Repository navigation
Conversation
Host-only mode keeps prefix checkpoints in the hicache host pool and drops the donated GPU slot from the mamba ratio. A later match still returns the Full KV indices for those nodes. Co-authored-by: Cursor <[email protected]>
Host-only checkpoints keep the ring on req_pool_idx instead of every mamba slot, and padding rows no longer alias request 0. Co-authored-by: Cursor <[email protected]>
A match that stands on a host mamba checkpoint was dropping the contiguous GPU Full prefix in front of it, so those pages were recomputed instead of reused. Co-authored-by: Cursor <[email protected]>
…mamba. A repeat insert was copying a full GPU slot and then dropping the new host index. Co-authored-by: Cursor <[email protected]>
A host-only checkpoint has no device value. Load-back was still restoring a node slot and committing the request slot back onto the node, so each hit paid two H2D copies and re-pinned a GPU slot. Concurrent hits on the same anchor then collided in ongoing_load_back. Skip the node restore, leave the node on the host tier, and retry admission while that anchor's load-back is still in flight. Co-authored-by: Cursor <[email protected]>
97fd5d3 to
cd3d6fc
Compare
InsertParams requires mamba_host_value. The unevict and commit walks set it, but the overlap step did not, so the radix-tree crate failed to compile.
The in-flight load-back guard ran with the flag off and could block admission. Host-only copies now use the hicache transfer engine, and a finished no-buffer request frees the GPU slot it only copied.
The flag stays cached on the mamba component, and a missing mamba value is allowed only for the insert that already found a checkpoint. Co-authored-by: Cursor <[email protected]>
The host-only walk already passes the layer it evicts, and the fixture has to record that call. Co-authored-by: Cursor <[email protected]>
The load-back file already imported it, and a second import fails the unused-import lint. Co-authored-by: Cursor <[email protected]>
Clippy rejects the stacked negations around the host-only exception. Co-authored-by: Cursor <[email protected]>
Host-only ring indices are read only when that ring is on, empty layer maps no longer index the first entry, and the MLA view publishes the staging buffer HiCache already reads. Co-authored-by: Cursor <[email protected]>
Keep main's MLA hicache staging type, which already covers a single tensor or a K/V pair. Co-authored-by: Cursor <[email protected]>
|
/rerun-failed-ci |
|
@amd-bot ci-status |
# Conflicts: # python/sglang/srt/mem_cache/kv/router.py
CI Status for PR #44718Verdict (1–2 sentences): No test job has failed on head Warning PR CI is incomplete, so a green result can't be assumed yet. The jobs most relevant to this PR's change (an AMD-side mamba hicache change) haven't finished:
Executed failures: AMD: 0 (0 related) · Others: 0 (0 related) Gate jobs that failed (no verdict; these are not test failures)
What to do before merge
Generated by amd-bot using Claude Code CLI |
|
/rerun-failed-ci |
1 similar comment
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
@amd-bot ci-status |
CI Status for PR #44718Verdict (1–2 sentences): None of the executed failures was caused by this PR. Five jobs failed in the CI health-check step because the GitHub API returned an HTTP 502, so no tests ran in them. The two Xeon unit-test failures happen because the Xeon image installs sglang from the PR branch, which is behind Warning PR CI is incomplete. In Executed failures: AMD: 0 (0 related) · Others: 7 (0 related): 5 health-check 502s and 2 Xeon unit tests Other Executed Failures
The gate jobs What to do before merge
Generated by amd-bot using Claude Code CLI |
|
/rerun-failed-ci |
3 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
PR Test Base, PR Test Extra all good. |
Main's sgl-project#44718 made _can_run_dspark_cutedsl_mtp read self.state_pool (a request-scoped ReplaySSM ring keeps the Triton path). The gate test builds the backend with __new__, so __init__ never sets that field and the merge with main fails with AttributeError. Set it to None: no state pool, so the gate goes on to the capability check the test pins.
…tegrated Conflicts resolved: - components/base.py, mamba.py / unified_tree_core.rs, components/mamba.rs: main added host-only Mamba checkpoints (sgl-project#44718) to the per-path cap walk this PR moved into the shared TreeComponent._evict_path_states_beyond_cap / UnifiedTreeCore::evict_path_states_beyond_cap_. The shared walk gains a count_host_only flag carrying main's host-only holder logic (host-only holders count toward the cap, skip on host lock, evict from host, cascade with the same layer). Mamba passes its host-only setting; SWA passes false, so SWA behavior is unchanged. - unified_tree_core.py / unified_tree_core.rs: keep the PR's dispatch by the action's component_type instead of main's TREE_STATE / Family::State lookup. - rust_tree_core/adapter.py: keep both mamba_host_only_checkpoint and swa_max_states_per_path; gate the SWA cap on TREE_WINDOW in families (main's slot model); translate component ids through main's _CoreIds both ways (ids.core() on the binding call, ids.tree() when decoding the evict_excess_path_states tagged action). - python_bindings.rs, CacheInitParams (Rust): keep both new fields and pyo3 kwargs. - swa.py: keep main's _evict_device_collapse_leaves and storage_and_sub_pool in apply_component_action, plus the PR's cap field and EvictExcessPathStates branch. - field_order.py: append swa_max_states_per_path after main's new fields. - test kit fixtures.py: drop draft_swa_window (moved into tree_slots on main), keep swa_max_states_per_path. - tests: base.rs takes main's imports with EvictExcessPathStates; test_mamba_path_state_cap.py takes main's ComponentType import path. Follow-ups for main changes outside conflict hunks: - tests/components/mamba.rs: pass MAMBA to main's new evict_excess_path_states_counts_host_only_checkpoints call. - test_swa_path_window_cap.py: import from where names are defined (unified_tree_core, component_type); the fake tree core gains joint_lru / joint_window_type and the target arg of _cascade_evict, as on main. Validation (gb300-oci-jhb, GB300, sglang nightly-dev-cu13-20261106-858073e4, torch 2.14.1, Rust TreeCore built from this tree via the loader's fingerprinted cargo build, production and inspection variants): - test_swa_path_window_cap.py: 10 passed (Python and Rust TreeCore) - test_mamba_path_state_cap.py: 10 passed - test_rust_tree_core_integration.py: 580 passed - test_rust_tree_core_errors.py 25, test_tree_core_registry.py 34, test_hicache_write_back_ordering.py 2, test_mamba_donated_alloc_ratio.py 20, test_hicache_sidecar_restore.py 6, test_unified_cache_linker.py 88, test_swa_unittest.py 24, test_mamba_unittest.py 14: all passed - unified_radix_cache/ core 468, hicache 295, insert_walk 46, kv_events 17, load_back 66, storage 224 passed (skips are the suites' own gates); test_unified_radix_cache_rust.py (unittest): 1297 ran, OK (181 skipped) - cargo test --locked in rust/sglang-radix-tree: 969 passed, 0 failed, 1 ignored - pre-commit on the changed files: pass (clippy rust/ workspace hook not runnable on macOS: turbojpeg-sys build)
…te safely (#132) ## Motivation - Serve `amd/Kimi-K3-Quark-MXFP4-AttnFP8` on Kimi-K3's gfx950 launches (the AgentX c1 recipe). - Attention projections are Quark per-channel FP8; experts are native MXFP4. - KDA state is bf16 (`--mamba-ssm-dtype bfloat16`), with slot-scoped ReplaySSM. - On `main` the launches refuse its FP8 projections, so it is served with `--enable-amd-monokernel` off. - Standalone against `main`; includes the Kimi-K3.1 bf16 guard from #131. | Input | Before | This PR | | --- | --- | --- | | K1 `in_proj` weight | bf16 | bf16, or Quark FP8 (row-major or AITER-preshuffled) | | Layer-launch `o_proj` weight | bf16 | bf16, or Quark FP8 (row-major or AITER-preshuffled) | | KDA state dtype | fp32 | fp32 or bf16 | | ReplaySSM slot-scoped ring (k / v / gate / beta rows) | fp32 state | fp32 or bf16 state | | ReplaySSM request-scoped ring (sgl-project/sglang#44718) | not checked | declined: SGLang's path | ### Dependency - FP8 K1 needs sgl-project/sglang#44362 (open), which merges Quark FP8 `[q,k,v,g | f_a | b]` into `fused_qkvg_proj`. - When SGLang sets `_qkvgbfa_in_qkvg_proj`, K1 reads `fused_qkvg_proj.weight` with the merged FP8 `[f_a | b]` tail. - SGLang `main` has `fused_qkvg_proj` but neither that tail nor the flag. - K1 also needs the bf16 `f_b` copy (`_bfa_f_b_w`); a checkpoint restore without it takes SGLang's KDA path. - Without it, K1 logs `not built for the KDA layers` and only the layer launch's FP8 `o_proj` runs. - Open item: on SGLang `91a841a004` (an AgentX stack with an earlier #44362 revision), K1 was still not built here. - SGLang reserved no FP8 tail rows at init; still to be checked against #44362's head `3492e17401`. - `test_k1_runs_the_fp8_in_projection` fails until K1 engages, so the gap cannot pass silently. - CI: `kimi_k3_quark` is marked `blocked` until #44362 merges, so the AMD gate does not fail on the missing merge. - The gate reads `scripts/ci/models.py` from the base branch; run the Quark suite directly until then. ## Modifications ```mermaid flowchart LR W["Quark FP8 weight<br/>+ fp32 row scale"] --> F["stages/wfmt.py<br/>FP8 -> bf16 in registers"] F --> K1["K1 in_proj GEMV"] F --> O["layer launch o_proj"] S["committed KDA state<br/>(bf16 or fp32)"] -->|read| KDA["attention/kda.py"] K1 --> KDA KDA -->|"no ReplaySSM: per-token snapshots"| P["intermediate state pool"] KDA -->|"ReplaySSM: k / v / gate / beta rows"| R["slot-scoped ring"] ``` - FP8 attention weights - `stages/wfmt.py`: one shared path for K1 `in_proj` and `o_proj`. - FP8 widened to bf16 in registers; the fp32 row scale applies to the fp32 sum. - The `wfmt` refactor compiles all 81 exercised kernels to byte-identical ISA. - `f_b` comes from the bf16 copy SGLang keeps for its fused decode (`_bfa_f_b_w`). - KDA state (`attention/kda.py`, `k1.py`) - bf16 or fp32 state, as SGLang resolves it (`--mamba-ssm-dtype` or `SGLANG_MAMBA_SSM_DTYPE`). - With ReplaySSM, K1 writes ring rows (raw k / v, gate, beta) that SGLang's commit replays. - A request-scoped ring is declined: it is indexed by request, not by the slot K1 stores at. - Safety checks (`spec.py`, `k1.py`) - Validate dtype (E4M3), scales, layouts and native MXFP4 expert shapes; accept interleaved or separated experts. - Refuse a non-SiTU MoE, SiTU parameters other than K2's (4.0, 25.0), and a static-input Quark FP8 projection. - Kimi-K3.1 (`kimi_k31/spec.py`): monokernels refuse to start with a non-bf16 KDA `in_proj` or `o_proj`, or a non-fp32 KDA state, even for narrow-only serving: the wide launch reads them as bf16 / fp32. - Optional SGLang names (`_qkvgbfa_in_qkvg_proj`, `SGLANG_OPT_HIP_K3_AITER`) stay out of `SGLANG_READS`. - Tests - CPU spec tests and K1 GPU tests for the new formats and state dtypes. - TP8 harness pins `AITER_SITUV2_A4W4=1`, the MoE numerics the launch implements. - FP8 `o_proj` seam bounds (`k2_fp8.*`): prefix and `x` cosine > 1 - 1e-6. - Measured vs check_k2's torch reference (E4M3 weight x unquantized activation): prefix cos 1 - 1.19e-7 accumulating, exactly 1 resetting. - K1 ring test also runs the Quark recipe's variant (preshuffled FP8 in_proj, bf16 state): fold cos 0.999997. - Check mode (`SGLANG_AMD_MONO_CHECK=1`) logs any metric without a bound instead of skipping it. - Follow-up: check mode scores the whole ReplaySSM ring, stale rows included; scoring only the step's rows needs a check-mode run where FP8 K1 engages to recalibrate the `k1_fp8.ring_*` bounds. - E2E and CI - `test_kimi_k3_quark_server.py` on the Quark checkpoint: - Reused from `test_kimi_k3_server.py`: the routing line and the cache-flushing KL check. - Replaced: few-shot GSM8K by sgl-eval GSM8K. Not repeated: the fault test (checkpoint-independent). - Added: K1 engages on the FP8 in-projection; KL after a radix-cache prefix hit. - Recipe `kimi_k3_quark_server.py`: derived from the AgentX c1 server; it keeps SGLang's default `fcfs` scheduler where AgentX sets `--schedule-policy lpm`. - `test_kimi_k3_server.py`: `_launch` and the test class take the recipe, so the Quark test reuses them. - New `kimi_k3_quark` entry in `scripts/ci/models.py`: `blocked` on sgl-project/sglang#44362 and `pr: False`. ## Accuracy Tests - Unit: `test/unit` 685 passed on SGLang `main@2005571ac1` (39 in the two Kimi spec files), after merging main. - New E2E checks, this branch, on SGLang `91a841a004` (AgentX stack), 8x MI355X, monokernels on. - K1 was not built in this run (see Dependency), so these cover the FP8 `o_proj` launch and SGLang's KDA. | Check | Result | Bound | | --- | ---: | ---: | | GSM8K, sgl-eval 0.1.3, 200 questions, thinking, temperature 1.0, top_p 0.95, 16k tokens | 0.98 | > 0.95 | | Mean KL, decode vs prefill, cache flushed (48 prompts x 32 tokens) | 0.0096 | 0.03 | | Mean KL after a radix-cache prefix hit (32 prompts x 512 tokens, 31 hits scored) | 0.0117 | 0.03 | | K1 engaged | **no** | must engage | ### Earlier results (author's runs) - GSM8K, sgl-eval 0.1.3, 1,319 questions, max tokens 16384, monokernels on vs off, same server. - Server: c1 AgentX recipe, `Kimi-K3-Quark-MXFP4-AttnFP8`, TP8, DSpark block 7, ReplaySSM, bf16 state. - Build: SGLang `fb19a76c70`, AITER `9ab94e438f`, this PR at `d31bc07`. | Monokernels | Accuracy | Correct | | --- | ---: | ---: | | Off | 97.35% | 1284 / 1319 | | On | **97.42%** | 1285 / 1319 | - McNemar p = 0.75 (no significant difference). - E2E bounds of the earlier `test_kimi_k3_quark_server.py` (few-shot GSM8K, 200 questions, x3). - Build: SGLang `de0f491836`, AITER `5405ee0026`, FlyDSL 0.5.0, this PR at `c06024c`. - That SGLang lacks #44362, so K1 was not built; these cover the FP8 `o_proj` launch only. | Run | GSM8K (bound 0.95) | KL (bound 0.03) | | --- | --- | ---: | | Monokernels on (routing line present) | 0.985 / 0.98 / 0.97 | 0.0105 | | Monokernels off | 0.99 / 0.98 / 0.985 | 0.0060 | | On + `ROCM_QUICK_REDUCE_QUANTIZATION=INT4` | 0.99 / 0.99 / 0.985 | 0.0100 | - The recipe leaves INT4 quick-reduce out; whether it dispatched in that run was not recorded. - Kernel tests on MI355X: | Test | Result | | --- | --- | | TP8 harness | 3 tests, 2 subtests passed; layer cos 0.999995 (bf16, FP8, FP8-preshuffled); MoE cos 0.99997 | | K1 (`test_kimi_k3_k1.py`) | 17 passed; FP8 in-projection cos 0.999999; ReplaySSM fold cos 0.999997 | ## Speed Tests and Profiling - `sglang.benchmark.serving`, random 8k in / 1k out, same node and build, monokernels on vs off. | Client concurrency | Median TPOT off (ms) | Median TPOT on (ms) | Output tok/s off | Output tok/s on | | ---: | ---: | ---: | ---: | ---: | | 1 | 2.62 | **1.78 (1.47x)** | 314.1 | **433.8** | | 2 | 3.41 | 3.43 | 488.8 | 494.2 | - c1: 1.47x faster TPOT with the monokernels on; c2 is neutral. - This run's server flags and verify widths are not recorded here. - Not attached: an on/off comparison past the launches' 8-row width (wider steps take SGLang's path). ## Checklist - [x] `pre-commit run --all-files` passes. - [x] Tests under `test/` cover the change. - [x] The SGLang commit tested against is named above. - [x] Accuracy and speed results are attached. - [ ] CODEOWNERS line: not applicable (extends Kimi-K3 / K3.1). ## Review and Merge Process 1. The `lint` and `Check PR title` checks must pass. 2. Ask a `kimi_k3` / `kimi_k31` code owner from `.github/CODEOWNERS` to review. 3. Merge with "Squash and merge": the PR title becomes the commit title on `main`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Motivation
Mamba radix checkpoints donate a GPU slot for every matched prefix. On a Kimi-K3 c=48 recipe that floor is
max_running_requests * 5(480), so the GPU mamba pool stays large even when the checkpoint only needs to be reloaded from host.Modifications
Set
SGLANG_OPT_MAMBA_HOST_ONLY_CHECKPOINT=1(default off). It requires--enable-hierarchical-cacheand rejects--enable-int8-mamba-checkpoint. This is an environment variable, not a server argument.With the variable unset, the server keeps the previous path: the same mamba ratio, the same donated GPU slot, the KDA ReplaySSM ring indexed by the mamba slot, a single in-flight load-back receipt, and a device match that follows GPU mamba slots. The new
InsertParams.allow_missing_mambabit stays false, so an insert that omits mamba still panics.With the variable set:
no_bufferwith page size 1 returns 1.max_running_requests // attn_dp + 1) instead of every mamba slot. Padding rows are -1.mamba_host_valuewithout a donatedmamba_value. A repeat insert that already found a checkpoint may omit both values; that permission is on the insert params and applies only to that insert.Memory
Per-rank GPU, MI355, Kimi-K3 c=48, 96 running requests, page size 32, extra buffer, overlap, DCP 8, ReplaySSM on. The env-on pool is the size the ratio allows;
max-mamba-cache-sizehas to be lowered with it. Leaving the pool at 480 keeps the 13 GB allocation and only raises the running-request cap.Env off is the earlier 0.87 log: conv 0.85 GB + ssm 12.15 GB, ring 9.14 GB. Env on conv + ssm is
ci355_ix_20261015_213315_c20e(max-mamba-cache-size 288): conv 0.51 GB + ssm 7.30 GB. The same class of boot withrequest_ring=Truekeeps that 7.81 GB pool and sizes the ring at 97 rows (d = k = rawv = rawk = 0.306 GB, g = 0.613 GB, beta = 0.005 GB). The intermediate conv window stays 0.86 GB in both measurements. The checkpoint itself sits in the existing hicache host pool.Tests
Python:
test_flag_off_restores_original_ratios,test_flag_on_drops_base_but_keeps_no_buffer,test_host_only_drops_gpu_prefix_floor: ratio is 3 / 4 / 5 with the flag off, and 1 / 2 / 3 with it on.test_flag_off_keeps_a_donated_gpu_slot,test_host_only_no_buffer_frees_the_request_slot.test_kda_host_only_ring_follows_requests: flag off charges every mamba slot; flag on chargesmax_running_requests + 1rows.test_inflight_anchor_still_loads: an anchor already inongoing_load_backstill load-backs. Moved out of the ratio file.test_host_only_load_back_fills_request_slot_without_node_slot,test_host_only_second_load_back_on_inflight_anchor_retries.Rust (
sglang-radix-treemamba component):missing_mamba_insert_keeps_the_existing_checkpoint_when_allowedinsert_host_only_checkpoint_keeps_no_gpu_slothost_only_checkpoint_keeps_the_device_kv_prefixhost_only_checkpoint_counts_gpu_kv_in_front_and_host_kv_at_the_boundaryhost_only_anchor_bumps_the_mamba_host_hithost_only_load_back_build_copies_into_the_request_slot_onlyhost_only_load_back_commit_keeps_the_node_off_the_device_tierhost_only_mamba_anchor_disables_branching_under_hicacheOn mi355,
test_mamba_donated_alloc_ratio.py(18),test_mamba_path_state_cap.py(10),test_replayssm_ring_accounting.py(4), andTestInflightAnchorStillLoadspassed.cargo test --libforsglang-radix-treepassed 949 tests.Accuracy Tests
No model-output change when the variable is unset. With it set, load-back still restores the request slot from the host checkpoint; the GPU tests above cover that copy.
Speed Tests and Profiling
The memory table above is the measured effect. This PR does not include a new throughput number.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ✅ Run #40877021617
Latest PR Test (Extra): ✅ Run #40877021430
Latest PR Test (AMD ROCm 10): ✅ Run #40877021529