Skip to content

[SGLang] Batch ReplaySSM radix materialization across compatible layers - #3942

Draft
ZLkanyo009 wants to merge 5 commits into
mainfrom
lingzha/replayssm-materialize-layers-main-20261127
Draft

ZLkanyo009 wants to merge 5 commits into
mainfrom
lingzha/replayssm-materialize-layers-main-20261127

Conversation

@ZLkanyo009

@ZLkanyo009 ZLkanyo009 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

SGLang's ReplaySSM radix commit currently launches materialization once per GDN layer. This Draft combines compatible eager layers into one grid while retaining the shared replay arithmetic and the order of materialization, cursor commit, and convolution-state scatter.

The plugin owns the live pool lookups, HiCache readiness waits, and an immutable pointer-table generation. It refreshes the table when addresses, layouts, layer order, or consumer stream change, and retains and records the backing tensors on that stream. Graph capture and heterogeneous layouts continue through the existing per-layer path; this PR does not optimize batched graph replay.

The shared operator exposes an explicit replayssm_materialize_batch entry point. The existing single-layer API keeps its signature, grid and arithmetic. Its host launch configuration is refactored into a common helper, so Native host dispatch is affected; the bounded current-head comparison is reported below. The kernel's required table argument is None for the existing entry point. No model-specific name, architecture gate, environment switch, copied replay formula, or optional private host argument is added.

This change starts from public main at c88fef394fbf8c5eb490473079dd3f8b21854b09 and retains #3618's fourth flush_arrivals buffer, flush_wait, and six-value prepare_layer result. The table contains only the checkpoint and three record buffers. It does not include the separate forward-padding changes in #3718.

Validation available for this Draft:

  • Ten local CPU host/routing contracts pass using explicit device-free dependency substitutes. These exercise live readiness, actual address/layout/stream replacement, backing lifetime registration, capture/heterogeneous fallback, four-buffer selection, and commit ordering. Sixteen GDN/KDA layout combinations produce the same Native grid and launch arguments as the exact base. These checks are preparation evidence, not CI or GPU execution.
  • The replay arithmetic after pointer selection and the entire _commit_accepted function match the base AST. Black, Ruff and whitespace checks pass.
  • Earlier public-derived f3d0 prototype results are reported in #812: 14 GPU cases passed on gfx942. For a 36-layer helper microbenchmark, median event spans were 1777.032 → 214.041 µs at cursor 0 and 1762.373 → 213.111 µs at cursor 8. Those event spans include CPU submission bubbles. They are neither measurements of this main-based implementation nor model TPOT gains.

The committed GPU entry is tests/test_replayssm_materialize_batch_gpu.py (python -m pytest -q tests/test_replayssm_materialize_batch_gpu.py). At d7d20c6c1ca9e2c83fbfcb597654e232fd8ba80d, all 12 cases passed on one gfx942 MI308X, without skip/failure/error. Coverage includes single-layer Native, batch/fallback/capture, live replacement, pointer retirement with an actually pending consumer, and the four-buffer forward/commit path. This uses real kernels and SGL scatter with fixtures, not a full model or production HiCache.

The exact-base/current-head Native helper comparison used four alternating AB/BA rounds × 20 calls per arm for each layout (HV24/V128/T4/CAP16); whole checkpoints stayed byte-identical after timing:

Layout Host enqueue, base → PR GPU event span, base → PR Event-span change
GDN, K128 50.070 → 50.380 µs 51.039 → 51.391 µs +0.69%
KDA, K64 50.109 → 50.168 µs 51.161 → 51.098 µs −0.12%

These descriptive medians have mixed per-round directions and do not establish absence of regression. Event spans include CPU submission bubbles. A public-weight CPU download was active on NUMA1; no other task-owned GPU experiment overlapped. Source/dependency/runtime identity, JUnit lifetime proof, all exports and release were independently checked. Detailed validation.

This remains Draft pending production HiCache integration, current-head batch-performance measurement and matched two-rank model A/B results including actual route use, TPOT, MTP acceptance and final-task accuracy. Current-head CI/accuracy results remain separate. The f3d0 evidence does not replace those checks.

Keep the shared replay arithmetic and single-layer API while grouping compatible eager layers through an explicit batch entry. Preserve live pool readiness, pointer generation lifetime, capture fallback and main flush bookkeeping.

CPU host and routing contracts pass, including 16 Native GDN/KDA geometry comparisons. Current-head GPU, CI and model performance remain pending; historical f3d0 microbenchmarks do not validate this head.
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every eligible PR before approval:

  • ✅ Pre Checkin: Black, Ruff, catalog schema validation, non-GPU unit tests

Heavy model tests:

  • ✅ Gate checks are published on every PR so required checks do not stay missing
  • ✅ Expensive jobs run only after the PR is approved, or when a matching ci:* label is present
  • ✅ Pre Checkin must pass before approved heavy jobs continue
  • ✅ Without a matching label, expensive jobs also require a relevant path
  • ✅ A matching ci:* label is an explicit request and can open the gate even when paths would otherwise skip it

Path scope:

  • Native ATOM uses an ignore list: docs/markdown and plugin or Mesh paths are skipped
  • vLLM and SGLang use include lists: their own plugin code under atom/plugin/, plugin CI scripts, model list and release images. A core-only change does not run them; add ci:vllm / ci:sglang to ask for them
  • ATOMesh uses an include list: Mesh code, the ATOMesh accuracy workflow and its 1P1D launcher, plus the shared models_accuracy.json and accuracy_to_dashboard.py. ATOMesh benchmarks run after merge or on dispatch, not on PRs
  • Relevant path alone does not start expensive jobs; approval still opens the automatic path-scoped gate
Label Tests
ci:full Run all heavy PR model tests: native ATOM, vLLM, SGLang, and ATOMesh
ci:atom Run native ATOM model accuracy tests
ci:vllm Run ATOM vLLM OOT model accuracy tests
ci:sglang Run ATOM SGLang model accuracy tests
ci:mesh Run the ATOMesh accuracy tests, standalone and 1P1D, for Mesh-related changes

Without a matching ci:* label, heavy jobs are skipped when the path is not relevant or the PR is not approved.
Add labels via the sidebar or gh pr edit 3942 --add-label <label>

Add reproducible Native recurrence, batched numerical, live replacement, graph fallback and queued-pointer retirement coverage, plus actual current-main prepare/forward/materialize/commit/conv cases at three flush boundaries.

Prepared and linted only; real GPU execution remains pending with the sole owner. Product source is unchanged from 8f4ed60.
Invalidate the precompile result before the lifetime-sensitive submission, so a missing queued write cannot pass using the previous output. No product changes; GPU execution remains pending.
Prebuild and synchronize the same consumer-stream pointer table, then queue fixed matrix work and the cached materialize call. Record and require pending execution before dropping raw-pointer backings; preserve the destination sentinel. No product change or retry.
@ZLkanyo009

Copy link
Copy Markdown
Contributor Author

Current-head GPU validation is complete at d7d20c6c1ca9e2c83fbfcb597654e232fd8ba80d on one gfx942 MI308X. The committed pytest entry passed 12/12 cases, with no skips, failures or errors, including the four-buffer forward/commit path and pointer retirement while the consumer was still pending. Whole Native checkpoints remained byte-identical after timing.

The Native single-layer comparison used exact base c88fef39, four alternating AB/BA rounds and 20 calls per arm/round:

Layout Host enqueue, base → PR GPU event span, base → PR Event-span change
GDN, K128 50.070 → 50.380 µs 51.039 → 51.391 µs +0.69%
KDA, K64 50.109 → 50.168 µs 51.161 → 51.098 µs −0.12%

Both use HV24/V128/T4/CAP16. These are descriptive medians with mixed per-round directions; they do not establish absence of a regression. Event spans include CPU submission bubbles. A CPU weight download was active on NUMA1; no other task-owned GPU experiment ran during this measurement.

Independent review verified the 3,956-file source inventory, dependency/runtime identity before and after, all 11 exported files, JUnit lifetime property and full resource release at 10:56:00 UTC. This validates the current test/fixture paths; production HiCache integration, current-head batch performance and same-host model TPOT/MTP/final-task accuracy remain open. The PR stays Draft.

This branch has not been deployed

No deployments
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