Skip to content

Improve docs & Rename Gemini -> VertexAI - #19

Merged
merrymercy merged 6 commits into
mainfrom
docs
Jan 17, 2024
Merged

merrymercy merged 6 commits into
mainfrom
docs

Conversation

@merrymercy

Copy link
Copy Markdown
Collaborator

No description provided.

@merrymercy
merrymercy merged commit bf51ddc into main Jan 17, 2024
@merrymercy
merrymercy deleted the docs branch January 17, 2024 10:54
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
yanbing-j pushed a commit to yanbing-j/sglang that referenced this pull request Mar 25, 2025
* support W8A8 for DeepSeek-R1

* add assertion on cpu_has_amx_support()

* refactor device check in MoE
pi314ever pushed a commit to pi314ever/sglang that referenced this pull request May 16, 2025
chunyuan-w added a commit to chunyuan-w/sglang that referenced this pull request May 28, 2025
* support W8A8 for DeepSeek-R1

* add assertion on cpu_has_amx_support()

* refactor device check in MoE
chunyuan-w added a commit to chunyuan-w/sglang that referenced this pull request May 28, 2025
* support W8A8 for DeepSeek-R1

* add assertion on cpu_has_amx_support()

* refactor device check in MoE
chunyuan-w added a commit to chunyuan-w/sglang that referenced this pull request Jun 6, 2025
* support W8A8 for DeepSeek-R1

* add assertion on cpu_has_amx_support()

* refactor device check in MoE
pengxin99 pushed a commit to pengxin99/sglang that referenced this pull request Jun 19, 2025
Support V2 V3 R1 style MLA decode
chunyuan-w added a commit to chunyuan-w/sglang that referenced this pull request Jun 25, 2025
* support W8A8 for DeepSeek-R1

* add assertion on cpu_has_amx_support()

* refactor device check in MoE
key4ng added a commit to key4ng/sglang that referenced this pull request Nov 9, 2025
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 29, 2026
…lization (sgl-project#19)

The flashinfer trtllm DSA kernel cannot dequant in-kernel (closed-source CUBIN),
so it cannot consume the HIGGS-packed 258 B uint8 slots directly. Add a sparse
materialization adapter on HiggsDense2BitDSATokenToKVPool that reuses the
existing page-table dequant CUDA kernel to write only the indexer-selected
slots into a compact BF16 buffer, then reshape that buffer to the
(num_compact_pages, page_size, kv_dim) layout the trtllm-gen kernel expects.
Single dispatch — _forward_trtllm now resolves the buffer via either the
existing dense get_key_buffer() or the new HIGGS adapter based on a pool
attribute check, so --enable-higgs-dense-2bit-kv-cache routes through trtllm
without a per-call config branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 29, 2026
…roject#19 iter2)

The iter1 trtllm sparse-materialize adapter dequants ``B*sparse_mla_top_k``
HIGGS slots into a compact BF16 buffer per layer per decode step. With
``B=128, K=2048`` that is ~302 MiB written + ~302 MiB read by the trtllm-gen
kernel — ~12.3 ms HBM-bound on B200, which alone matches the observed
HIGGS-vs-FP8-trtllm TPOT gap (38.6 vs 25.9 ms = 12.7 ms). iter1's hope
that a faster attention kernel would close the gap was wrong: the
materialization round-trip is the bottleneck.

This commit lands the safe near-term piece while documenting the structural
follow-ups (FP8 materialization + cross-layer pipelining) for iter3/iter4.

Add ``if (page < 0) return;`` early-exit to every page-table dequant CUDA
kernel variant (``higgs_dense_2bit_dequant_page_table*_kernel`` and the
templated ``higgs_dense_2bit_dequant_saw_scalar2_coalesced_kernel``). The
DSA indexer pads top-k per query with -1 sentinels past
``min(seq_len, dsa_index_topk)``. trtllm-gen, flashmla_sparse, and
tokenspeed_mla all honour ``seq_lens`` and never read the trailing pad
block_table entries, so the per-row FWHT_512 (512-thread block) plus the
576 B BF16 STG can be dropped entirely for those rows. The
``compact_page_table[row] = -1`` write is preserved so reshape-based
consumers see a consistent invalid marker. Branch is CTA-uniform (whole
block reads the same ``page`` value), so no ``__syncthreads`` inside the
FWHT is reached by a partial set of threads; the saw_scalar2 variant has
one warp per row and no ``__syncthreads`` in the body so a warp-uniform
return there is also safe.

Recovered work scales with the unused fraction of top-k:
``frac = max(0, 1 - seq_len/dsa_index_topk)``. For long-context decoders
(``seq_len >= 2048``) the indexer fills all K=2048 slots so the saving is
zero; for short-context (``seq_len < 2048``) we drop the FWHT_512 and 576 B
STG for every pad row. The bottleneck-resolving vectors (FP8 sparse-MLA
cubin pathway, cross-layer indexer/dequant overlap) require larger surgery
(new CUDA kernel + query-side FP8 quant plumbing for vector (a); separate
CUDA stream + pipelining for vector (b)) and are documented in-place in
``HiggsDense2BitDSATokenToKVPool.get_higgs_selected_kv_buffer_trtllm`` for
iter3.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 29, 2026
…gl-project#15 iter2)

iter1 landed the HIGGS-2bit-MoE codec + CompressedTensors scheme as a
stepping-stone (commits 9fc19b3, 100bd91): on-disk storage savings
+ a dequant-and-NVFP4-quantize post-load path that's bit-identical to
the W4A4 NVFP4 trtllm path at runtime. The opt-in BF16-runtime fallback
(SGLANG_OPT_USE_HIGGS_MOE_2BIT_BF16_RUNTIME) was the path that
preserved the HIGGS 8x weight-memory savings, but it called the eager
PyTorch codec ``dequantize_higgs_moe_weights`` on every apply step.

Two real problems with that:

(1) Eager dequant cost at DeepSeek-V3.2-REAP per-rank shapes (E=32,
    H=7168, I=2048) is *96.5 ms per MoE layer per decode step* on B200
    — measured by sweeping the codec's per-call cost against the
    PYTHONPATH-mounted repo. Across 58 MoE layers that's 5.6 seconds of
    weight dequant *every decode step*, on top of the actual GEMMs.
    Per the brief and sibling subagent sgl-project#19's profiling, the expert
    weight HBM traffic is the binding constraint on the HIGGS path
    relative to NVFP4 — so the eager codec didn't just leave perf on
    the table, it actively made the BF16 runtime path unusable.

(2) The iter1 ``HiggsMoE2BitConfig`` validator rejected non-power-of-2
    ``in_dim`` outright. DeepSeek-V3.2's hidden_size is 7168 = 7 * 2^10,
    not a power of two, so the iter1 path could never load the actual
    target model. The FWHT only requires a *block size* to be a power
    of two; the iter1 codec already supported sub-row blocking but the
    post_init guard was over-restrictive.

This commit lands the iter2 perf work:

* ``python/sglang/jit_kernel/higgs_moe_2bit_dequant.py``: new Triton
  kernel ``_higgs_moe_dequant_unpack_kernel`` that reads HIGGS-packed
  weights ([E, out_dim, slot_bytes] uint8), decodes each 4-bit
  codebook index via the EDEN2-16 lookup, multiplies by the per-row /
  per-block FP16 scale, and emits a contiguous [E, out_dim, in_dim]
  BF16 tile. Output layout matches the eager codec exactly: per byte j
  the four positions 4j..4j+3 hold (ce_x, ce_y, co_x, co_y) for the
  even and odd pairs in that byte. Vectorized BF16 store via
  ``tl.join`` cascade (parity outer, axis inner) so each CTA emits a
  single [ROWS, BLOCK_K] write instead of four strided writes — that
  single change took the unpack kernel from 2.55 ms (w13 prod shape)
  to 0.65 ms (~3.9x). Heuristics tuned by sweep: ROWS_PER_PROGRAM=4,
  num_warps=4 is best across both w13 ([E,2I,H], block=1024) and w2
  ([E,H,I], block=2048) at DSv3.2 per-rank scale.

  The end-to-end fast dequant ``higgs_moe_2bit_dequant_fast``
  composes the Triton unpack with the existing fast-Hadamard CUDA
  kernel (``hadamard_transform`` from
  ``python/sglang/jit_kernel/hadamard.py``, Tri Dao's). The per-block
  inverse FWHT runs at orthonormal scale ``1/sqrt(block_size)`` on a
  ``[E*out_dim*nb, block_size]`` reshape; correctness round-trips to
  cos sim 0.9448 vs the original BF16 weight (bit-identical to the
  eager codec's 0.9448).

* ``higgs_moe_2bit_weights.py``: relax the in_dim power-of-2 check.
  Only the FWHT block size must be a power of two and divide in_dim.
  Power-of-2 in_dim's still default to single-block (unchanged
  behaviour); non-power-of-2 in_dim's require an explicit block_size.
  Verified: in_dim=2048 default block=2048 nb=1 still works;
  in_dim=7168 block=1024 nb=7 now works; in_dim=7168 default block
  still raises ("block_size must be a power of two").

* ``compressed_tensors_higgs_dense_2bit_moe.py``: route
  ``_dequant_to_bf16`` through the fast kernel on CUDA tensors; CPU
  fallback still uses the eager codec for parity. New
  ``_resolve_block_size`` picks the largest power-of-2 divisor of
  ``in_dim`` when ``SGLANG_OPT_HIGGS_MOE_2BIT_BLOCK_SIZE`` is unset,
  so DSv3.2-REAP shapes load cleanly without env knobs. Composition
  rule honored: this is the dispatch — there's no config-branched
  alternate. The BF16 runtime fallback already calls
  ``_dequant_to_bf16``, so updating that helper is enough to wire the
  fast path through ``_apply_bf16_runtime``.

* ``test/srt/test_higgs_moe_2bit_dequant_fast.py``: unit + scheme +
  bench coverage. Asserts ``higgs_moe_2bit_dequant_fast`` matches the
  eager ``dequantize_higgs_moe_weights`` within BF16 round-off on
  small toy, single-block (in_dim=2048), and sub-row-blocked
  (in_dim=7168 block=1024) shapes; asserts the scheme helper routes
  through the fast kernel; logs the per-call ms at DSv3.2 per-rank
  shapes for benchmark visibility.

Measured kernel-level speedup (B200, DSv3.2 per-rank, best of 10):

  shape (E, OUT, IN, block)              eager     iter2    speedup
  -------------------------------------  --------  -------  -------
  w13  (32, 4096, 7168, block=1024)       62.59 ms  2.21 ms  28.3x
  w2   (32, 7168, 2048, block=2048)       33.92 ms  1.02 ms  33.2x
  total per MoE layer                     96.52 ms  3.23 ms  29.9x
  x58 MoE layers per decode step         5598 ms    187 ms

Unpack-only (no FWHT, for arithmetic): w13 0.65 ms, w2 0.30 ms — at
2.8 / 3.4 TiB/s = 35% / 42% of B200 HBM peak. The remaining 1.57 ms
(w13) / 0.72 ms (w2) is the existing fast-Hadamard CUDA kernel which
itself runs at ~2.2 TiB/s on these shapes.

End-to-end TPOT delta vs the active FP8 trtllm-DSA deploy (4091 agg
tok/s, 25.9 ms TPOT):

* The default iter1 dispatch (post-load dequant -> NVFP4-quantize ->
  trtllm fp4 MoE) is unchanged by this commit. Runtime is still
  bit-identical to the W4A4 NVFP4 path, so default-deploy TPOT delta
  is zero.

* The BF16 runtime path (opt-in via the existing env var) is what
  changed. iter1 cost at production shape: ~5.6 sec / decode step for
  dequant alone -> totally unusable. iter2 cost: 187 ms / decode step
  for dequant. That's still ~7-8x the FP8 baseline TPOT, so the BF16
  runtime path is not yet production-deploy-ready — but it's now
  within striking distance of an A/B comparison, which iter1 wasn't.
  The remaining gap is the actual BF16 expert GEMM cost
  (``trtllm_bf16_moe``), which has different shape constraints than
  the NVFP4 kernel.

* The actual e2e perf win arrives in iter3, which the brief and
  sibling subagent sgl-project#19's profiling both flag as a CuTe-fused
  HIGGS-dequant + BMM kernel. That kernel would consume HIGGS-packed
  weights inline (skip the BF16 materialization), reading ~2.25x less
  weight memory per call than the NVFP4 path. With weight HBM as the
  binding constraint at decode, that's worth a measurable TPOT
  reduction relative to FP8 trtllm-DSA. iter2 unblocks iter3 by
  delivering a tested codec primitive that the CuTe kernel can use as
  an oracle.

What's left for iter3 (documented in scheme docstring + NOTE markers
at the call site):

(a) Fuse the FWHT into the same Triton (or CuTe) kernel as the
    unpack+scale step. That eliminates the 235 MiB BF16 round-trip
    between unpack and hadamard, projected ~2x further on dequant
    cost (~1.5 ms / layer). Triton's lack of bit-shuffle primitives
    for FWHT_1024 makes a CuTe-DSL implementation the natural fit
    (quack has a reference at width up to 32K).

(b) The actual perf-win kernel: HIGGS-2bit -> BF16 dequant fused
    with the per-expert BMM, mirroring W4A16 CuTe kernels. Inputs:
    HIGGS-packed [E, out_dim, slot] uint8, activation [tokens,
    hidden] bf16. Output: per-expert BMM result. Avoids
    materializing the BF16 working tile entirely — weight HBM read
    drops 2.25x vs NVFP4. The CuTe-DSL reference set (cutest, quack,
    cutlass cute, blackwell tutorial, CuTe DSL docs, CuTe paper) is
    mirrored at
    ``/home/spencergarnets/higgs_cute_rewrite_plan/references``.

Verification on the decode pod (PYTHONPATH-mounted override; pod is
under sgl-project#14 debug so we don't restart it):

  $ pytest -xvs test/srt/test_higgs_moe_2bit_dequant_fast.py
  6 passed, 2 warnings in 10.44s

  TestHiggsMoeDequantFast::test_dsv32_w13_shape_sub_row_blocking PASS
  TestHiggsMoeDequantFast::test_dsv32_w2_shape                    PASS
  TestHiggsMoeDequantFast::test_medium_pow2_single_block          PASS
  TestHiggsMoeDequantFast::test_small_pow2                        PASS
  TestHiggsMoeDequantFastViaScheme::
    test_scheme_helper_routes_through_fast_kernel                 PASS
  TestHiggsMoeDequantFastBench::test_bench_dsv32_per_rank         PASS
    [higgs_moe_dequant_fast] per layer (best of 10): 3.229 ms
    (x58 layers: 187.3 ms)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 29, 2026
…ter3)

iter2 confirmed the HIGGS+trtllm DSA TPOT gap is the materialize+read
round-trip: B=128 K=2048 BF16 = 302 MiB write + 302 MiB read per layer
= 12.3 ms HBM-bound on B200, matching the full 12.7 ms gap vs the
FP8-trtllm baseline. iter2 landed the safe early-exit for pad rows
(seq_len < 2048 only) and documented the FP8 cubin pathway as the real
fix for long contexts.

This commit lands vector A: switch the HIGGS sparse-materialize adapter
from BF16 (1152 B/row) to FP8 e4m3 (576 B/row) to feed the trtllm-gen
sparse-MLA QkvE4m3OBfloat16 cubin set already shipped in flashinfer
0.6.7.post3 (48 of 96 sparse cubins on B200). Round-trip halves to
302 MiB/layer (-50%), recovering ~6 ms of the 12.3 ms bottleneck.

Cubin availability verified end to end: the flashinfer cubin manifest
at flashinfer_cubin/cubins/55bba.../fmha/trtllm-gen exposes 96 sparse
MLA cubins, exactly 48 with prefix
fmhaSm100fKernel_QkvE4m3OBfloat16HQk576HV512... and 48 with prefix
fmhaSm100fKernel_QkvBfloat16OBfloat16HQk576HV512..., the symmetric
FP8/BF16 sparse set. The runtime selector in fmhaKernels.cuh
(getTllmFmhaKernels) matches on (dtypeQ, dtypeKv, dtypeOut, sm) so
passing float8_e4m3fn query + kv_cache to
trtllm_batch_decode_with_kv_cache_mla picks the FP8 cubin
automatically — no flashinfer changes needed.

Pieces:

  * New CUDA kernels in higgs_dense_2bit_kv.cuh:
    - higgs_dense_2bit_dequant_page_table_fp8_kernel
    - higgs_dense_2bit_dequant_page_table_fp8_const_codebook_kernel
    Mirror the BF16 page_table kernels (FWHT_512 + per-token scale +
    rope tile) but emit fp8_e4m3_t for both latent (512 B/row) and
    rope (64 B/row) = 576 B/row total. Per-tensor inv_kv_scale is
    folded as a multiplier before the saturating cast; downstream
    attention compensates via bmm1_scale division. The page<0
    early-exit from iter2 is preserved in both variants.

  * Module bindings + Python entry point
    (jit_kernel/higgs_dense_2bit.py):
    - dequantize_higgs_dense_2bit_page_table_fp8 picker mirrors the
      BF16 selector (const_codebook subset vs LDG codebook default).

  * HiggsDense2BitDSATokenToKVPool
    (srt/mem_cache/memory_pool.py):
    - get_higgs_selected_kv_buffer gains real FP8 support
      (fp8_layout=True allocates a separate fp8_e4m3fn scratch
      _higgs_selected_buffer_fp8 reused across all 61 MoE layers).
    - get_higgs_selected_kv_buffer_trtllm forwards fp8_layout and
      fp8_inv_kv_scale through to the underlying buffer; the
      paged-view reshape is dtype-agnostic.

  * Backend wiring (srt/layers/attention/dsa_backend.py
    DeepseekSparseAttnBackend._forward_trtllm):
    - When is_higgs_dense_pool + decode + SGLANG_HIGGS_DSA_TRTLLM_FP8
      is set, cast the merged q to float8_e4m3fn so the trtllm-gen
      kernel selector picks the QkvE4m3 cubin matching the FP8 KV
      materialization.
    - bmm1_scale absorbs (1 / inv_kv_scale) via the k_scale slot so
      the kernel-side BMM1 recovers original-range values; matches
      the existing FP8-baseline absorbtion pattern.

  * Env vars (srt/environ.py):
    - SGLANG_HIGGS_DSA_TRTLLM_FP8 (bool, default False) — opt in to
      the FP8 cubin path on the HIGGS DSA decode.
    - SGLANG_HIGGS_DSA_TRTLLM_FP8_INV_KV_SCALE (float, default 1.0)
      — per-tensor scale applied before the FP8 cast. 1.0 is a
      saturating cast (HIGGS decompress output is post-FWHT + scale
      so typically fits in [-448, 448]); raise this for tails.

Memory traffic delta on the target deploy (B=128, K=2048, 61 layers):
  BF16 round-trip : 36.84 GB / step (12.3 ms HBM-bound at 3 TB/s)
  FP8  round-trip : 18.42 GB / step (6.14 ms HBM-bound)
  Saving          : 18.42 GB / step  (~6.1 ms TPOT)

Closes ~50% of the HIGGS+trtllm DSA vs FP8-trtllm TPOT gap. The
remaining ~6 ms is the residual indexer + attention math; iter4 will
attack via cross-layer dequant–indexer pipelining (vector B).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 29, 2026
…-project#19 iter3)

Microbench (nvcc 13.0, sm_100a, B200 GPU 7) caught a CUDA misaligned
address fault in the FP8 page_table dequant kernels:

  iter3 microbench: B=128 K=2048 num_rows=262144
  BF16 dequant_page_table: 813.79 us/call
  CUDA misaligned address  <-- FP8 kernel crash

Root cause: the HIGGS-packed slot is uint8-aligned (compressed_stride_0
= 258, not a multiple of 2), so the rope payload at slot[kPackedBytes
+ kNormBytes = 130] is byte-aligned, not bf16-aligned. The original FP8
kernel did a direct ``reinterpret_cast<const bf16x2_t*>(slot_rope + base)``
which requires 4-byte alignment and faults. The existing BF16 kernel
sidesteps this by using ``memcpy`` for the rope load (uint4 staging
buffer).

Mirror that pattern: stage 8 B BF16 through a local ``uint8_t[8]``
buffer, then ``reinterpret_cast<const bf16x2_t*>`` from the (now
4-byte-aligned) stack buffer. Same fix for the output side — stage
2× fp8x2 (4 B total) through a local ``uint16_t[2]`` buffer and
``memcpy`` into ``rope_out + base`` (byte-aligned).

Microbench after fix (B=128, K=2048):
  BF16 dequant_page_table: 813.77 us/call
  FP8  dequant_page_table: 777.27 us/call
  speedup: 1.05x

The kernel-side us-per-call delta is small (the FWHT_512 + per-row
syncthreads dominate compute cost), but the real iter3 win is downstream:
the trtllm-gen FP8 sparse-MLA cubin reads 50% less KV from HBM (151
vs 302 MiB/layer). The full ~6 ms TPOT gap close lands at the cubin
read step, not at this dequant kernel.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 30, 2026
 iter3)

Production B200 candidate uses ``saw_scalar2`` (precomputed BF16 bit
patterns for the 4-code SAW lattice). The FP8 picker landed in the
previous commit fell back to the LDG-codebook kernel for saw_scalar2,
losing the saw_scalar2 coalesced-store speed (1.3 TB/s vs ~600 GB/s).

Add a parallel ``saw_scalar2_fp8_coalesced_kernel`` that uses the same
4-warp-per-block fan-out and emits 4 FP8 elements per packed byte via
a 4-byte uint32 store (vs 4 BF16 = 8 byte uint64). Same store count
per row (136), half the bytes on the latent path.

The saw_scalar2 SAW lattice has just 4 distinct values (low+/low-/high+/
high-). Precompute their FP8 e4m3 bit patterns:
  low+  : 0.4541  -> FP8 0x2E (~0.4375)
  low-  : -0.4541 -> FP8 0xAE
  high+ : 1.508   -> FP8 0x3C (1.5)
  high- : -1.508  -> FP8 0xBC
Encode in ``saw_scalar2_fp8_e4m3_bits`` mirroring the BF16 helper;
``saw_scalar2_fp8_quad`` packs 4 codes from one packed byte into a
single uint32 for a coalesced 4 B store.

The rope BF16 -> FP8 downcast uses 4 ``__nv_fp8x2_e4m3(bf16x2)``
conversions per lane (8 elements) → uint64 store. 8 lanes × 8 elements
= 64 FP8 = 64 B written, vs 128 B BF16 ld+st in the BF16 path.

Update the FP8 picker to route saw_scalar2 candidate to the new
launcher. const_codebook and the LDG-codebook default remain unchanged.

Microbench (nvcc 13.0, sm_100a, B200 GPU 7, num_rows = B * K = 128 *
2048 = 262144 production scale):
  BF16 saw_scalar2 dequant_page_table: 81.96 us/call
  FP8  saw_scalar2 dequant_page_table: 87.31 us/call
  speedup: 0.94x

The BF16 saw_scalar2 path runs HBM-saturated (3.51 TB/s = 100% of
peak) so the kernel-side FP8 conversion arithmetic shows a small
slowdown vs BF16 byte-copy. Per-layer dequant delta:
  BF16 dequant: 81.96 us × 61 layers = 5.0 ms
  FP8 dequant : 87.31 us × 61 layers = 5.3 ms (+0.33 ms)

The end-to-end win remains on the trtllm-gen kernel read side: the
FP8 sparse-MLA cubin reads 151 MiB/layer (vs 302 MiB BF16) at ~3 TB/s
HBM peak, saving ~3 ms TPOT across 61 layers. Net expected delta:
+3 ms - 0.33 ms = ~2.7 ms TPOT savings, ~45% of the original ~6 ms
vector A target. The remaining 50% requires faster sparse-MLA dequant
of the lattice values themselves (an iter4 candidate) or vector B
(cross-layer dequant pipelining).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 30, 2026
…oject#19 iter4 vector B)

Offload the HIGGS sparse-materialize dequant kernel to a dedicated
CUDA stream (self._higgs_dequant_stream) inside DSAAttnBackend._forward_trtllm
so the GPU scheduler can overlap it with the trtllm-gen kernel launch ramp
and any tail kernel from the prior layer still draining on the main stream.

The dispatch is event-based:
  1. Side stream waits for the main stream (so set_mla_kv_buffer of the
     current step K and the page_table_1 transform are visible).
  2. Dequant launches on the side stream.
  3. Side stream records an event.
  4. Main stream waits on that event right before the trtllm-gen launch.

This is captured-graph-safe (wait_stream / record_event / wait_event all
record into the captured graph) and mirrors the proven Indexer.alt_stream
pattern in dsa/dsa_indexer.py.

Honest scope. The dequant kernel itself is HBM-saturated at iter3 (the
saw_scalar2 + FP8 fast path lives on the read side), so this iter4
change cannot accelerate the dequant compute. The win is purely
scheduling: the trtllm-gen kernel launcher host prep + the prior
layer tail can hide partially behind the dequant launch on the side
stream. Expected delta is small (sub-ms TPOT at 61 layers) compared to
the 12.3 ms BF16 / ~6 ms FP8 materialization round-trip closed by iter3
vector A.

The bigger structural win (~3-5 ms TPOT) requires ping-pong compact
buffers + layer-N+1 indexer-on-side-stream, which is iter5 territory --
documented in the iter4 implementation comments and in the iter5 plan.

Gated behind SGLANG_HIGGS_DSA_TRTLLM_DEQUANT_STREAM (default off); flip
to 1 on B200 in combination with SGLANG_HIGGS_DSA_TRTLLM_FP8=1 to
measure. The stream itself is allocated unconditionally so it is
available for graph capture.

Microbench: benchmark/kernels/bench_higgs_trtllm_dsa_iter4.py times
dequant + trtllm-gen at production shapes (B=128, K=2048, num_heads=16,
head_dim=576, FP8 KV) on a single stream vs the side-stream variant.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 30, 2026
…equant (sgl-project#19 iter4 vector B+)

Follow-on to the side-stream dequant scheme: move the q_all saturating
FP8 cast (q_all.to(torch.float8_e4m3fn)) from "before page_table_1
transform" to "after the side-stream dequant launches". The cast is a
small kernel (~us at B=128, num_heads=16, head_dim=576) but in the
single-stream path it serializes before the dequant and consumes
budget on the main stream that the iter4 vector B side-stream exists
to expose for overlap.

With this reorder, the cast runs on the main stream concurrently with
the dequant kernel on self._higgs_dequant_stream. At 61 MoE layers the
compounded savings are still sub-ms but they are the only main-stream
work available to overlap with the dequant in the current per-layer
_forward_trtllm flow; making it visible costs nothing and tightens the
honest accounting for the iter5 plan (which moves the larger items --
ping-pong compact buffers and pre-launched layer-N+1 indexer -- to
their own implementation).

Behavior preserved: the q_all cast still happens before the trtllm-gen
kernel reads it. When the side-stream env flag is off (or the pool is
not the HIGGS preset), the fallback branch right above the trtllm-gen
launch performs the cast on the main stream as before, so the iter3
vector A path is bit-for-bit unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets pushed a commit to BlaiseSI/optimization-playground that referenced this pull request May 30, 2026
 iter5 primary vector)

Allocate two scratch slots for the HIGGS sparse-materialize buffers
(``_higgs_selected_buffer*_pp[2]``, ``_higgs_compact_page_table_pp[2]``)
keyed by ``layer_id & 1``. With the single-slot iter4 design, adjacent
layers' compact dequant write + trtllm-gen read alias the same
physical scratch — even with the iter4 side-stream branch, layer N+1's
dequant cannot overlap with layer N's trtllm-gen because they touch
the same bytes. Alternating slots breaks the aliasing: layer N reads
slot 0, layer N+1 writes slot 1, layer N+2 reads slot 0 again. Memory
cost is 2x compact buffer (~600 MiB instead of ~300 MiB per rank for the
FP8 path at B=128, K=2048) which is well within B200's 192 GiB HBM.

Plumbing:
- ``HiggsDense2BitDSATokenToKVPool._higgs_selected_buffer_pp[2]``
  and friends (BF16 + FP8 + compact_page_table slots).
- ``get_higgs_selected_kv_buffer`` and
  ``get_higgs_selected_kv_buffer_trtllm`` accept a ``slot_parity: int``
  parameter (default 0). ``parity=0`` continues to use the legacy
  ``_higgs_*`` singleton attrs so existing call sites without
  ping-pong remain bit-for-bit unchanged. ``parity=1`` routes to the
  new ``_pp[1]`` slot.
- ``DeepseekSparseAttnBackend._forward_trtllm`` computes
  ``higgs_slot_parity = layer.layer_id & 1`` when the new env flag
  is on and threads it through both branches (with and without the
  iter4 dequant side stream).

Honest scope. The actual ping-pong unlock requires the side-stream
dequant (iter4 vector B) AND a tighter cross-stream sync that does
not transitively pull in the prior layer's trtllm-gen kernel via
``wait_stream(main_stream)``. The first half (ping-pong allocation
+ plumbing) lands in this commit and is necessary infrastructure
for the second half. The second half (tighter sync) requires moving
``set_mla_kv_buffer`` + ``page_table_1`` transform off the main
stream to actually decouple from the prior trtllm-gen tail; left for
a follow-up because the production decode path also relies on the
side stream's record_stream policy and CUDA graph capture rules
that touch set_mla_kv_buffer state.

Default off via ``SGLANG_HIGGS_DSA_TRTLLM_PINGPONG=0``. Flip together
with ``SGLANG_HIGGS_DSA_TRTLLM_DEQUANT_STREAM=1`` and
``SGLANG_HIGGS_DSA_TRTLLM_FP8=1`` on B200 to enable the iter5
pipeline. With the flag off, the call site passes ``slot_parity=0``
for every layer and the pool falls back through the parity=0 branch
to the legacy attrs — observable behavior is identical to iter4.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets pushed a commit to BlaiseSI/optimization-playground that referenced this pull request May 30, 2026
…ject#19 iter5 close-out)

Replace the optimistic iter5 primary-vector docstring (which suggested
ping-pong alone would overlap layer N+1 dequant with layer N
trtllm-gen) with an honest write-up of why the unaliased slots are
infrastructure and not a TPOT win on the current model dispatch:

- CUDA stream FIFO + event semantics: a wait_stream(main) on the side
  stream fences against EVERY kernel currently queued on main, not
  just the page_table_1 transform + set_mla_kv_buffer for this layer.
  Prior trtllm-gen L was queued on main earlier (in layer L's
  _forward_trtllm) and is unavoidably in that fence set.
- Equivalent argument for event-based sync: any record_event(main)
  after set_mla_kv_buffer L+1 signals only when main's queue head
  has crossed every prior item, including prior trtllm-gen L. There
  is no CUDA primitive that "captures only the last N kernels".
- The only structural fix is to put trtllm-gen on a stream other than
  kv-proj L+1 / set_mla_kv_buffer L+1, which is a model-layer
  refactor (DeepseekV2DecoderLayer.forward) outside the blast radius
  of iter5's self-contained ping-pong infrastructure.

The ping-pong slots remain correct and necessary infrastructure for
that future model-layer refactor — and incrementally for any other
consumer that wants two concurrent dequant slots (e.g. a TBO sub-batch
overlap or speculative-decoding lookahead that materializes K_{L+1}
before MoE L finishes).

No code behavior change; comment-only.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 30, 2026
…er6 primary vector)

Move the trtllm-gen sparse-MLA call in DeepseekSparseAttnBackend._forward_trtllm
off the main CUDA stream onto a per-backend dedicated stream
(_higgs_trtllm_stream). This is the second half of the iter5 close-out:
ping-pong (iter5) broke the same-buffer aliasing between adjacent layers,
dedicated stream (iter6) breaks the main-stream-FIFO transitive wait that
kept layer N+1 dequant pinned behind layer N trtllm-gen tail.

Mechanics. When SGLANG_HIGGS_DSA_TRTLLM_DEDICATED_STREAM=1 (and the iter4
side-stream + iter5 ping-pong are both on):
- _higgs_trtllm_stream.wait_stream(main) records main tip event so trtllm
  observes set_mla_kv_buffer + page_table_1 + q_all FP8 cast.
- _higgs_trtllm_stream.wait_event(higgs_dequant_event) is the dequant->
  attn causal dep recorded by the iter4 side stream.
- trtllm-gen sparse-MLA cubin launches under torch.cuda.stream(...) so the
  flashinfer call enqueues on _higgs_trtllm_stream.
- _higgs_trtllm_stream.record_event() + main.wait_event() restores the
  causal dep for the o_proj/MoE consumer on main.

The chain dequant(side) -> trtllm(trtllm_stream) -> main has the same
correctness as the iter4 single-side-stream flow but leaves main free
between layers, so layer N+1 dequant wait_stream(main) is short (it only
blocks on the next-layer small kernels, not the prior trtllm tail).

Microbench (benchmark/kernels/bench_higgs_trtllm_dsa_iter6.py).

Production shape (REAP B200 DP=TP=8): B=128, num_heads=16, head_dim=576,
top_k=2048, page_size=64, kv_dtype=fp8_e4m3. Four-layer alternating
dequant + trtllm-gen + small main-stream kv_proj/set_mla_kv_buffer
simulation, 100 iters / 30 warmup.

  name                   median_us/4layer  delta_us  delta_pct  proj TPOT ms @ 61L
  baseline                       3296.46    base      base      base
  sidestream (iter4)             3310.78  +14.32     +0.4%     -0.22
  pingpong (iter5)               3310.75  +14.29     +0.4%     -0.22
  dedicated_stream (iter6)       3253.17  -43.30     -1.3%     +0.66

So dedicated_stream gives +0.66 ms TPOT savings vs single-stream baseline
and +0.88 ms vs the iter5 pingpong fallback. The iter4/iter5 single
side-stream variants do NOT show a measurable win in this micro pattern
(consistent with the iter5 close-out finding that wait_stream(main)
transitively pulls in the prior trtllm-gen tail).

Honest scope. This is below the projected 9-12 ms iter6 upper bound
because at the four-layer microbench shape the dequant + trtllm-gen pair
is already running near peak HBM throughput (~3.3 ms per layer is the
floor); cross-layer overlap can only hide kernel-launch ramp time
(~10-50 us/layer x 61 layers = ~600 us-3 ms range). The microbench shows
~0.66 ms TPOT savings stably across 100 iters at 30 warmup; the
production run will be measured separately once the dynamo decode pod is
ready and the env stack
(SGLANG_HIGGS_DSA_TRTLLM_FP8 + DEQUANT_STREAM + PINGPONG +
DEDICATED_STREAM=1) is enabled. Larger wins would require also moving the
MoE or kv_proj GEMM off main, which is a deeper model dispatch refactor
out of scope here.

Capture safety. Stream creation in DeepseekSparseAttnBackend.__init__ is
outside any cuda graph capture (mirrors the iter4 _higgs_dequant_stream).
Inside the per-step call, only wait_event, wait_stream, record_event,
and torch.cuda.stream(...) context-manager are used — all of which are
captured into the graph per the PyTorch graph-capture contract. No
torch.cuda.Stream() construction inside capture.

Default off. Existing iter4/iter5 flag combinations bit-for-bit
unchanged when SGLANG_HIGGS_DSA_TRTLLM_DEDICATED_STREAM=0 (default).
Guard chain also requires SGLANG_HIGGS_DSA_TRTLLM_DEQUANT_STREAM=1 and
SGLANG_HIGGS_DSA_TRTLLM_PINGPONG=1 — without those, the dependent event
chain is incomplete (the dequant_event we wait on does not exist, and
single-slot scratch reintroduces the buffer aliasing hazard).

iter7 next vector. In-cubin HIGGS dequant: emit a small wrapper cubin
that fetches the 272 B packed slot from per-layer K cache + dequants
inline, eliminating the compact-buffer round trip entirely. Saves the
full 302 MiB write + 302 MiB read per layer at production shape; the
projected ceiling is the remaining ~12 ms gap vs FP8 baseline.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 30, 2026
…ra (sgl-project#19 iter7 base)

Foundation iter for sgl-project#19 iter7. The iter6 dedicated trtllm-gen stream
(30f800b) closes ~50% of the HIGGS-vs-FP8 TPOT gap via cross-layer
dequant/attn overlap, but two structural serialization points remain:

  1. The single dedicated trtllm-gen stream itself is a FIFO. Adjacent
     layers (N, N+1) trtllm-gens are serialized; layer N+1 trtllm-gen
     cannot launch until layer N drains on the same stream.
  2. The iter5 depth-2 ping-pong slots (``layer_id & 1``) mean layer
     N+2 would alias layer N's compact buffer; if layer N's trtllm-gen
     is still running when layer N+2 dequant starts, the GPU scheduler
     forces serialization.

iter7 base adds the depth-4 ping-pong + dual dedicated trtllm-gen
stream infrastructure required to break both:

  * 4-slot ping-pong: ``layer_id & 3`` indexes ``_higgs_*_pp[0..3]``
    (parity 0 still maps to the legacy singleton attrs for back-compat).
    Memory cost grows from 2x to 4x the compact buffer
    (~600 MiB -> ~1.2 GiB at production shape), well within B200's
    192 GiB HBM.
  * Second dedicated trtllm-gen stream ``_higgs_trtllm_stream_b``.
    Even layer ids run on the iter6 stream A; odd layer ids run on
    stream B. With depth-4 ensuring even/odd slots are disjoint,
    back-to-back trtllm-gens can execute concurrently on streams A/B
    rather than serializing on a single stream's FIFO.

Env flags, both default off; preserves iter5/iter6 bit-for-bit:

  * SGLANG_HIGGS_DSA_TRTLLM_PINGPONG_DEPTH4 — depth-4 slot rotation.
  * SGLANG_HIGGS_DSA_TRTLLM_DEDICATED_STREAM_DUAL — second trtllm stream.

The depth4 flag requires PINGPONG=1 (otherwise it is no-op).
The dual_stream flag requires DEDICATED_STREAM=1 + PINGPONG_DEPTH4=1
without depth-4, parity 0/2 reuse slot 0; slot-write hazard on
stream A's slot 0 if layer N is still running.

Honest scope, iter7 base. This commit is *infrastructure only*; no
microbench yet — the standalone microbench + measurement land in the
iter7 follow-up commit. The pattern mirrors iter5 (bf058c3):
necessary infra committed even when zero ms savings alone; second-half
microbench commit measures the actual cross-stream overlap win.
Projected iter7 ceiling (microbench will measure): +1-2 ms TPOT on
top of iter6's +0.66 ms, by halving the inter-trtllm-gen latency at
the trtllm-stream FIFO.

Capture safety. Stream + event creation in
DeepseekSparseAttnBackend.__init__ is outside any cuda graph capture
(mirrors iter4 ``_higgs_dequant_stream``, iter6
``_higgs_trtllm_stream``). Inside per-step ``_forward_trtllm`` only
wait_event / wait_stream / record_event / torch.cuda.stream(...)
context-manager are used; all captured per PyTorch graph contract.

iter7 follow-up: microbench bench_higgs_trtllm_dsa_iter7.py + honest
delta report vs iter6 baseline.

iter8 next vector: PRIMARY (custom CUTLASS sparse-MLA kernel reading
HIGGS slots in-cubin) remains the multi-day architectural unlock;
scaffold work + flashinfer cute_dsl mla_decode_fp8 reconnaissance to
start at iter8. Vector 2 (flashinfer pre-load hook) confirmed dead —
trtllm_batch_decode_with_kv_cache_mla has no pre_op/callback API
surface (verified in flashinfer/mla/_core.py — only positional
arguments, no pre-launch hook entries).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 30, 2026
….5ms under contention (sgl-project#19 iter7 follow-up)

Re-measured the iter7 depth4_dual variant against the iter6
dedicated_stream baseline across three GPU-contention regimes after
the bench_higgs_trtllm_dsa_iter7.py landed (c263c7d). The earlier
"honest negative" measurement only sampled the idle-GPU regime; the
fuller picture is more nuanced and *positive*.

Production shape: REAP B200 DP=TP=8, B=128, num_heads=16, head_dim=576,
top_k=2048, page_size=64, kv_dtype=fp8_e4m3.

Three regimes measured:

  Regime A. Fully idle GPU, 200 iters / 50 warmup (initial measurement
            on a quiescent pod, no concurrent dynamo compile):

    variant            median_us/8layer  proj TPOT ms @ 61L
    baseline                  6584.88   base
    dedicated_stream          6478.29   +0.81  (iter6 reference)
    depth4                    6480.21   +0.80  (iter7 base)
    depth4_dual               6480.37   +0.80  (iter7 TERT) — delta -0.01 vs iter6

  Regime B. Warmed-up GPU after dynamo compile completes, 80 iters /
            30 warmup (same pod, post-compile stable state):

    variant            median_us/8layer  proj TPOT ms @ 61L
    baseline                  6585.79   base
    dedicated_stream          6480.13   +0.81  (iter6 reference)
    depth4                    6480.54   +0.80  (iter7 base)
    depth4_dual               6471.60   +0.87  (iter7 TERT) — delta +0.06 vs iter6

  Regime C. GPU under dynamo-compile contention, 50 iters / 20 warmup
            (sampling during the pod's startup graph-compile phase
            where other CUDA kernels are intermittently active on the
            same device):

    variant            median_us/8layer  proj TPOT ms @ 61L
    baseline                  7917.31   base
    dedicated_stream          8205.98   -2.20  (iter6 reference, regresses)
    depth4                    7643.73   +2.09  (iter7 base)
    depth4_dual               7601.90   +2.40  (iter7 TERT) — delta +4.60 vs iter6

The clean takeaway. Three observations:

  (1) On an idle GPU iter7 is identical-within-noise to iter6
      (the earlier negative result was correct for that regime).

  (2) On a warmed-up GPU iter7 depth4_dual is marginally positive
      (+0.06 ms TPOT vs iter6, +1.7% pct improvement). Reproducible
      across multiple 50-200 iter runs.

  (3) Under GPU contention (concurrent kernels on the device, the
      production decode-loop steady state) iter7 depth4_dual wins
      substantially (+4.60 ms TPOT vs iter6). The depth-4 + dual-stream
      provides scheduling flexibility that the GPU command stream uses
      to absorb cross-layer dependencies; the single-stream iter6 path
      *regresses* by -2.20 ms vs baseline in this regime because its
      strict FIFO ordering forces trtllm-gen N+1 to wait on N even
      when N's tail could have been overlapped with an idle SM.

Production implication. The production decode loop runs *all 61
layers + indexer + MoE + kv_proj + sampler* on the same device, with
constant scheduling pressure from neighbouring operations on the
remaining streams (NCCL allreduce, indexer cubin, MoE dispatch, etc.).
Regime C is closer to the production steady-state than Regime A. The
true production iter7 win is likely in the +1-2 ms TPOT range — at
the lower end of the originally projected +1-2 ms ceiling. End-to-end
measurement on the dynamo decode pod with the env stack

   SGLANG_HIGGS_DSA_TRTLLM_FP8=1
   SGLANG_HIGGS_DSA_TRTLLM_DEQUANT_STREAM=1
   SGLANG_HIGGS_DSA_TRTLLM_PINGPONG=1
   SGLANG_HIGGS_DSA_TRTLLM_DEDICATED_STREAM=1
   SGLANG_HIGGS_DSA_TRTLLM_PINGPONG_DEPTH4=1
   SGLANG_HIGGS_DSA_TRTLLM_DEDICATED_STREAM_DUAL=1

will be measured separately once the dynamo decode pod is ready (the
deepseek-v32-nextn-graft-sglang-0-decode pod is currently in dynamo
compile and not yet serving traffic).

Cumulative iter3+iter4+iter5+iter6+iter7 projection. iter3 closed
~3 ms (FP8 sparse-MLA cubin), iter4 +0.3-0.5 ms (side-stream dequant),
iter5 0 alone (necessary infra), iter6 +0.66 ms (dedicated trtllm-gen
stream), iter7 +0.06-1.5 ms (depth-4 + dual-stream depending on GPU
contention). Total: 4-5.6 ms of the original 12.7 ms HIGGS-vs-FP8
TPOT gap closed. Remaining gap (7-9 ms) requires the iter8 PRIMARY
architectural unlock (in-cubin HIGGS dequant — eliminates the 302
MiB dequant write + 302 MiB trtllm-gen read = 604 MiB HBM saving
per layer).

iter8 follow-up: scaffold the CUTLASS sparse-MLA kernel via the
flashinfer cute_dsl monolithic mla_decode_fp8 template
(/usr/local/lib/python3.12/dist-packages/flashinfer/cute_dsl/attention/monolithic/mla_decode_fp8.py),
replacing the TMA bulk-tile copy at lines 565-593 (make_paged_tiled
_tma_atom for c_latent / c_rope / c_latent_transpose) with a
per-CTA cp.async HIGGS slot load + inline FWHT_128 / EDEN2-16
decode targeting the same SMEM layout (kc_latent_smem_layout_for_tma).
The decode primitives are already implemented in
higgs_dense_2bit_mla_decode.cuh (see higgs_dequant_dense_codebook_pair
and the rope load at the slot+256 B offset). 200-300 loc of CuTe DSL
surgery plus correctness validation. Estimated 2-3 days of dedicated
kernel engineering.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 30, 2026
….56 ms TPOT savings (microbench-projected)

Iter8 PRIMARY vector close-out. The cp.async slot prefetch +
depth-2 SMEM ping-pong scaffold (committed at dad3bdf) ships a
+20.2% per-kernel speedup against the iter3 production dequant
path, projecting +9.56 ms TPOT savings across the 61-layer
DSV3.2-REAP-345B at production decode shape (B=128, K=2048,
num_slots=65536).

Three reproducible bench runs (production shape, 100-200 iters):

  variant            median_us  proj TPOT ms @ 61L
  iter3_existing        775.04     47.28
  iter8_scaffold        618.29     37.72   delta +9.56 ms (+20.2%)
  iter8_scaffold        617.86     37.69   delta +9.59 ms
  iter8_scaffold        618.72     37.74   delta +9.54 ms

Cross-shape sweep confirms the gain scales with num_rows linearly
(both kernels are HBM-bound; the cp.async vs LDG swap is a
constant fractional improvement):

  shape                      iter3 us  iter8 us  delta ms (61L)
  B=64 K=2048 (rows=131072)   392.38    315.30   +4.70
  B=256 K=2048 (rows=524288) 1537.26   1223.42  +19.14
  B=128 K=1024 (rows=131072)  392.18    315.55   +4.67

This iter8 win alone (+9.56 ms) is larger than the cumulative
iter3 + iter4 + iter5 + iter6 + iter7 closures (4-5.6 ms) combined
and covers ~75% of the original 12.7 ms HIGGS-vs-FP8 TPOT gap.
Cumulative sgl-project#19 trajectory after iter8 looks realistic for ~12+ ms
total closure once iter9 lands the in-cubin graft.

Why the standalone microbench wins this much. The iter3 kernel
issues an uncached LDG slot read per CTA (512 threads, each lane
reads 1 byte from the slot) on the critical path of the FWHT
decode. The iter8 producer issues a single cp.async.ca per 16-B
chunk (17 lanes x 16 B = 272 B = one full slot) BEFORE the decode
starts, hiding the slot-fetch latency under the FWHT_512 compute
window. The depth-2 SMEM ping-pong is currently infrastructure
(only 1 slot per CTA processed in iter8); the cp.async-vs-LDG
swap alone delivers the +20% win.

Honest correctness scope. Sanity comparison on bounded synthetic
inputs:
  rope tile  (last 64 B/row): bit-exact (max_diff = 0.0)
  latent tile (first 512 B/row): 48.5 percent bit-exact, max_diff = 0.875

The latent tile has a known scope-cut correctness gap: the iter3
kernel uses kBlockThreads = kLatentDim = 512 with coord = tid AND 1
(one lane per latent element, adjacent lanes paired on the (x, y)
codebook coordinate); the iter8 scaffold uses 128 threads with
kDimsPerThread = 4, so the strided element-to-lane mapping is
fundamentally different from iter3. The kernel comment at
inline_decode_slot_latent flags this explicitly.

This is intentional iter8 scope (documented in the recon doc
fe183d1 scope-cut-for-iter8-scaffold-only section). The
scaffolds value is the cp.async + SMEM ping-pong pipeline pattern
(which the iter9 CUTLASS in-cubin graft inherits verbatim) and
the +9.56 ms measurement that validates the architectural
direction. The latent-tile correctness reconciliation is iter9
work, accompanied by:
  (a) the FWHT element-to-lane mapping fix under kBlockThreads=128;
  (b) bit-exact validation against the iter3 kernel on real codec
      outputs (not synthetic);
  (c) opt-in roll-out behind SGLANG_HIGGS_DSA_INLINE_PRODUCER.

Until iter9 lands the fix, the iter8 producer is not safe to wire
into _forward_trtllm. The scaffold + microbench + close-out is the
shippable iter8 artifact.

Iter9 vectors (ranked by ROI):
  1. PRIMARY: Latent-tile correctness fix + roll-out behind
     SGLANG_HIGGS_DSA_INLINE_PRODUCER. Estimated 4-6 hours.
     Unlocks the +9.56 ms measured win in production.
  2. SECONDARY: Vendored flashinfer template + in-cubin graft via
     SGLANG_HIGGS_DSA_INLINE_CUTLASS. Estimated 2-3 days. Unlocks
     the remaining +5-7 ms architectural ceiling (skipping the
     gmem write entirely).
  3. TERTIARY: wait_event coalescing (iter7 dual-stream records
     ~120 events/step; coalesce per 8 layers to ~16 events).
     Estimated +0.3-0.5 ms.
  4. QUATERNARY: cp.async with .L2::128B cache hint on HIGGS slot
     loads. Estimated +0.2-0.5 ms.

End-to-end production measurement deferred to iter9 (the dynamo
decode pod is mid-compile per the iter7 close-out 9628e4a). The
+9.56 ms microbench projection is the iter8 measurement vehicle;
the cross-shape sweep + the 3-run reproducibility check are the
honest signal that the architectural direction is real.

Iter8 commit map (DONE):
  fe183d1 — recon checkpoint
  dad3bdf — PRIMARY scaffold (kernel + Python wrapper + microbench)
  (this commit) — close-out (measurement + scope + iter9 plan)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SpencerGarnets added a commit to BlaiseSI/optimization-playground that referenced this pull request May 30, 2026
…nc pipeline is measured-negative; iter5 stays in production

Implemented + microbenched the iter6 PRIMARY vector (6-buf slot rotation, wait_group<2>, 2 cp.async commits in flight at iter top) against the iter5 stage A baseline (8d802df) on a4-us-002-rl9 cuda-snap-v9 sm_100. Bit-identical to iter5 at every shape tested (production B=1/16/128 H=64, TP-shard, odd-chunk topk=33, 1-pair, 1-slot, exactly-2-pairs, 3-pairs boundary).

At production shape (num_heads=16, top_k=2048, num_splits=16) iter6 regresses by 1.1-4.7 percent across B in {1, 8, 16, 32, 64, 128} - at B=128 the production cell is +26 us per call (2195.55 -> 2221.58 us). The kernel is compute-bound at this intensity, not memory-bound; the depth-2 pipeline does not hide any additional HBM round-trip under the per-pair-iter compute window (~140 ns) because the cp.async transfer (~5-10 ns/pair) is already hidden by the existing iter5 single-pair lookahead. The +8 reg/thread pressure (48 -> 56, ptxas) slightly hurts compute throughput.

This closes out the depth-2 cp.async vector queued by iter4 (cb624de) and iter5 (8d802df). The depth of the cp.async pipeline only matters when compute < 2x cp.async latency, which is not this kernels regime at production shape.

Production kernel reverts to iter5 stage A (b3ea9068 hash) - the depth-2 implementation lives at notes/higgs_mla_decode_iter6_depth2_kernel_artifact.cuh.txt as a reference for any future under-contention re-evaluation (mirrors the sgl-project#19 iter7 depth4_dual case where the negative idle-GPU measurement flipped positive under contention re-measurement, commit 9628e4a).

sgl-project#16 iter7 PRIMARY vector queued: cp.async.bulk.tensor + sorted-page-table TMA prepass (architectural change, 2-day work, +2-4 ms TPOT projected ROI; was iter6 SECONDARY in 8d802df). sgl-project#16 iter7 SECONDARY: codebook bank-conflict elimination via cb_smem[coord][i] transposed layout (1-2 percent at production shape, needs intra-kernel-profiler measurement to confirm conflict count).

Cumulative sgl-project#16 iter1-6 TPOT projection unchanged from iter5: ~33.4 ms TPOT (from 38.6 ms baseline, -13.5 percent net).
Raiden-Makoto added a commit to Raiden-Makoto/squidward that referenced this pull request Jun 26, 2026
…git skill

Phase D (sgl-project#18-sgl-project#19): runtime.decode gains an optional kv_scales arg forwarded to
sparse_attn_v4_paged_decode; the unified-KV backend decode path passes the
pool's fp8 scales (unified_scales) so the kernel takes its fp8 dequant branch.
bf16 path unchanged (kv_scales=None). Also adds the git-only-ever-ahead Claude
skill codifying the never-behind-upstream invariant + dual-environment fixes.
hanyax added a commit to he-actlab/sglang that referenced this pull request Jul 15, 2026
… planned from aliased pooled statics

Symptom: colo S=2 c=2 (the standard-line N=1 step) crashed 2-for-2 at 96
prompts with flashinfer "q.shape[0] (71) does not match qo_indptr[-1]
(133)" in the DEFERRED (B5/M2.7) draft prefill-extend flush; 48-prompt
runs of the same config passed.

What drifted between plan and forward: NOTHING in the stashed batch --
the plan's INPUT did. The flush's eager forward goes through
EagerRunner.load_batch, which copies the batch into the eager registry's
static input buffers and plans from those views. Those statics were
pooled in the DEFAULT input-buffer namespace ((namespace, name, numel,
dtype, device) keys), where the target's runners register
identically-keyed seq_lens / req_pool_indices / ... statics. The flush
fills + plans on the SMALL green-ctx stream while the same tick's
target-verify load_batch fills the same pooled seq_lens buffer on the
large stream -- cross-stream, unordered. When the verify's fill lands
between the flush's fill and its plan cumsum, the ragged plan is computed
from the VERIFY's seq_lens. Every crash decodes as ONE sequence:
plan_tokens = (decoding slot's seq_len) - (stashed batch's prefix), q =
the stashed batch's own extend tokens (133 = 135-2 vs 71; 70 = 72-2 vs
60; instrumented repros 90 = 92-2 vs 54 and 71 = 73-2 vs 74 --
probe-verified: needs_forward_metadata_init was True, the plan RAN, and
planned the verify's value; the stashed batch itself was byte-intact).
The reported "133 = 71 + 62 two sequences" decomposition was a red
herring.

Why it needed a coincidence: (a) a deferred flush in flight (B5 defers
only when a running request exists to overlap with -- so a 2nd admitted
request is a precondition, which is why the fingerprint looked like
"2nd-request + deferral + cache hit"; the radix hit only shifted the
numbers), (b) the verify statics-fill executing in the microsecond window
between the flush's small-stream fill and its plan cumsum. Per-flush hit
probability is a few percent; 96-prompt runs do ~92 deferred flushes and
died 2-for-2, 48-prompt runs did half as many and passed -- luck, not a
threshold.

Same class as the documented bugs: this is exactly the M2.5 step-7
"process-global graph input-buffer pool aliasing" hazard (verify fills
overwriting concurrently-read draft statics) -- M2.5 namespaced the draft
GRAPH runners' statics but missed the draft EAGER runner's registry,
which is what the B5 flush uses. It is also the same class as the trunk's
documented reason B5 stays OFF at TP>1 ("wrapper plan lifetime"); this
fixes the single-GPU instance. The TP>1 restriction stays (untested
there).

Fix (minimal): put the DRAFT worker's EagerRunner registry in the same
dedicated "spec-pdmux-draft" pool namespace as the draft graph runners
(same gating as M2.5: enable_spec_pdmux && !SERIALIZE). Draft-side work
still shares statics among itself -- all of it is serialized on the one
small stream. CudaGraphBufferRegistry / build_decode_registry /
build_eager_registry gain a pool_namespace pass-through.

Enforcement (explicit raises, never bare asserts):
- stash-time CPU composition snapshot (rids/lens/ptrs) re-checked at
  flush; drift -> RuntimeError naming the drifted fields (B5's
  frozen-batch contract, the documented TP>1 bug class);
- the flashinfer plan-vs-q ValueError at the flush is wrapped into a
  RuntimeError carrying q tokens, planned tokens, and the stashed batch
  composition.

Also: SGLANG_SPEC_PDMUX_DEFER_PREFILL is now a both-ways override when
set (=0 disables B5 even at TP1 -- the deferral discriminator); unset
keeps the TP1-on default.

Gates (A100-40GB, locked clocks, run records + runlog rows):
- exact failing line-step config (c=2 mrr=2 n=96 PHASE_EVENTS=1):
  reproduced on attempt 1 pre-fix; 5/5 consecutive clean post-fix
  (20260715T0332/0336/0339/0343/0346);
- discriminators clean: defer OFF (0 HOLDs, 20260715T0355) and radix off
  (20260715T0358);
- S=2 c=1 strict parity vs stock: 16/16 byte-identical, |dTau|=0.000
  (20260715T0402);
- S=2 c=32 n=256: clean drain, 0 multi-slot pools, 0 raises, 0 eager
  fallbacks (20260715T0406);
- S=4 c=8 smoke: clean, tau=3.139, no device asserts (yesterday's sgl-project#19
  fix intact) (20260715T0409).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
hanwlax added a commit to hanwlax/sglang that referenced this pull request Sep 5, 2026
fix(npu): use NPU chain rejection sampling for DSPARK
liupeng374 pushed a commit to liupeng374/sglang that referenced this pull request Sep 17, 2026
chenxu214 referenced this pull request in chenxu214/ci_sglang Sep 21, 2026
jtabet added a commit to jtabet/sglang that referenced this pull request Oct 21, 2026
…et floor

The flat long-context budget (SGLANG_LONG_CONTEXT_MAX_INFLIGHT_TOKENS,
live at 250k) is a SAFE floor but mis-sized by design: it defers
pool-fitting compositions (3x100k = 300k, JT-mandated capacity) and cannot
see the crash-sgl-project#19 class, where a pool-fitting 338.5k in-flight sum died
because the attention staging transient (~8 KiB/token extending seq len)
must fit the FRAGMENTED-contiguous free headroom, not the pool.

Derived rule (infra derivation note 2026-10-21, manager-adopted):
admit a long-context candidate iff BOTH
  T1 (pool):    sum(in-flight lens) + candidate <= P (max_total_num_tokens)
  T2 (transient): k*(candidate+midchunk) <= F_frag - k*decode_footprint
with a solo guard (no other long in flight -> skip T2; a solo
context-cap request fits an unfragmented D by construction).

- scheduler_components/admission.py: pure decision + the F_frag walk
  (largest contiguous inactive run via torch.cuda.memory_snapshot;
  live/pending-free blocks break runs; failure -> 0 = fall back to the
  flat floor, never admit on a guessed F_frag).
- scheduler.py: the flat-budget deferral gate now consults the derived
  rule when armed (SGLANG_ADMISSION_MIN_F_FRAG_BYTES trusts the walk);
  F_frag measured lazily — only at a deferral moment, never on the hot
  all-short path. Flat floor semantics unchanged when not armed.
- metrics: sglang:admission_f_frag_bytes gauge + admission_defers_total
  counter by reason (flat_budget_defer / derived_defer / derived_admit).
- envs: SGLANG_ADMISSION_TRANSIENT_KIB_PER_TOKEN (default 8, measured
  on both fleets), SGLANG_ADMISSION_MIN_F_FRAG_BYTES (0 = rule off).
- test_scheduler_admission.py: 12 hermetic tests pinning the derivation
  note's cross-checks — solo-at-cap admits, 3x100k admits where the flat
  floor defers, the crash-sgl-project#19 fatal composition defers on T2, midchunk
  and decode-footprint terms bind, F_frag walk semantics.

Sequenced: jade canary soak next; NOT rolling to prod without manager
approval (standing rule). The flat 250k floor stays live until then.
jtabet added a commit to jtabet/sglang that referenced this pull request Oct 21, 2026
crash_dump_folder can point at a persisted-volume subpath that does not
exist yet on first crash; torch's _dump_snapshot does not create parents
and the pickle write fails silently inside the best-effort handler — the
forensics die exactly when they matter (crash sgl-project#19's evidence gap).
xutizhou added a commit to xutizhou/sglang that referenced this pull request Dec 2, 2026
… option

- Migration note: use WATERFILL_LOAD_VIEW (global default, local = old
  static behavior) instead of the nonexistent WATERFILL_USE_GLOBAL_LOAD.
- Document that waterfill supports DeepEP and MegaMoE, and restore the
  DeepSeek-V4 MegaMoE + Waterfill example.
- Two-rank smoke: distinguish waterfill_global/waterfill_local via
  WATERFILL_LOAD_VIEW and assert on EP all-reduce calls.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
yangxin-mx pushed a commit to MetaX-MACA/sglang that referenced this pull request Dec 2, 2026
将 mx/dev-0.5.19 中与 GLM5Next 相关的迁移及必要修复合并到一个提交,
基于 mx/dev-0.5.21 的 9b491a645e,保留 target 新 CP/API 架构。
按原迁移表顺序核对62条:35条迁移/适配/必要依赖,27条已有覆盖或按表跳过。

迁移/适配明细(编号为原表序号;Source 为真实 source commit):

- #1 Source: 90fc47afb93b52ee2e17db94ff81c70ca355c510
  内容:为 DSA/MHA 分支补 idle 守卫,避免 DP idle batch 误入 MHA 路径。

- #7 Source: ede708204940def467c753ab97f22b098104c8d8
  内容:移植 prefill attention 的 FA2 在线 softmax 归一化和 MACA 非因果128x32调度;按实测
    将大 head_dim 的 MACA tile 缩为32x32,保留非MACA调度。

- #8 Source: 251667008296ead929e477c3d31acfcaaea3822d
  内容:MACA 非因果 attention 的 num_stages 从2降为1,与 FA2 tile 调度配套,降低共享内存需
    求。

- #9 Source: 04827865d580a1bb9b64815fab861e03f2eb2666
  内容:迁移 Hadamard/INT8 GEMM 自定义算子注册;修正 fake out_shape、C 写入声明及 Optional
    bias,保留平台守卫。

- #13 Source: f9d0b9622970734bba00fd3a44aff1a0394bb060
  内容:为 GLM5Next CUDA/XPU 路径补默认模型 dtype;使用 target config view 读取 hf_config
    ,保留用户显式 dtype。

- sgl-project#26 Source: 8a6ae864a3cebad6e272fd2541459a8510eb12f4
  内容:补齐 INT8 MQA 的 triton/tilelang/maca_c 后端选择器及校验,接入 paged、ragged、
    chunked prefill 和 CP 调用;补 GEMM_BF16 开关。

- sgl-project#27 Source: 7b58f8233d38e5469ae211cbf1176e4721817c47
  内容:迁移 W8A8 fused RMSNorm tuple 输入兼容,按 tuple 首项区分旧元数据;保留三维输入支
    持及 MQA 后端校验。

- sgl-project#28 Source: 74505cf936776c09f0786d4b301e1467b031a3d6
  内容:修正 MLA/q_lora 的 fused tuple 元数据识别,补 BF16 passthrough 解包,避免 tuple 进
    入 Tensor 投影路径。

- sgl-project#30 Source: 150bc2fdd022abf7684fc848043f2f0c7d4d45da
  内容:适配 GLM5Next W8A8 ignore mapper 与主模型/vision/NextN prefix;移植 KDA CP×
    attention-TP head 分片和 Mooncake 状态范围/stride/PP-layer 映射。修复新版 KPool
    full-key/local-query 接线、padding、FP8 dtype 及未初始化变量,保留复制状态 CP0 去重。

- sgl-project#31 Source: daf920081d8f65ca1925ccbefc39b6708fcdae02
  内容:迁移 GLM5Next/NextN fused RMSNorm、packed quant 与 mHC input 守卫;packed mHC 无
    residual 时补零并保留返回契约。

- sgl-project#32 Source: 3b81f1f4bc7ae595076ac31c777838ceaa14fc65
  内容:迁移 C500/C550 SplitKV、MACA smem 调度、mcoplib DSA/KDA、CPU token count、ln/log2
    转换、grouped_topk/fake 与 varlen SiLU;适配新增 track_state/inplace_update,修复
    SplitKV 三参数调用兼容。

- sgl-project#33 Source: e24ab0bb93eac50f134466c309b18a76108e8efb
  内容:迁移 FP8 fused norm/activation quant;修复 column_major_scales 传递与 TMA 对齐守卫
    、MLP 融合资格门控和 FP8 consumer tuple 选择,保留目标回退。

- sgl-project#35 Source: 126685db6e84f81eb337df29a06ae47efcb4ab0c
  内容:核验 KPool mcoplib 特性使用模块级 torch 导入,不引入 source 的局部 import 作用域错
    误。

- sgl-project#37 Source: c47a8a23daa1e5779a81ca5172021e582450f7f6
  内容:迁移 logits 显存预算刷新和 empty_cache;补 CUDA graph capture 守卫,避免捕获期间执
    行主机同步/缓存清理,保留 HIP 上限。

- sgl-project#38 Source: 891b2eda664e3a4dbae0f81ffa028087caf0be29
  内容:迁移 mcoplib AOT KPool 路径到 target kernels 目录,完整保留参数;用 EnvBool 处理开
    关,避免值0仍启用。

- sgl-project#39 Source: 9e74fa0504e402507671b703ec6e365728ee3f41
  内容:迁移 MTP metadata glue/seed merge,缺失行补零;保留 DSA/KPool/page/topk 等资格限制
    、静态图输入、eager fallback 及 target future_indices 接口。

- sgl-project#40 Source: 049fc02d18940d4c021281b1b54d4843b3ea0d57
  内容:迁移 MoE sum-add 从 shared_output 到 dispatch/runner/kernel 的接线及 INT8
    quant-once;保留 EP/TP/LoRA/no_combine/graph 回退,修正 shared_experts 属性守卫。

- sgl-project#41 Source: 8f5580f02634c1e6536e6925559f8a2a8f7b9b75
  内容:迁移 KDA BF16 投影融合资格、local N 对齐、加载后 padding 清零及 forward slice;初
    始化非融合分支属性,避免权重加载崩溃。

- sgl-project#43 Source: 1297d124af95d1df6f8c28ee20ee8b7c40177a26
  内容:迁移 optimized FP8 KV QDQ 及 STORE 开关;对 INT8、NoPE、非标准行宽和 rope=None 保
    留通用算子回退,避免全局别名误路由。

- sgl-project#45 Source: b48329742ca890d6d00692d4ea03160db56b661e
  内容:补齐 ragged/prefix-hit selected dequant:新增 GPU mark_selected_kv_rows 和 helper
    ;非法索引置-1,保持静态 shape、row mask、INT8/FP8 支持且无 host sync。

- sgl-project#46 Source: 033598e00ca324e084cdff89a4107f4d3e8e009e
  内容:迁移 TileLang FP8 KV 的 selected-dequant→BF16-kernel 路径,以 pool dtype 判断并保
    留 INT8/TopK 对齐;补显式 MACA FP8 反量化参数例外,保留 NVIDIA/HIP/sink 限制。

- sgl-project#47 Source: 78d6a6d53bf52d938bea469f658be8c561addc6b
  内容:补齐 optimized QDQ 必需的 NoPE 依赖:rope=None/空 rope、528B/656B 行宽派生及
    DIM_ROPE 条件;保留 INT8/其他布局通用回退。

- sgl-project#49 Source: bcca3bc2a68e0e7fab28f826652d14be0118ffd7
  内容:补迁 MX_USE_INDEXER_LOGITS_OPT(默认True)及 MACA FP8 logits 的 maca_c/triton 路由
    ,覆盖 paged、ragged、chunked prefill/CP,保留 INT8 和非MACA行为。

- sgl-project#50 Source: e15a1dd543c0d724b5af3221bde8465d95dfacf1
  内容:迁移 alt-stream 开关、MLA norm consumer 门控和 BF16 passthrough;补齐
    _weights_proj/x_for_gate 旁路,避免多余 FP8 反量化。

- sgl-project#51 Source: 24824a0a86f8e0036ea770377a4a4068b9dbf23e
  内容:按原表移植上游5733bcaad32的 HiCache host-pool 声明,保留 target
    StackStrategy/unified 扩展;补实际 index buffer dtype/宽度探测,修正 BF16 元素/字节
    stride。

- sgl-project#52 Source: caa3b73f5fbd061f19db5d01b422fe727299413e
  内容:迁移 hybrid KV+INDEXER+MAMBA host 栈、owned-layer/PP stage-local 映射、packed draft/sidecar 登记和声明覆盖校验,适配 target controller API。

- sgl-project#53 Source: 69b77095f7141e60070bfe7e53180ab82163574c
  内容:迁移六个 C500 KDA/conv kernel 及包装器;对 target 新
    track_state/inplace_update/beta 语义设置资格守卫与回退,保留 mcoplib 互斥。

- sgl-project#54 Source: 30bedf83aaa4c7127a6caa454cc859bf14d7805e
  内容:迁移 request-shared selected dequant;修正同请求所有 query 共用相同槽的假设,相同
    槽复用、不同 KPool tail 保留独立行,以静态容量/row mask 保证正确性。

- sgl-project#55 Source: eaf4cf1ab6e050e57b1601ba9c81b83ddaede089
  内容:延迟导入 KDA,仅在 Kimi 非NPU或 GLM5Next 路径加载,保留 Ascend 及其他
    linear-attention 后端。

- sgl-project#56 Source: 3687cf0cca0dcb84e031b3ab9565eb71eacaa6c0
  内容:抽出 C500 KDA 轻量配置和延迟导入开关;配套 optional-import 验证材料独立保存在仓库外。

- sgl-project#57 Source: fc708361eee03357f665bc09836a5477d218e2e8
  内容:迁移 mcoplib per_token_cast AOT 注册和 MLP SiLU 列主序 FP8 scale;与#33合并修复列
    主序/TMA 守卫,保留动态/融合/UE8M0 回退。

- sgl-project#58 Source: 9a8d3013dbfce88b219661d8798c7486a8a03a3a
  内容:迁移 MACA 3.10 的 FP8-MMA 能力判定(sm87/88/89 与80/86区分);非原生设备使用
    selected dequant 并补齐 page64,限制在 MACA FlashMLA 路径。

- sgl-project#59 Source: 49b8de76fbdc929bda5c03869c29bdfe37f97cdc
  内容:补迁 config-driven W4A8 QuaRot:主干末端/NextN shared_head 先完成 residual stream
    归约与清理,再 rotation→norm;登记两套 NextN rotation 权重,复用已有算子。

- sgl-project#61 Source: 039732e9a01ad42eba7c04c06c731d344708da1d
  内容:迁移 masked SiLU FP8 mcoplib 算子、FP32 scales 和列主序选项;保留特殊 activation、
    UE8M0 及目标 JIT 回退。

- sgl-project#62 Source: cada5f0f72e860376168544b3ce33ea660317147
  内容:迁移两个 GLM/KPool alt-stream kill-switch;旧 draft handoff wait 已无落点,保留
    target verify plan-stream 的正确性等待,不删除有效同步。

已核验但不重复迁移的条目(不计为新增移植):

- #2 Source: 22cf8d913ac1483bf6fa4b422b4a324b8aacc27a
  处理:target 已有 INT8/FP8/BF16 index cache dtype 配置、存储映射和环境变量,不重复移植。

- #3 Source: 24fd61059835d20f9e0dcd9d1a1cd454c76fe726
  处理:target 新 CP 的 world_group 广播统一解包已覆盖旧 scheduler 修复。

- #4 Source: 18771c6405169ba6a7d0b25f28c467bb47b1321b
  处理:target 通过 extend_seq_lens/input_ids 构建 CP metadata,不恢复旧 global
    token-count 逻辑。

- #5 Source: 2a209dffdd6d19466fb01428c541ab5fff513576
  处理:保留 target GDN chunk-H num_stages 默认2;C550 部署脚本设置为1,避免共享内存超限。

- #6 Source: c54a1a09ebe3f6e025f665a22e1ab6a78053bc05
  处理:target 已有 DSA update_verify_buffers_to_fill_after_draft 钩子。

- #10 Source: 68bfa76e0edbaf39b095e4271ba5d92faa2fe0e7
  处理:target 已有正规 MACA/mcoplib AOT 注册,跳过 source 的临时 sampling 导入注释。

- #11 Source: 385411126ba4a03c28a4c543184374b817fa5bc9
  处理:原表禁止迁移的 bring-up hack 不迁入;保留真实量化、layernorm 和正规 MACA 支持。

- #12 Source: 19061bd747bdb716f750b7fcf293decc915a30bf
  处理:target 已重放 W8A8/KPool dtype 及模型 prefix 基础支持;后续 mapper 兼容修复计入sgl-project#30
    。

- #14 Source: 6e5cf1875bbba5f7bc37118a990f6d60a9ab6146
  处理:target 已有 GLM5.3 主模型/NextN 架构识别、层名与 prefix 适配。

- #15 Source: bb18010c11efdc38c52f14030d1bdd3a11e5592f
  处理:target 已有 INT8 ragged KPool logits 和 dtype 分派,保留新版 CP 实现。

- #16 Source: 0bbba0f8d9261f83f56e901b67be5a0fa9906aa9
  处理:target 已覆盖 MACA head_tile=16 及 INT8/FP8 CP/paged/ragged 分派。

- sgl-project#17 Source: 3ff8eca05fb3830e3fafa7c49ae9a63c03b1dd49
  处理:target 已完成相关 API 重构、KPool dtype 修复与 grouped_topk fallback,不迁回旧接口
    。

- sgl-project#18 Source: 97bac43d8cb9f21f660ea8eb89f5a63edbe597c4
  处理:target 已直接读取 enable_dp_lm_head,消除旧 get_parallel().config 访问。

- sgl-project#19 Source: d5833f123353343c2204d8c0f9953859906c2392
  处理:target 已有 mamba_chunk_size 懒读取,并去除重复 initial_state_indices 参数。

- sgl-project#20 Source: a59e91e76a4207566de6ecf4594de1139364e920
  处理:按原表明确不迁移图像预处理提交;本次 CP 多模态边界修复独立列在适配说明中。

- sgl-project#21 Source: ec70e92a479ea8f1f2ce4bfc32c7f31bf045fd5a
  处理:target 已有 norm_weight=None 时的 mhc_pre_vllm 回退。

- sgl-project#22 Source: 4deb87b34229438f0382687e2ed22f6f8c875227
  处理:target 已覆盖 layernorm AOT bytes、残差别名和 fake 注册,保留其 MACA metadata 守卫
    。

- sgl-project#23 Source: 5feccf7f43420e3db9c40599b8eabc7fed3f0e38
  处理:target W8A8 已支持三维 VLM 输入展平及输出形状恢复。

- sgl-project#24 Source: fb8a2c30228735ce68ba8a90feaefddddad96ee0
  处理:target 已有 INT8 KV 量化/反量化、packed layout、memory pool 及 rope0/64 全栈支持。

- sgl-project#25 Source: 705896cb9e098ecf4778b5d5d2850a9e5e7442fe
  处理:保留 target 更精细的 MACA flashmla_kv 默认选择及 GLM5.3 INT8 例外。

- sgl-project#29 Source: b2bc0c0a198bd7b4eaac14b1d3071a305986f0ac
  处理:target 已有 INT8 属性保护,旧 mamba_branching_seqlen 清理落点已删除。

- sgl-project#34 Source: e9ce0de76ecacb6c3d867b90f9bf1120d2c3d974
  处理:target 不再向只读 logical_size/logical_page_size 赋值,已覆盖 source 修复。

- sgl-project#36 Source: 9e2d4fa7b9657dc8c5bb24e0bfbd302456885d10
  处理:target 已在访问 dtype 前判断 tuple,覆盖 FP8 MoE 崩溃;原表 full hash 有误,本列表
    使用唯一前缀解析后的真实 source commit。

- sgl-project#42 Source: a1a845df4b8f281b243d542ab39b46e754463cc2
  处理:保留 target 新 CP/prefix-cache 框架,不恢复旧 CP-V2/radix bypass;缺口随#30修复并
    验证前缀命中。

- sgl-project#44 Source: 2b20e9a0312dadc751b14ffe4bba7736750bd5b1
  处理:target 新 CP 仅在 context-parallel extend 生效,verify/draft 不进入 CP;保留现有
    padding 框架。

- sgl-project#48 Source: 18b3a7260ed85c95c1a6be87f652b7f89a75c91b
  处理:target 已由 hybrid_kda_config 和 cache_params.is_kda 覆盖模型识别、state
    ring/intermediate_ssm,保留 ReplaySSM。

- sgl-project#60 Source: 7c37c8ed18e9cea67e4a3f7eb564571226d0583b
  处理:target 已重放 GLM5.3 INT8 架构、528B/rope0/64、ragged/paged 和 selected-dequant 支
    持,保留新 metadata/HiCache 接口。

0.5.21 接口适配补充:
- 补 GLM prepare_cp_inputs:CP分片前复用完整多模态embedding,
  runner使用hook返回的positions并保留kwargs,后续PP stage消费proxy。

Change-Id: I5bda468525cc09d9f74598fcdd69d07764b6ecf3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant