Skip to content

Fix warp illegal instruction in kimi k2 thinking PCG#15306

Merged
ispobock merged 1 commit intomainfrom
fix_warp_illegal_instruction
Dec 18, 2025
Merged

Fix warp illegal instruction in kimi k2 thinking PCG#15306
ispobock merged 1 commit intomainfrom
fix_warp_illegal_instruction

Conversation

@BBuf
Copy link
Collaborator

@BBuf BBuf commented Dec 17, 2025

Motivation

The kimi_k2_moe_fused_gate kernels fail to initialize indices_ptr when no valid expert is found (when expert_id is out of bounds or max_expert == -1), leaving uninitialized garbage values that propagate to moe_align_block_size_kernel and cause out-of-bounds memory access in atomicAdd(&shared_counts[expert_id], 1), triggering a "Warp Illegal Instruction" error.

Kimi K2 Thinking piecewise cuda graph

python3 -m sglang.launch_server --model-path moonshotai/Kimi-K2-Thinking --tp 8 --trust-remote-code  --tool-call-parser kimi_k2 --reasoning-parser kimi_k2 --model-loader-extra-config='{"enable_multithread_load": "true","num_threads": 64}' --enable-piecewise-cuda-graph
➜  sglang git:(pcg-marlin-moe) ✗ python3 benchmark/gsm8k/bench_sglang.py --num-questions 1400 --parallel 1400
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 1319/1319 [00:24<00:00, 53.88it/s]
Accuracy: 0.938
Invalid: 0.001
Latency: 24.583 s
Output throughput: 5294.458 token/s

Kimi K2 Thinking without piecewise cuda graph

python3 -m sglang.launch_server --model-path moonshotai/Kimi-K2-Thinking --tp 8 --trust-remote-code  --tool-call-parser kimi_k2 --reasoning-parser kimi_k2 --model-loader-extra-config='{"enable_multithread_load": "true","num_threads": 64}' 
➜  sglang git:(pcg-marlin-moe) ✗ python3 benchmark/gsm8k/bench_sglang.py --num-questions 1400 --parallel 1400
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 1319/1319 [00:24<00:00, 54.09it/s]
Accuracy: 0.941
Invalid: 0.001
Latency: 24.558 s
Output throughput: 5289.763 token/s

Kimi K2 Thinking EP

python3 -m sglang.launch_server --model-path moonshotai/Kimi-K2-Thinking --tp 8 --ep 4 --trust-remote-code  --tool-call-parser kimi_k2 --reasoning-parser kimi_k2 --model-loader-extra-config='{"enable_multithread_load": "true","num_threads": 64}'
➜  sglang git:(pcg-marlin-moe) ✗ python3 benchmark/gsm8k/bench_sglang.py --num-questions 1400 --parallel 1400
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 1319/1319 [00:23<00:00, 55.14it/s]
Accuracy: 0.939
Invalid: 0.000
Latency: 24.119 s
Output throughput: 5519.985 token/s

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@ispobock
Copy link
Collaborator

/tag-and-rerun-ci

@ispobock ispobock merged commit 56d12b4 into main Dec 18, 2025
181 of 196 checks passed
@ispobock ispobock deleted the fix_warp_illegal_instruction branch December 18, 2025 08:58
Liwansi added a commit to iforgetmyname/sglang that referenced this pull request Dec 19, 2025
…n3_pp

* 'main' of https://github.com/sgl-project/sglang: (74 commits)
  [bug fix][pp] fix inconsistent latency between tp (sgl-project#15379)
  Fix warp illegal instruction in kimi k2 thinking PCG (sgl-project#15306)
  Fix gpt-oss yarn with `truncate` argument (sgl-project#14270)
  Monkey patch deepseek-ocr's `v_head_dim` (sgl-project#15384)
  [model-gateway] Replace PolicyRegistry RwLock with DashMap for lock-free policy lookups (sgl-project#15361)
  [PP] Fix dynamic chunking strategy for PP (sgl-project#15372)
  Fix issue: ENABLE_BELOW_SM90 cannot be enabled on aarch64 CPU (sgl-project#12967)
  Split test_piecewise_cuda_graph.py to optimize CI resource usage (sgl-project#15290)
  unified management of environment variables for vlm cuda ipc transport  (sgl-project#14501)
  Mistral Large 3 NVFP4 TRTLLM MoE support (sgl-project#15049)
  fix: adjust time for test_epd_disaggregation.py (sgl-project#15354)
  Add doc for qwen3 next (sgl-project#15337)
  feat: DeepSeek-V3.2 Streaming tool call output (sgl-project#15278)
  Feature/trtllm mha workspace size configurable sgl-project#15089 (sgl-project#15131)
  [VLM] Support cos sin cache for Qwen3-VL & GLM-4.1V (sgl-project#15205)
  [Deepseek V3.2] Support Overlap Spec + NSA (sgl-project#15307)
  Add request-level timestamp for when prefill finishes (sgl-project#14860)
  [CI] Migrate LoRA tests to test/registered/lora/ (sgl-project#15176)
  Reserve more memory for DeepSeekOCR model and adjust server start timeout for DeepGEMM to reduce flakiness (sgl-project#15277)
  Fix condition check for require_gathered_buffer (sgl-project#15328)
  ...
Prozac614 pushed a commit to Prozac614/sglang that referenced this pull request Dec 23, 2025
jiaming1130 pushed a commit to zhuyijie88/sglang that referenced this pull request Dec 25, 2025
YChange01 pushed a commit to YChange01/sglang that referenced this pull request Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants