[GH-ISSUE #655] Feature request: cross-model KV-cache handoff (SwaT, arXiv 2610.15095) - start with KV export/import #269

Open
opened 2026-10-29 21:23:31 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Gazelle221B on GitHub (Oct 29, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/655

Request: a way to hand a conversation's context from one Maya model to another without the receiver re-reading the prompt, along the lines of Swarm Telepathy: Prefill-Free KV-Cache Transfer Across Families (SwaT, arXiv:2610.15095, code at Ar-Kareem/SwaT).

What SwaT does. Both models stay frozen. A small trained "mapper" (about 300M parameters, B blocks of cross-attention over the sender's grouped K/V, with the sender's RoPE removed and the receiver's RoPE applied at integer positions) predicts the receiver's full KV cache from the sender's. The receiver then prefills only the new query. The tokenizers don't have to match: alignment goes through shared character spans. The paper reports about 4x lower wall-clock than text-to-text agent handoffs, and on Qwen 3 4B → Llama 3 8B the mapper costs 5.7 ms vs 52.9 ms of re-prefill at 1K tokens, and 1.3 s vs 8.0 s at 64K. It needs one mapper per sender→receiver pair, trained in under 1 GPU-day on text only.

Why it would matter for Maya. People run several large models behind one router and switch between them in agent workflows, for example a planner on one model and a coder on another. Every switch re-reads the whole context. On a 2x 32 GB AMD box that costs tens of seconds to minutes at 64K-120K tokens, for each model change.

What I think Maya would need (smallest first):

  1. KV export/import in the engines. Write and load a conversation's KV cache (per layer, pre-RoPE keys plus values, with token positions and spans) through a documented file or GEN-protocol hook. The slot keep/restore work (#356, #394) looks like a natural base. This alone would let people experiment with mappers out of tree.
  2. A mapper runtime hook. Run a pair's mapper (a small transformer, so HIP/CUDA via existing GEMMs) between export and import, plus server support for a "handoff" request.
  3. Trained mappers for Maya's pairs (DeepSeek-V4.1 ⇄ GLM-5.3, and to/from Qwen3.8 Flash-Next if Strata takes part). This is the hard part: the paper only covers 3B-32B dense models. DeepSeek's compressed KV and sparse indexer keys and GLM's DSA cache differ from standard attention, so the mapper targets and the training cost for 300B+ MoE receivers are open questions.

Caveats. The SwaT repository has no license file at the time of writing, so its code can't be reused directly; the method itself is described in the paper. The authors also note that a transferred cache can carry information that isn't visible in the text, which matters for auditing.

I can test on 2x 32 GB AMD GPUs (HIP) with DeepSeek-V4.1 (Maya-XS) and GLM-5.3-Flash. Step 1 alone would already be useful to me.

Originally created by @Gazelle221B on GitHub (Oct 29, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/655 **Request:** a way to hand a conversation's context from one Maya model to another without the receiver re-reading the prompt, along the lines of *Swarm Telepathy: Prefill-Free KV-Cache Transfer Across Families* (SwaT, [arXiv:2610.15095](https://arxiv.org/abs/2610.15095), code at [Ar-Kareem/SwaT](https://github.com/Ar-Kareem/SwaT)). **What SwaT does.** Both models stay frozen. A small trained "mapper" (about 300M parameters, B blocks of cross-attention over the sender's grouped K/V, with the sender's RoPE removed and the receiver's RoPE applied at integer positions) predicts the receiver's full KV cache from the sender's. The receiver then prefills only the new query. The tokenizers don't have to match: alignment goes through shared character spans. The paper reports about 4x lower wall-clock than text-to-text agent handoffs, and on Qwen 3 4B → Llama 3 8B the mapper costs 5.7 ms vs 52.9 ms of re-prefill at 1K tokens, and 1.3 s vs 8.0 s at 64K. It needs one mapper per sender→receiver pair, trained in under 1 GPU-day on text only. **Why it would matter for Maya.** People run several large models behind one router and switch between them in agent workflows, for example a planner on one model and a coder on another. Every switch re-reads the whole context. On a 2x 32 GB AMD box that costs tens of seconds to minutes at 64K-120K tokens, for each model change. **What I think Maya would need** (smallest first): 1. **KV export/import in the engines.** Write and load a conversation's KV cache (per layer, pre-RoPE keys plus values, with token positions and spans) through a documented file or GEN-protocol hook. The slot keep/restore work (#356, #394) looks like a natural base. This alone would let people experiment with mappers out of tree. 2. **A mapper runtime hook.** Run a pair's mapper (a small transformer, so HIP/CUDA via existing GEMMs) between export and import, plus server support for a "handoff" request. 3. **Trained mappers for Maya's pairs** (DeepSeek-V4.1 ⇄ GLM-5.3, and to/from Qwen3.8 Flash-Next if Strata takes part). This is the hard part: the paper only covers 3B-32B dense models. DeepSeek's compressed KV and sparse indexer keys and GLM's DSA cache differ from standard attention, so the mapper targets and the training cost for 300B+ MoE receivers are open questions. **Caveats.** The SwaT repository has no license file at the time of writing, so its code can't be reused directly; the method itself is described in the paper. The authors also note that a transferred cache can carry information that isn't visible in the text, which matters for auditing. I can test on 2x 32 GB AMD GPUs (HIP) with DeepSeek-V4.1 (Maya-XS) and GLM-5.3-Flash. Step 1 alone would already be useful to me.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#269
No description provided.