Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Thanks for picking this up. Since #26274 introduced the original IndexCache design, I can help review the forward-port and validate the behavior against the original benchmarks. For the new PD/CP/HiCache paths, I can also help check whether the original reuse semantics are preserved. |
|
@feng397 Bisected — removing this PR gives 22min+ stable, adding it back crashes in 1-2min every time. Root cause is in The skip_topk path passes the producer layer's The kernel's fast path ( // hisparse.cuh ~line 516, slow path miss-copy:
const int64_t src_loc = req_host_cache_locs[miss_token];
// ↑ miss_token == -1 → OOB READThe hash insertion (~line 306) also doesn't filter -1 — it gets inserted as a valid key into the shared memory hash table, and downstream miss counting + host cache loc indexing blow up. Additionally, Suggestions:
Env: 4x L20X TP, |
|
Update: After more on-pod debugging, the Here's what we actually found: The crash is in target_verify CUDA graph replay, not decode. The stack trace points to Most likely trigger: What we ruled out (all verified on pod):
Workaround: Skip Would appreciate it if you could run |
…project#32035 sgl-project#33656 sgl-project#32183 sgl-project#33145) Applied PRs (latest from GitHub): sgl-project#33288 Indexer logits OOM fix sgl-project#30393 HiCache packed/sidecar draft caches sgl-project#31170 DPA prefix_affinity load balancing sgl-project#33795 DSpark compact ragged-verify CUDA graph JIT race sgl-project#32467 C128 plan-kernel warp barrier sgl-project#33865 DSpark x prefill CP unblock sgl-project#30371 SWA state pool sizing (storage page) sgl-project#33358 FlashMLA norm-rope K-tokens-per-block ILP sgl-project#33872 num_draft_tokens clamp + extend_len==0 skip (supersede sgl-project#32183) sgl-project#34002 Sidecar backup vacuously-successful fix (replaces sgl-project#33656, with tests) sgl-project#33862 Reclaim redundant host mirrors after storage backup sgl-project#31315 Avoid repeated Mooncake gets after stale hits sgl-project#32327 Q8KV8 sparse MLA prefill backend (flashmla_sparse_q8) sgl-project#31668 Fix sidecar pool life-time (use-after-free on prefetch abort) sgl-project#31195 TP0 verify-token-budget broadcast (adapted to get_schedule() API) Dropped (per user request or superseded): sgl-project#32771 IndexCache C4 top-k reuse — has bug sgl-project#32035 DSpark C128 online compressor — has bug sgl-project#33656 Superseded by sgl-project#34002 (same fix + unit tests) sgl-project#32183 Superseded by sgl-project#33872 (included in supersede PR) sgl-project#33145 Base f01f706 already has superior reasoning-effort profile system Conflicts resolved: sgl-project#31195: adapted to base get_schedule().disable_overlap_schedule API sgl-project#32327: path remapped jit_kernel/ -> kernels/jit/ and kernels/ops/attention/ sgl-project#31668: applied cleanly on top of sgl-project#30393+sgl-project#34002+sgl-project#33862 modifications
… alloc in target_verify + graceful fallback when prev_topk_indices is None)
|
Independent validation of this branch on 8x NVIDIA B200 SXM (SM100) with DeepSeek-V4-Flash-0731, checkpoint revision 7872f01b. Branch head e9100d6 built editable on top of the sglang:nightly-dev-20260731 base image (embedded sglang 3abbc56, torch 2.11.0+cu130). Launch shape: monolithic single-node TP8, megamoe, context_length 1048576, chunked prefill 8192, PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True, Three findings: an SM100 startup crash in decode CUDA-graph capture (the actionable item, reported first), the perf trend on real prose, and an early-stop quality observation. 1. Startup crash: CUDA illegal memory access in decode CUDA-graph capture on SM100, including at inert freq=1The branch crashes at startup about 8 minutes in, during decode CUDA-graph capture (
This narrows the repro to the branch tree versus the stock base image in this config (SM100, monolithic TP8 + megamoe, fp8 indexer); it does not localize to a specific branch change, and I have not verified a root cause. Two consequences carry through everything below: all perf and quality legs ran with Relation to @Leoyzen's report above: same error class, different phase. Their crash is 1-2 minutes into serving under freq=2 with flashinfer_mxfp4 + DSpark + HiSparse decode; ours is at startup capture with none of those flags, and reproduces with DSpark/HiSparse absent. I could not reproduce their runtime crash: freq=2 and freq=4 then served continuously for 23 and 20 minutes with zero illegal-memory hits across all cells and suite traffic. Adjacent but distinct; no shared-root-cause claim. Full docker logs (both crash attempts and the clean control) and the exact launch command are available on request, and I am happy to rerun on a fix. 2. Perf trend on real proseSetup difference up front, since it bounds what is comparable: your posted throughput table is PD-disaggregated, random token IDs, 100 output tokens, c=1. Mine is monolithic single-node TP8, real prose (cache-busted long-form text, unique cache-buster per request), max 64 output tokens, c=1, 3 reps, temperature 0. Absolute numbers are not cross-comparable; the qualitative growth trend is the comparable quantity.
The first rep at each context is a cold pass (for example 12.4s TTFT on 128K freq=1 versus about 3.0s warm); the p50 filters it out, the tok/s mean includes it. On real prose the advantage keeps growing with context, +21%/+38% at 512K and +28%/+53% at 1M for freq 2/4, which matches the direction of your random-ID trend past 256K. Prefill is un-graphed in this model config even on stock ( 3. Early-stop observation at 512K+
Available on request: per-request raw response JSONs, suite prompt transcripts, server logs, launch scripts. |
…ripped PD/disaggregation files) Forward-port of sgl-project#26274 by ChefWu551, adapted by feng397 (sgl-project#32771). Enables DSV4 C4 indexer top-k reuse: producer (F) layers compute raw top-k, shared (S) layers skip indexer/compressor/logits/topk and reuse cached indices via Triton raw→page-index transform. Config: --json-model-override-args '{"index_topk_freq": N}' (default 1=off) Performance: +7-18% throughput (scales with context length) Accuracy: AIME2025 94.2%→90.0% at freq=4 (use freq=2 for conservative) DSpark compatible: draft model has compress_ratio=0 (no C4 layers), IndexCache only affects target model C4 attention. topk_state threaded transparently through model.forward(). Stripped from PR: 4 disaggregation files (base/conn.py, common/conn.py, decode.py, prefill.py) + 3 PD test files — not needed for non-PD deploy. Conflict resolved in indexer.py: kept both _forward_oversize_varlen_chunked (from 9303e26) and _match_num_queries/_forward_c4_indexer_skip_topk (from PR). TBO and PP>1 rejected at startup (neither used in deployment).
Motivation
The upstream implementation is #26274. This PR only attempts to forward-port and merge it onto the current
mainbranch. It does not propose a separate IndexCache design. Credit for the original design, implementation, and benchmark results belongs to the authors and contributors of #26274.#26274 targets an older version of the DeepSeek V4 code and no longer applies cleanly after the model, attention, cache, and disaggregation paths evolved. This PR keeps its core behavior and adapts it to the current interfaces.
IndexCache lets producer (
F) C4 layers compute raw top-k indices and allows following shared (S) C4 layers to reuse them. A shared layer skips its own indexer compressor, query/weight computation, logits, and top-k selection. The cached values are logical C4 indices, so each shared layer still translates them through its own page table before running sparse attention.Modifications
Forward-port the core implementation
index_topk_freqandindex_topk_patterntoDeepSeekV4Config.Adapt to the current runtime
index_topk_freqas a positive integer and reject floats andbooleans.
index_topk_freq=nullto the default value1.F/Spatterns and require the first C4 layer to beF.pp_size > 1).Test coverage
generation, producer-subset validation, and bootstrap consistency.
reference for invalid indices, different page sizes, odd top-k sizes,
non-contiguous tensors, and empty top-k.
index_topk_freq=4;Current limitations
pp_size > 1)Accuracy Tests
Additional local validation used DeepSeek-V4-Flash with thinking enabled on AIME 2025, 30 questions, avg@4:
index_topk_freq=1index_topk_freq=4The original accuracy evaluation and methodology are also available in #26274.
Speed Tests and Profiling
Additional local validation used DeepSeek-V4-Flash in a PD disaggregation setup with random token IDs, 100 output tokens.
Throughput at concurrency=1:
freq=1input tok/sfreq=4input tok/sfreq=1output tok/sfreq=4output tok/sThe gain increases with context length, consistent with #26274, which reports approximately 17% throughput improvement at 256K input length. Full benchmark commands and profiling results are available in the upstream PR.
CI States
Latest PR Test (Base): ❌ Run #30601244952
Latest PR Test (Extra): ❌ Run #30601244802