Repository navigation
Eliminate 2 gpu ops during sampling when logit_bias is zero - #343
Merged
Merged
Conversation
timethink
pushed a commit
to timethink/sglang
that referenced
this pull request
Mar 9, 2025
…ect#343) Co-authored-by: Qubitium <[email protected]>
vschandramourya
pushed a commit
to vschandramourya/sglang
that referenced
this pull request
Feb 3, 2026
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
rucnyz
added a commit
to rucnyz/sglang
that referenced
this pull request
Jul 14, 2026
…gation Swarm / k2m robustness: - sgl-project#339 per-req mamba admission budget (COW-source over-admit defer) - sgl-project#340 clamp k2m fire grant to dst mamba max_size - sgl-project#341 k2m KV working-set floor (prefill-chunk reserve) - sgl-project#342 planner k2m/m2k oscillation fix (LPB-loss eviction cost) - sgl-project#343 has_cost_curves() gate so base fail-closes cleanly (no faked regression) - require_mamba_radix_cache_for_hima boot guard; admitter returns None (defers) when owner_provider unwired (first-tick race) instead of raising Budgeter simplification: PaybackPlanner (payback R_evict + R_admission + urgency) replaces the NB planner; pressure_adapter removed. Third-model (Ling-2.6-flash, MLA) finding: \sys structurally unmeasurable — the MLA KV pool is not arena-backed (arena lives only in MHATokenToKVPool with head_dim==v_head_dim), so kv_arena=None and cross-pool KV<->mamba transfer is impossible; 0 fires across all configs. Documented in reproduce/RQ1/FINDINGS.md. Same class as the Kimi ChunkCache blocker. Reproduce harness: multi-GPU run_arm (GPUS/TP, GPU-free wait, per-model csigma), aggregate_maintable, vLLM arm. Tests: admitter defer-unwired, require-mamba-radix, payback, m2k cap floor, async fire, kv working-set floor. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Jul 31, 2026
…e, per-device gates, process-wide floors (sgl-project#343, fixes sgl-project#267)
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Jul 31, 2026
…1 divergence harness (sgl-project#343)
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Jul 31, 2026
…d under uneven-DCP replication (sgl-project#345, root of sgl-project#340/sgl-project#343 divergence)
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 2, 2026
…device actually has Boot 11 failed on both architectures of this rig for two different reasons, and neither was a missing capability -- both were a dispatch that named one architecture where it meant "has this kernel". TP0 (5090, sm120) entered the sparse-prefill branch and hit "Sparse Attention Forward Kernel is only supported on SM90a and SM100f". Upstream already fixed exactly this in the merged PR sgl-project#30272 by adding "and not _is_sm120" to the predicate; our base predates it (git log -S on that file is empty, so this is an old base, not a fork regression). Adopted rather than rebuilt, but phrased as flash_mla_sparse_fwd_supported(device) -- the kernel states its own domain in its error text, so the gate says major in (9, 10) and covers Ampere with the same line. The dense branch it falls to is handed the SAME swa_page_indices / swa_topk_lengths the indexer produced: the kernel changes, the attention support does not. Two independent confirmations that this is lossless rather than an approximation: upstream sgl-project#32464 calls the SM120 dense route intended production behaviour, and our own test kit compares both branches against one _pure_torch_dsv4_combined_reference. TP1/TP2 (3080, sm86) died in dsv4/dequant_k_cache.py on "type fp8e4nv not supported in this architecture". The V4 KV layout is fp8-e4m3 BY ARCHITECTURE (448 fp8 nope + 64 bf16 rope + 7 ue8m0 scale bytes in a uint8 pool); --kv-cache-dtype cannot move it, the pool asserts store_dtype == uint8. Triton's NVIDIA backend admits fp8e4nv only from capability 8.9. The briefing named one file. The bug has four call sites, and fixing only the named one would have MOVED the failure rather than removed it -- the two KV *writers* run before any attention: * dequant_k_cache.py (read) -> manual decode * flash_mla_sm120_triton.py -> manual decode; this is the one that actually becomes load-bearing on sm86 once the sparse branch is left * index_buf_accessor.py (write) -> turned out to be a pure byte copy with no arithmetic between load and store, so both ends are viewed as uint8 unconditionally: byte-identical everywhere, no gate needed * quant_k_cache.py (write) -> a real encode. Rather than hand-roll round-to-nearest-even in Triton, the fallback stages the already-clamped float32 and lets torch do the cast, which sgl-project#262 proved bit-exact on sm86. f32 not bf16 staging: bf16 has 8 mantissa bits and would double-round. Third finding, from sgl-project#33194's report and confirmed here: the compile failure is triggered by the kernel ARGUMENT, not the load -- an fp8-typed tensor fails at the def line even if the pointer is never dereferenced. An in-kernel branch alone cannot fix it, so the host passes the uint8 view and a tl.constexpr selects the decode. nope_cache_view returns view and flag together, following sgl-project#192's pairing invariant: a caller cannot take one without the other. Also removed the module-level SGLANG_SM120_FLASHMLA_BACKEND read in flash_mla_sm120.py -- the exact sgl-project#343 anti-pattern, and its default resolves to a flashinfer kernel gated to cc 120/121, so on a mixed group every rank got whichever card imported first. Resolution is per device now; an explicitly set value still applies everywhere (a statement about the launch, not a probe), and is downgraded loudly, not silently, where the kernel cannot exist. TESTS (desk, CUDA_VISIBLE_DEVICES=99, no GPU touched) test_dsv4_fp8_triton_compat_417.py 12 tests / 262 subtests green. Runs the production @triton.jit decode under TRITON_INTERPRET=1 against a pure Python IEEE-754 reference that never touches a torch fp8 dtype (sgl-project#262's rule: a torch reference would share torch's own Ampere bug and pass vacuously), with an e5m2 cross-probe so a comparison of nothing fails. All 256 codes, signed zero at 0x80, both NaN codes, plus the whole paged kernel vs the torch ref. CAN-FAIL: bits & 7 -> bits & 6 gives 128 failed / 10 passed. test_dsv4_arch_dispatch_417.py 16 tests / 28 subtests green, incl. the two cards of this rig disagreeing inside one process. CAN-FAIL: _FLASH_MLA_CUDA_MAJORS -> (8, 9, 10) gives 7 failed / 15 passed. Regression: unit/layers/attention + unit/utils, 44 failed / 362 passed on this branch vs 44 failed / 334 passed at a56f33aafd (throwaway detached worktree). Failing set diff EMPTY; all 44 pre-existing "No CUDA GPUs are available". The +28 are these tests. ruff 1 finding on the touched files, the identical 1 at the base (F841, pre-existing). codespell, black, isort clean. mypy clean on both new modules. NOT proved at the desk, by construction: that these kernels COMPILE on a real sm86 card. The Triton interpreter never invokes the NVIDIA backend, which is where fp8e4nv is rejected. Gates for the card window are written down in docs/dev/PLAN_417_dsv4_arch_paths.md along with the full per-architecture coverage matrix, the upstream survey, and the open risks -- chief among them that the indexer (dsv4/indexer.py:667, DeepGEMM metadata) is NOT addressed here and may well be where boot 12 stops, and that sgl-project#33194's chain ends at FP4 routed experts, a wall we expect to miss because we serve GGUF.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 2, 2026
…ache peak managed Two probes and one answered question, all from sgl-project#417 window 3. Both probes are default-off and inert unless asked for; they sit on the forward path and the load path. 1. FORWARD PEAK, MEASURED INSTEAD OF INFERRED Window 3 died on a prefill transient: a 3080 rank had 639 MiB free at ready and still failed a 136 MiB allocation on a ~1-2k prompt. Nobody ever measured that transient -- it was inferred from the one allocation that happened to fail, which is a lower bound on the SHORTFALL and says nothing about the peak. Every fixposten since has budgeted it by taste, mine included. model_executor/forward_peak.py brackets each forward with reset_peak_memory_stats / max_memory_allocated, bucketed by phase and token count. Driven from _forward_raw, the same place the sgl-project#343 layer tap lives and for the same reason (the model is entered as model.forward(...), so a module hook never fires). peak_scope() closes the bracket on the exception path too: an OOM is exactly when the peak matters. It writes a FILE per rank, not a log line, and the channel was chosen on evidence. /server_info already aggregates a per-rank memory_usage dict and is the natural home for a live number -- but this number exists to characterise a peak that PRECEDES an OOM death, and /server_info needs a live server. The per-rank JSON files survive it: that is how window 3's expert_stats arrived from a boot whose rank had already died. Worker logger.warning does not reach the log at all on this rig, which rules out the third channel. 2. THE LOAD-TIME PAGE-CACHE RACE, MANAGED INSTEAD OF LUCKY Chosen of the three options: trim coupled to CONSUMER PROGRESS (ProgressCoupledTrim, called from ConsumedPageDropper._flush_shard after each advice batch). The failure is a RATE mismatch, not a wrong threshold: cachetrim.sh samples on a 5 s wall clock and window 3 moved memory.current 88.2 -> 102.5 GiB inside one 15 s window, so whether a boot lived came down to where a noisy peak fell between two samples -- w3a survived the recipe w3b died on. Coupling the trim to the stream makes a faster load trim more often with no interval to tune. * "loader waits on a watermark" is this plus a stall: more invasive, and it can deadlock when the watermark is unreachable because the pinned pool, which reclaim cannot touch, is already above it. * "tighter load-phase threshold" only moves a number a 5 s sampler can still overshoot. It does not address the rate. cachetrim.sh stays (it also trims what the loader does not cause) and the rammon guard is untouched, as instructed. Safety is cachetrim's own argument and is CHECKED not assumed: swapless means reclaim cannot evict anon, so the pinned pool, CUDA host allocations and the Python heap are out of reach and only page cache can go. With swap it refuses; without memory.reclaim it disables itself. A probe must never be why a load fails. 3. PER-RANK CHUNKED-PREFILL-SIZE IS NOT POSSIBLE -- NAMED LIMIT, NOT A GAP Asked whether the 3080s could get a smaller chunk than the 5090. Hard no. chunked_prefill_size IS the batch-shape knob: it sets how many tokens each rank contributes to prefill's own collectives, every rank parses the same scalar, and the only division (dp_size) is applied identically everywhere. Making it per-rank reproduces precisely the class this fork already built machinery against -- kv_session_offload.py:2559: "A divergent decision makes rank 0 take the prefill branch while ranks 1/2 take the decode branch ... those branches carry DIFFERENT collectives, so the ranks desync (NCCL/gloo hang)", with scheduler.py:3643 documenting the admission budget as deliberately RANK-UNIFORM. --rank-moe-resident-fraction is safe as a vector precisely because it only moves bytes within a rank's own weight/host split and never changes a batch shape; chunk size is the opposite knob. Recorded as an exclusion with its reason. Consequence: the 3080 prefill transient can only be cut by lowering the GLOBAL chunk size, at a cost paid by all three ranks. Also answered, for the window-4 plan: --disable-cuda-graph is NOT a conservative choice and is nothing to do with DSV4 or GGUF. MoE expert offload forces it, fail-fast at layer construction, because the residency plan is data-dependent (topk_ids.tolist(), a device->host sync inside every forward) and cannot be captured. SGLANG_MOE_OFFLOAD_CUDA_GRAPH=1 opens a capturable DECODE-only path, but it freezes the resident set -- a different configuration, not a toggle, so its number would not be comparable to an eager one from the same boot. Recommended as its own later arm with its own floor rather than forced into window 4. TESTS (desk, CUDA_VISIBLE_DEVICES=99) test_forward_peak_and_stream_trim.py 12 tests green: both probes inert by default, peak recorded per phase/bucket, bracket closes on the exception path, file written per rank, trim quiet below the watermark and reclaiming exactly current-target above it, swap refusal, self-disable when memory.reclaim is missing. Can-fail included (a tracker that never reset would report a running max). 48 passed across the two new suites together. Regression unit/layers + unit/model_executor + unit/model_loader: 19 failed / 1113 passed at 5d1e8a18c6, failing set diff EMPTY on this branch. ruff clean on the new files, codespell/black/isort clean, mypy clean on forward_peak. Window-4 plan is in docs/dev/PLAN_MOE_RESIDENT_FRACTION_PER_RANK.md: one boot, w3a's vector unchanged, both probes armed, and a STAGED prefill (256/512/1024/ 2048) so the transient is bracketed between two measured numbers even if the top step still OOMs -- which is the difference between this window and the last one.
WhiteCmile
added a commit
to WhiteCmile/sglang
that referenced
this pull request
Dec 1, 2026
…roject#421) The split poll (default on since sgl-project#343) is now the only path: - dt_direct_ring.py: drop the DT_TARGET_POLL_SPLIT env read - dt_target.py: delete _poll_export_rank (fused poll, flag-off only), the _target_poll_split attribute and both flag branches; ready_sync unconditionally runs _ready_sync_export_rank, control_phase guards on is_export_rank only - tests: drop the split=off test in test_dt_target_poll_split.py; repoint test_dt_completion_before_park.py at _ready_sync_export_rank and the source-read-done ack test at _control_phase_export_rank (same live code, previously reached via the fused poll)
1195343015
pushed a commit
to 1195343015/sglang
that referenced
this pull request
Dec 2, 2026
…concurrency (sgl-project#343) Raise MODEL_SANITY_READY_TIMEOUTS for zai-org/GLM-5.3 from 4500s to 6600s to cover TP4 141-shard cold loads before CUDA graph capture and DeepGEMM warmup, and set strategy.max-parallel to 4 for model_sanity (32 for fast_sanity) in nightly-test-ppu.yml to reduce concurrent NAS read contention. Signed-off-by: Yunzshi310 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixed #338