Skip to content

[Perf] deepseek-v4.1: Check request-window SWA history without per-layer host syncs - #45223

Merged
hnyls2002 merged 2 commits into
mainfrom
lsyin/dsv41-request-window-sync
Oct 19, 2026
Merged

hnyls2002 merged 2 commits into
mainfrom
lsyin/dsv41-request-window-sync

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator
  • With encoder SWA bounded replay on, RequestWindow.buffer checked each SWA layer's history before use with boolean-mask indexing and torch.equal: three host syncs per SWA layer per extend step, so the scheduler could not run ahead of the GPU.
  • The check now goes through the sync-free invariants API (utils/invariants.py): expect on a dsv41.swa_history_present invariant (FATAL_CONTAINABLE), so SGLANG_INVARIANT_CHECK decides it: off in production (no detection), a throttled count and log at WARN, a device-side assert at STRICT.
  • Behavior change: with SGLANG_INVARIANT_CHECK off (the default), servers no longer check SWA history; CI runs at STRICT and still fails on a missing history.
  • Verification: DeepSeek-V4.1-Flash on GB300, DP2 attention + MegaMoE (EP2), encoder and decoder replay on, a multi-turn agentic prefill trace at concurrency 512, 900 s per run, same-node pairs.
    • Before: py-spy put 75% of the scheduler main thread's samples in RequestWindow.buffer.
    • Removing the per-layer check: +4.5% to +6.7% tok/s/GPU on three nodes; the step interval went from ~405 to ~375 ms at the same step shape.
    • The deferred-flag version of this check (an earlier revision of this PR) ran within -1.3% to +0.7% of removing the check on three nodes, with no false raise; the invariants version adds only the comparison kernels.
    • test_dsv41_request_window_copy.py passes. A one-off GPU script confirmed: matching history passes at STRICT; missing history passes at OFF and trips invariant-check FAILED [dsv41.swa_history_present] at STRICT.

CI States

Latest PR Test (Base): 🚫 Run #39318746765
Latest PR Test (Extra): ❌ Run #39318746634
Latest PR Test (AMD ROCm 10): 🚫 Run #39318746757

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_dsv41_request_window_copy.py test_deepseek_v41_flash_gb300_encoder_bcg.py registered/attention/unittests/dsv4/test_deepseek_v4.py test_q8kv8_sparse_prefill_backend.py test_encoder_swa_replay.py test_dsv4_compressed_pools.py test_invariants.py test_dsv41_late_layer_tail_readers.py

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🚀 1-gpu-h100 (3 tests): ✅ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_dsv41_request_window_copy.py
cd test/ && python3 registered/attention/unittests/dsv4/test_deepseek_v4.py
cd test/ && python3 registered/kernels/ops/attention/test_q8kv8_sparse_prefill_backend.py

🚀 4-gpu-gb300 (1 test): ❌ View workflow run

cd test/ && python3 registered/e2e/models/test_deepseek_v41_flash_gb300_encoder_bcg.py

🚀 4-gpu-b200 (1 test): ❌ View workflow run

cd test/ && python3 registered/attention/unittests/dsv4/test_deepseek_v4.py

🚀 ubuntu-latest (4 tests): ✅ View workflow run

cd test/ && python3 registered/unit/model_executor/test_encoder_swa_replay.py
cd test/ && python3 registered/unit/mem_cache/test_dsv4_compressed_pools.py
cd test/ && python3 registered/unit/utils/test_invariants.py
cd test/ && python3 registered/unit/layers/test_dsv41_late_layer_tail_readers.py

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Oct 19, 2026
@hnyls2002
hnyls2002 merged commit 8b1d1e0 into main Oct 19, 2026
182 of 243 checks passed
@hnyls2002
hnyls2002 deleted the lsyin/dsv41-request-window-sync branch October 19, 2026 20:34
chaohu2000 added a commit to flytiger-eco/sglang-for-sail that referenced this pull request Oct 27, 2026
…yer host syncs (sgl-project#45223)

(cherry picked from commit 543002de921db17333cba2cbc58081ecef480279)
listar2000 pushed a commit to listar2000/miles that referenced this pull request Oct 30, 2026
…e host every layer [fork fix-067]

RequestWindow checked that the SWA history the replay expects is present
with torch.equal on a masked gather, once per layer per prefill: a
device-to-host sync each time. SGLang's change (#45223) makes it a
device-side invariant (sglang.srt.utils.invariants, already at our pin)
that stays fatal under strict checking.

Patch page: fork/patches/fix-065-sglang-swa-fixes.md

Fork-Fix: fix-067
Touches: sglang:python/sglang/srt/mem_cache/dsv41_request_window.py
Evidence: sgl-project/sglang#45223 (main 8b1d1e0d7); prefill time in the 1-node A/B on this branch's image
Upstream-Status: merged in sgl-project/sglang main 80afdc128 (8b1d1e0d7, #45223); not on sglang-miles 5403606db9
Remove-When: SGLANG_COMMIT includes sgl-project/sglang 8b1d1e0d7
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant