Repository navigation
[Feat] unified_cache: Support hybrid SWA + Mamba models in the Mooncake direct linker - #41343
Merged
Merged
Conversation
alphabetc1
requested review from
Jialin,
Ying1123,
hanming-lu,
hnyls2002,
huangtingwei9988,
hzh0425,
ispobock,
merrymercy,
stmatengss,
xiezhq-hermann and
yizhang2077
as code owners
September 26, 2026 10:27
This was referenced Sep 27, 2026
This was referenced Sep 29, 2026
This was referenced Oct 11, 2026
alphabetc1
marked this pull request as draft
October 12, 2026 16:22
alphabetc1
force-pushed
the
feat/linker-mamba
branch
2 times, most recently
from
October 13, 2026 01:18
5724394 to
10730ce
Compare
alphabetc1
marked this pull request as ready for review
October 13, 2026 14:18
…test in the direct linker
alphabetc1
force-pushed
the
feat/linker-mamba
branch
from
October 14, 2026 12:55
29b8726 to
6efa28e
Compare
Collaborator
Author
|
/rerun-test -c |
Contributor
|
🚀 🚀 |
hzh0425
approved these changes
Oct 15, 2026
huangtingwei9988
approved these changes
Oct 16, 2026
stmatengss
approved these changes
Oct 16, 2026
hnyls2002
approved these changes
Oct 17, 2026
This was referenced Oct 18, 2026
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The unified-cache external linker (direct L3, no host tier) supports Full and SWA tree components only. Hybrid SWA + Mamba models such as Inkling are rejected at startup by both the Python wrapper and the Rust tree core, and the Mamba component's linker hooks raise.
Depends on #44220: Inkling replays the Full prefill CUDA graph by default, and without #44220 a loading batch can replay before its layer-wise load lands.
Modifications
Device pool group for FULL + SWA + MAMBA (
linker_pool_assembler.py,hybrid_pool_assembler.py)_MambaSwaStrategy.build_direct_linker_pool_group: the full-attention and SWA MHA pools each pack a layer's K and V into one page object; the Mamba pool is slot-addressed (one row per state slot; the empty temporal state of conv-only models is skipped).--enable-unified-memory, int8 Mamba checkpoints, Mamba side states (short conv / ngram), and scaled KV caches.Mamba component (
components/mamba.py)TRAILING_PAGES, so a prefix is restorable only where a stored state ends._alloc_mamba_slot, evicting if needed, same sizing contract as HiCache'sprepare_load_back)._adopt_loaded_state. The forward then reads the state layer by layer through the linker's layer counter, already registered onreq_to_token_poolfor Mamba pools. ABORT frees the loaded slot.Wrapper (
unified_cache_linker.py)ComponentType.MAMBA.Mooncake keys (
mooncake_store.py)DevicePoolEntryalways maps to one object per page per pool (_kfor KV,_{pool}otherwise); the layer-wise load reads one key per location. Without this, the MHA SWA entry has no key scheme (Unsupported Mooncake hybrid pool name: swa). Keys for the existing DeepSeek-V4 / DSA linker pools are unchanged: those groups are rank-replicated and already took the single-object branch.Rust tree core
set_enable_external_cache_linkerand addMambaComponent::build_external_linker_offload_transfer(without it the Rust core never offloads a Mamba state, so it never restores one).Tests
test_unified_cache_linker.py(Python and Rust tree cores):test_mamba_state_round_trips_only_at_its_checkpoint(offload keys, restorable only at a stored state, LOAD/PREPARE binding, insert),test_mamba_load_supersedes_a_shorter_device_cow(a shorter device CoW must not overwrite the loaded state or leak its slot).test_linker_pool_assembler.py::test_mamba_swa_uses_hybrid_assembler_strategy: K/V packing offsets, slot-addressed Mamba rows, empty temporal state skipped.cargo test --lib: 930 passed.Accuracy Tests
Temporary CI skip:
test_unified_cache_linker_kl_inkling.pyis disabled in CI until #44220 is merged and included in the tested branch (tracking deadline: 2026-10-29). Re-enable its CI registration after that fix lands. This lets dependent PRs proceed, but does not remove the runtime correctness dependency on #44220: Full prefill graph replay can read incomplete layer-wise loads without it. The measured results below are unchanged.New
test_unified_cache_linker_kl_inkling.py(tinythinkingmachines/Inkling --revision test, Mooncake,--enable-deterministic-inference, default Full prefill CUDA graph). This checkpoint scores every token identically in prefill and decode, so the threshold is a 1e-9 floor, not a tolerance. Turn 1 offloads,/flush_cachedrops the device tree, turn 2 restores from Mooncake alone (assertscached_tokens_details.host == cached_tokens) and is replayed against recomputed logprobs.Measured on 1x GB300 (Mooncake over TCP), with #44220 applied:
Known limitations
Related: #39511 (FULL + Mamba on UMBP for Kimi K3); the pool group, UMBP and DCP parts there are complementary to this PR.
Checklist
CI States
Latest PR Test (Base): ✅ Run #38998794952
Latest PR Test (Extra): ✅ Run #38998794915
Latest PR Test (AMD ROCm 10): ❌ Run #38998794906