Skip to content

Declare hybrid Mamba indexer host pool - #40915

Merged
ispobock merged 3 commits into
mainfrom
hicache-decl-c
Oct 6, 2026
Merged

ispobock merged 3 commits into
mainfrom
hicache-decl-c

Conversation

@ispobock

@ispobock ispobock commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Part 3 of 5 of #40608. Hybrid Mamba plus DSA models (GLM-5.3-Flash) restore KV from host without the indexer on main, so a host hit runs attention on stale block selection. Host restore KL against warm is 0.06 to 0.71 on main. build_hybrid_mamba_stack now assembles the full attention pool's declarations next to the Mamba host pool, and _MambaStrategy raises when a declared pool is missing. HybridLinearKVPool.host_pool_decls() declares only the buffers of its full attention sub pool. Mamba state stays with its owner and the existing Mamba host path.

The DSA indexer is already declared by its pool since #40913, but each strategy assembled its own host pools and the Mamba path never added it. With declarations the pool owner lists its host buffers once, and every strategy holding that pool builds them from the same list instead of repeating a per-strategy branch. A strategy that drops a declared pool now fails at startup instead of restoring stale state. On main the same check only logs declares host pools ['indexer'] that _MambaStrategy did not assemble, which is how this gap showed up.

Stack: #40913 (declarations and DSA target), #40914 (separate draft), #40915 (hybrid Mamba), #40916 (QSA), #40917 (plain KV and cleanup). Each PR is based on the previous one.

Accuracy

GLM-5.3-Flash tp8, page 64, hicache size 20 GB, extra_buffer strategy: stack KV + INDEXER + MAMBA, indexer host 1.76 GB, host restore KL against warm 1.9e-3, 1.6e-3, 3.5e-3 at the finished sequence length. Main on the same runs: 0.06 to 0.71.


CI States

Latest PR Test (Base): 🚫 Run #37302418283
Latest PR Test (Extra): 🚫 Run #37302417380
Latest PR Test (AMD ROCm 10): ❌ Run #37302418055

is_anchor=True,
packed_draft_device_pools=mtp_draft_device_pools,
),
entries = _build_declared_entries(configs, root_host_pool=kv_host_pool) + [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question on the INDEXER entry for kpool models: it copies index rows by KV page, but with index_kpool=4 the writer stores the compressed rows for all four 64-token pages of a 256-token group in the group's first page (token_page_row = pool_page_group * POOL_SIZE,

token_page_row = pool_page_group * POOL_SIZE
). mamba_checkpoint_grid is lcm(64, 64) = 64 here, so a parent node can end at 192. With write_through it is backed up once while page 0 holds rows 0-47; a child then writes rows for 192-255 into slots 48-63 of that same page, and those slots are never re-backed-up. A host restore past 192 would read stale index rows.

Is something keeping radix/checkpoint boundaries 256-aligned for kpool models that I missed? If not, this probably needs the page-local layout from #40134 (or a 256 tree page as in #38212) before or alongside this PR; the shared-page layout was also raised in #39156.

@github-actions github-actions Bot added documentation Improvements or additions to documentation deepseek npu jit-kernel labels Oct 1, 2026
@ispobock
ispobock changed the base branch from hicache-decl-b to main October 1, 2026 13:35
@ispobock ispobock added run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci) bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) labels Oct 1, 2026
# Conflicts:
#	python/sglang/srt/mem_cache/hybrid_cache/hybrid_pool_assembler.py
@ispobock
ispobock merged commit ed75fe6 into main Oct 6, 2026
177 of 203 checks passed
@ispobock
ispobock deleted the hicache-decl-c branch October 6, 2026 02:18
@andrew-bydlon

Copy link
Copy Markdown

Thank you for getting this merged. Looking forward to the next rebuild for GLM 5.3 Flash.

ormandj added a commit to ormandj/sglang that referenced this pull request Oct 10, 2026
…s separate

Rebuilt on the declared host pools from sgl-project#40913 and sgl-project#40915, which now restore
the target and draft DSA index buffers. What main does not cover is kept:

- Hybrid Mamba stacks scale the explicit KV host budget for declared
  dependent pools (the DSA indexer), as they already do for QSA indexes.
- DSAIndexerPoolHost.destroy unregisters its index buffer, which the
  inherited cleanup of kv_buffer misses.
- An MTP draft whose MLA KV rows differ from the target's (for example a
  separate draft KV dtype) uses the separate draft sidecar instead of failing
  the packed-row check; several mismatched runners are rejected because the
  sidecar keeps one.
@ormandj ormandj mentioned this pull request Oct 13, 2026
3 of 12 tasks
ormandj added a commit to ormandj/sglang that referenced this pull request Oct 13, 2026
…s separate

Rebuilt on the declared host pools from sgl-project#40913 and sgl-project#40915, which now restore
the target and draft DSA index buffers. What main does not cover is kept:

- Hybrid Mamba stacks scale the explicit KV host budget for declared
  dependent pools (the DSA indexer), as they already do for QSA indexes.
- An MTP draft whose MLA KV rows differ from the target's (for example a
  separate draft KV dtype) uses the separate draft sidecar instead of failing
  the packed-row check; several mismatched runners are rejected because the
  sidecar keeps one. Separate draft recurrent state still requires matching
  rows, because only packed MTP backs it up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) deepseek documentation Improvements or additions to documentation hicache Hierarchical Caching for SGLang jit-kernel npu run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants