Repository navigation
Eliminate 2 gpu ops during sampling when logit_bias is zero - #338
Merged
Merged
Conversation
hnyls2002
reviewed
Mar 29, 2024
Collaborator
timethink
pushed a commit
to timethink/sglang
that referenced
this pull request
Mar 9, 2025
…ect#338) Co-authored-by: hnyls2002 <[email protected]>
shiyu7
pushed a commit
to shiyu7/sglang
that referenced
this pull request
Dec 12, 2025
Estrella-xx
pushed a commit
to Estrella-xx/sglang
that referenced
this pull request
Apr 13, 2026
Co-authored-by: Jianzhao Xu <[email protected]>
rucnyz
added a commit
to rucnyz/sglang
that referenced
this pull request
Jul 14, 2026
…ctable-aware mamba admission gate (sgl-project#338) Two root-cause fixes so the recurrent-bound swarm runs correctly under HiMA: sgl-project#337 (mamba_actuator): MambaArenaActuator.unmark_token_slots routed the k2m dst-grow through the legacy MambaPool.unmark_slots shadow state, which live_size no longer reads, so a grown mamba pool was invisible to BudgetAgent._maybe_update_admission_cap ("grew events: 0", cap pinned at boot). Route through the allocator (self.allocator.unmark_pages_capped -> CappedFreeList._grow_into_tail) and reconcile pool.size from pool.live_size, byte-symmetric with KVArenaActuator. Single source of truth = the allocator's CappedFreeList. sgl-project#338 (memory_pool + common + scheduler): a hybrid request needs a mamba active slot in addition to a req slot, but Scheduler.get_num_allocatable_reqs gated only on req_to_token_pool.available_size() (req slots). After sgl-project#337 raises the cap, the scheduler admitted a batch mamba could not back and alloc_req_slots RAISED instead of leaving the request queued (the design defer action) -> swarm crash. Add HybridReqToTokenPool.mamba_admittable_reqs(mamba_evictable) = (free + evictable) // slots-per-req and gate get_num_allocatable_reqs on it, mirroring the KV available+evictable gate in PrefillAdder. Counting evictable (what alloc_req_slots reclaims via pre-evict) is what keeps a lightly-loaded pool from throttling on free slots alone. per-req factor extracted to HybridReqToTokenPool.mamba_slots_per_req (single source of truth shared with alloc_req_slots). Validated: 2 reproducing unit tests (actuator grow -> live_size; admittable-reqs crash-guard + no-throttle). E2E swarm A/B (real CC subagent-flattened trace, default config, conc 400): both arms complete clean 1200/1200, 0 crash (was 2148 err); base unaffected (1009 tps, ran at 194); sys grows mamba 977->1233, admits to 246, TTFT -23% mean / -30% p99. (Throughput is GPU-compute-bound at real-CC 16K-context, so the higher concurrency converts to a TTFT win, not a throughput win.) 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
…/capabilities API, disconnect card-hold fix 30s->0.25s (sgl-project#338) # Conflicts: # docs/dev/INTEGRATION_R3_VALIDATION.md
3 tasks
1195343015
pushed a commit
to 1195343015/sglang
that referenced
this pull request
Dec 2, 2026
…l-project#338) * fix(ppu): keep NoPE low-precision indexers off the FP8 shortcut Why: - Kimi-K3.1 NoPE FP4/INT8 indexers can enter a shortcut that requires a RoPE cache. How: - Restrict the merged NoPE shortcut to FP8 and retain the existing FP4/INT8 paths. Dependency: - None Test: - Unit: - None - E2E: - Kimi-K3.1: - Model data type: MXFP4 MoE weights with FP8 activations (W4A8). - Affected platforms: T-HEAD PPU with SAIL SM89+ support; two-node TP8/CP8/EP8/PP2. - Test case: - Retain the original model precision and two-node serving configuration. - Environment: export SGLANG_JIT_DEEPGEMM_PRECOMPILE=0; export SGLANG_K3_FUSED_FRONT=0; export SGLANG_SAIL_DEEPGEMM_MXFP4_W4A8=1; export SGLANG_OPT_DEEPGEMM_MEGA_MOE_NUM_MAX_TOKENS_PER_RANK=2048; export SGLANG_PP_LAYER_PARTITION=47,46; export SGLANG_PP_LAST_STAGE_STREAM_ORDERING=1. - Command: sglang serve --model-path /ppusw/datasets/checkpoints/LLM/moonshotai/k3.1/Kimi-K3.1-Pro/ --trust-remote-code --tp-size 8 --attn-cp-size 8 --enable-prefill-cp --cp-strategy interleave --ep-size 8 --moe-a2a-backend megamoe --pp-size 2 --pp-async-batch-depth 1 --nnodes 2 --node-rank 0 --dist-init-addr 215.193.197.25:20000 --host 0.0.0.0 --port 30000 --max-total-tokens 101024 --max-running-requests 96 --mem-fraction-static 0.98 --disable-radix-cache --attention-backend dsa --dsa-prefill-backend flashmla_sparse --dsa-decode-backend flashmla_kv --linear-attn-backend flashkda --watchdog-timeout 3600 --served-model-name Kimi-K3.1 - Verify service startup, Graph capture, and one inference complete without missing NoPE RoPE-cache attribute errors. * fix(ppu): omit unsupported Kimi MegaMoE token hints on SAIL Why: - PPU MegaMoE entry points reject the global_num_tokens keyword passed by Kimi. How: - Pass the token hint only to the non-SAIL implementation. Dependency: - None Test: - Unit: - None - E2E: - Kimi-K3.1: - Model data type: MXFP4 MoE weights with FP8 activations (W4A8). - Affected platforms: T-HEAD PPU with SAIL SM89+ support; two-node TP8/CP8/EP8/PP2. - Test case: - Retain the original model precision and two-node serving configuration. - Environment: export SGLANG_JIT_DEEPGEMM_PRECOMPILE=0; export SGLANG_K3_FUSED_FRONT=0; export SGLANG_SAIL_DEEPGEMM_MXFP4_W4A8=1; export SGLANG_OPT_DEEPGEMM_MEGA_MOE_NUM_MAX_TOKENS_PER_RANK=2048; export SGLANG_PP_LAYER_PARTITION=47,46; export SGLANG_PP_LAST_STAGE_STREAM_ORDERING=1. - Command: sglang serve --model-path /ppusw/datasets/checkpoints/LLM/moonshotai/k3.1/Kimi-K3.1-Pro/ --trust-remote-code --tp-size 8 --attn-cp-size 8 --enable-prefill-cp --cp-strategy interleave --ep-size 8 --moe-a2a-backend megamoe --pp-size 2 --pp-async-batch-depth 1 --nnodes 2 --node-rank 0 --dist-init-addr 215.193.197.25:20000 --host 0.0.0.0 --port 30000 --max-total-tokens 101024 --max-running-requests 96 --mem-fraction-static 0.98 --disable-radix-cache --attention-backend dsa --dsa-prefill-backend flashmla_sparse --dsa-decode-backend flashmla_kv --linear-attn-backend flashkda --watchdog-timeout 3600 --served-model-name Kimi-K3.1 - Verify service startup, Graph capture, and one inference complete without unsupported global_num_tokens keyword errors. * fix(ppu): align DSA FP4 cache selection across SAIL paths Why: - SAIL indexers and cache allocation can select different precision layouts. - The FP4 CLI gate rejects supported SAIL devices. How: - Accept SAIL SM89+ and retain the legacy environment default. - Align cache allocation and sizing with the SAIL precision resolver. - Keep SAIL on the PPU Indexer implementation. Dependency: - None Test: - Unit: - None - E2E: - Kimi-K3.1: - Model data type: MXFP4 MoE weights with FP8 activations (W4A8). - Affected platforms: T-HEAD PPU with SAIL SM89+ support; two-node TP8/CP8/EP8/PP2. - Test case: - Retain the original model precision and two-node serving configuration. - Environment: export SGLANG_JIT_DEEPGEMM_PRECOMPILE=0; export SGLANG_K3_FUSED_FRONT=0; export SGLANG_SAIL_DEEPGEMM_MXFP4_W4A8=1; export SGLANG_OPT_DEEPGEMM_MEGA_MOE_NUM_MAX_TOKENS_PER_RANK=2048; export SGLANG_PP_LAYER_PARTITION=47,46; export SGLANG_PP_LAST_STAGE_STREAM_ORDERING=1. - Command: sglang serve --model-path /ppusw/datasets/checkpoints/LLM/moonshotai/k3.1/Kimi-K3.1-Pro/ --trust-remote-code --tp-size 8 --attn-cp-size 8 --enable-prefill-cp --cp-strategy interleave --ep-size 8 --moe-a2a-backend megamoe --pp-size 2 --pp-async-batch-depth 1 --nnodes 2 --node-rank 0 --dist-init-addr 215.193.197.25:20000 --host 0.0.0.0 --port 30000 --max-total-tokens 101024 --max-running-requests 96 --mem-fraction-static 0.98 --disable-radix-cache --attention-backend dsa --dsa-prefill-backend flashmla_sparse --dsa-decode-backend flashmla_kv --linear-attn-backend flashkda --watchdog-timeout 3600 --served-model-name Kimi-K3.1 - Verify service startup, Graph capture, and one inference complete without FP4 writer versus FP8 index-K cache stride mismatches.
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.
Reason for PR: Eliminate 2 gpu ops during sampling when
logit_biasis not used (all zeros)logit_biaslogits.add_(self.logit_bias)On our internal test of Yi-6B quantized using
marlinon 4090 we see tangible improvement: up to 63% throughput improvement for small sized tokens output work loads when batch > 1.Concurrency is 10 requests so it will cause sglang to use batch size between 1-10: