Systems · LLM Inference & RL Infra · MTT S5000
Dissecting MTT S5000
Hardware roofline, multi-stream overlap laws, custom mp_31 MoE/HiCache/Training kernels, PCIe Gen5 KV offloading, MUSA 5.2.0 MT-DeepEP & Mooncake IPC, and native VMM RL sleep-mode on 8× Moore Threads S5000.
系统 · 大模型推理与强化学习基建 · MTT S5000
解剖摩尔线程 MTT S5000
微架构实测、多流重叠法则、自研 mp_31 推理/HiCache/训练算子、PCIe Gen5 KV 引擎、MUSA 5.2.0 MT-DeepEP 与 Mooncake IPC,以及原生 VMM 强化学习休眠分配器。
Systems · LLM Inference & RL Infra · MTT S5000
Dissecting MTT S5000
Hardware roofline, multi-stream overlap laws, custom mp_31 MoE/HiCache/Training kernels, PCIe Gen5 KV offloading, MUSA 5.2.0 MT-DeepEP & Mooncake IPC, and native VMM RL sleep-mode on 8× Moore Threads S5000.
Porting NVIDIA inference wisdom verbatim onto non-CUDA silicon fails in predictable ways: you either optimize kernels the vendor already solved, or you import concurrency tricks that run slower than serial execution. Before writing a single line of kernel code on an 8× Moore Threads MTT S5000 (PH100, 4th-gen MUSA mp_31) server, we audited mate 0.2.7, vllm-musa 0.1.24, and sglang-musa from source so we would not re-invent deep_gemm, flash_attn_3, or flash_mla.
What remained was a clear hardware-first engineering gap: no public reproducible roofline for mp_31, no empirical boundary for compute–communication overlap, three silent production killers inside vLLM-MUSA on deep MoE models, and broken or missing building blocks for mp_31 MoE glue kernels, PCIe Gen5 KV offloading, and MUSA 5.2.0 MT-DeepEP. We measured every claim on real silicon, fixed or built each layer from scratch, and open-sourced the full suite at github.com/spyzss/s5000-infra.

End-to-end 8×S5000 decode throughput on real Qwen3-30B-A3B-FP8 weights (48 layers, 128 experts, Top-8, TP8+EP8, warm-cache back-to-back A/B). Left: fixing MUSA Graph-Cap thrashing recovers 8.0×–29.5× over stock defaults, and hooking our bit-exact custom mp_31 MoE fusion kernels adds another +3.5% to +13.3% across BS=1–64 (peaking at 2,750.2 tok/s at BS=64 and 3,184.5 out / 19,284 total tok/s at BS=128). Right: cold start drops 10.7× (832.8s → 77.6s), graph capture 32.8× (655s → 20s), and graph VRAM >6× (11.7 → <2 GiB/GPU).
TL;DR
- Fix the graph cap before touching kernels: Any model with ≥37 layers exceeds MUSA's ~1,900 live graph-exec cap under default
vLLM-MUSApiecewise capture (48 × 51 + 51 = 2,499), triggering an 11-minute cold start and a 27× decode collapse. AFULL_DECODE_ONLYgeometric budget plus an FX metadata fix forfuse_allreduce_rms—both auto-hooked at runtime viapip install -e .+S5000_OPT_ENABLE=1—restores full speed and frees 64+ GiB VRAM per node.- Overlap on S5000 follows a strict resource boundary: Off-chip PCIe Gen5 DMA overlaps FP8 GEMM/FA3 at +89.4% to ~100%. Intra-node
MCCL + mate/deep_gemmsuffers -96.6% to -192.9% negative overlap becausedeep_gemm.set_num_smsis a no-op and floods all 56 MPs and the shared 60 MB L2. Enforcing strict SM disjointness (MT-DeepEP 16 SM + Triton GEMM 40 SM) flips intra-node overlap to +87.4% (1.50×).- Custom
mp_31MoE & DeepGEMM glue kernels move real 8-GPU serving numbers without losing bit-exactness:vllm::silu_and_mul_per_block_quantconsumed 6.44% of total GPU time in MUPTI. Five hand-writtenmp_31MUSA C++ kernels (eliminating int64 division, exact cancellation-free(g*u)/(1+expf(-g))FP8 quantization with 0 differing bytes across all finite BF16/FP16 patterns and 0/42.5M live prefill bytes, single-pass Add+RMSNorm+FP8 quant, and mask-safe Ballot-Argmaxtopk_softmax/grouped_topk) deliver 1.67×–28.1× op speedups (3.70×–3.98× onmusa_fused_add_rms_deepgemm_fp8_opatH=2048/7168) and +3.5% to +13.3% (BS=1..64) live 8×S5000 end-to-end throughput viaS5000_OPT_ENABLE=1.- Close the two missing ecosystem engines (
musa_kvcacheio+ MUSA 5.2.0MT-DeepEP): Staging scattered KV pages (≤512 KiB) through multi-GPUMusaDeviceGuard-safe, stream-synchronized GPUuint4gather/scatter pools (0/96 concurrent duplex D2H+H2D errors, 0 byte diffs across concurrent 2-GPU transfers) speeds upvLLM's 48-layer per-layerOffloadingHandlerby 12.9×–18.3× D2H / 4.3× H2D (and cuts 64K async prefetch TTFT by 23.2× with 24× less VRAM). RebuildingMT-DeepEPagainst MUSA 5.2.0 passes 40/40 official tests and beats 8-GPU MCCL by 1.70×–2.67× at decode (T ≤ 128).- Turn one 8×S5000 machine into a complete drop-in AI stack (
SGLang,MooncakeIPC, VMMsleep_mode,VeOmnitraining, ands5000-opt doctor/profile): Beyond 8-GPUvLLM,S5000_OPT_ENABLE=1unlocks post-grad BF16 FP8 DeepGEMM fusions across all Dense & MoE models (1.77×–2.27× onadd_rms_deepgemm, saving 7.3 GiB on single-GPU TP1), repairsSGLangmp_31HiCache (260.5 ms warm host restore, 100% greedy match), adds offset- & epoch-safeMooncakeMUSA 5.2MT2IPC (29.14 GB/s write / 37.56 GB/s read, 6.0×–6.4× batch speedup), implements native MUSA VMMCuMemAllocatorfor RLsleep_mode(98.62–98.78 GiB freed onTP=2, 1.04s / 370 ms wake, 0 graph recaptures), and shipsVeOmni/PyTorch training kernels (1.09×–1.70× SwiGLU, 3.98×–5.82× Vision RoPE beatingmuDNNup to 1.25×, and 2.08×–2.55×MATEMUBIN MoE Grouped GEMM).
Question Map
| # | Status | Question | Answer / Finding |
|---|---|---|---|
| Q1 | Answered | What does MTT S5000 (mp_31) actually look like under roofline and MTLink microbenchmarks? |
56 MPs, 60 MB L2 (3,006 GB/s), 1,335 GB/s HBM, 694.5 TFLOPS FP8, 8.27× eager-vs-graph launch cliff, 35.6 GB/s PyTorch copy_ trap vs. 321 GB/s MCCL A2A, and a 64 MB CAR-vs-MCCL crossover. |
| Q2 | Answered | Why does naive multi-stream overlap run slower on S5000, and can we break that curse? | deep_gemm.set_num_sms is a no-op and thrashes 60 MB L2 (-96.6%). PCIe DMA gives +89.4%, and SM-disjoint MT-DeepEP (16 SM) + Triton GEMM (40 SM) reaches +87.4% (1.50×). |
| Q3 | Answered | What kills production vLLM-MUSA on real 48-layer MoE weights out of the box? |
Three killers: MUSA cap=1900 graph rotation (832.8s start, 11.1 tok/s BS=8; -7.3 GiB saved on 1-GPU TP1 too), a KeyError: 'val' crash in fuse_allreduce_rms, and silent 18–84s cold prefill JIT spikes. |
| Q4 | Answered | After fixing system overhead, can custom mp_31 MoE & post-grad DeepGEMM kernels improve serving? |
Yes: +5.0% (BS=1), +6.9% (BS=32), and +13.3% (BS=64, -3.10 ms/step) warm A/B on 8×S5000 (0/42.5M FP8 byte diffs), plus 1.77×–2.27× Dense/MoE post-grad add_rms_deepgemm across H ∈ {2048..7168}. |
| Q5 | Answered | Can we turn S5000's 1 TiB host RAM and MTLink mesh into production KV offload and EP8 engines? | Yes: musa_kvcacheio speeds up ≤512 KiB per-layer vLLM offload up to 18.3× D2H / 4.3× H2D (and 64K TTFT 23.2×); rebuilt MUSA 5.2.0 MT-DeepEP beats 8-GPU MCCL 1.70×–2.67× for T ≤ 128. |
| Q6 | Answered | Can one drop-in toolkit unblock SGLang, Mooncake IPC, RL sleep_mode, VeOmni training, & diagnostics? |
Yes: mp_31 HiCache (260.5 ms warm restore), offset-safe Mooncake MUSA 5.2 IPC (29.1 / 37.6 GB/s), VMM sleep_mode (98.6 GiB freed on TP2, 0 recaptures), VeOmni training ops (1.09×–5.82×), and s5000-opt doctor/profile. |
| Q7 | Planned (Phase 2) | How well does this scale across multiple machines? | Explore how to improve performance when those machines work together over 8× 400Gbps RoCEv2. |
Setup
All single-node measurements ran on one 8× MTT S5000 node (PH100, mp_31, 80 GiB VRAM per GPU = 640 GiB total, 14 MTLink MT2 links up per GPU, 8× 400Gbps ConnectX-7 RoCEv2, dual Intel Xeon Platinum 8558 96C/192T, 1.0 TiB host RAM). Software stack: Driver 5.2.0-server, MUSA Toolkit 5.2.0 (mcc 5.2.0, libmusart.so.5, libmccl 2.11.4, MUPTI 1.3.0), torch 2.11.0.post2, torch_musa 2.11.0.post2, mate 0.2.7, vLLM 0.24.1 (vllm-musa 0.1.24), and mtshmem 3.1.7. Real-weight serving tests used Qwen/Qwen3-30B-A3B-FP8 (48 layers, 128 experts, Top-8, 32 GB FP8 checkpoint).
Code & raw datasets: github.com/spyzss/s5000-infra (Apache-2.0, pip install -e . opt-in autoload + s5000-opt CLI, zero hardcoded paths, 8-stage scripts/verify_phase1.sh).
Full hardware and software baseline record
- Compute/memory microbench:
microbench/01_compute_memory_roofline.py→results/01_roofline.json - Interconnect microbench:
microbench/02_comm_mtlink_bench.py,06_car_vs_mccl_crossover.py→results/02_comm_mtlink.json,results/06_car_vs_mccl_crossover.json - Overlap suite:
microbench/03*.py(03through03f) +benchmarks/track3_deepep/bench_overlap_*.py→results/03_overlap_feasibility.json,results/track3_deepep.json - Real-weight 8×S5000 serving:
microbench/07_real_qwen3_ablation.py,08_vllm_deepep_smoke.py,09_vllm_kv_offload_e2e.py,09b_vllm_offload_handler_microbench.py→results/07_*.json,results/09_*.json - Single-GPU serving, post-grad DeepGEMM fusions & CLI (
doctor/profile):s5000_opt/{doctor,profiler,cli}.py→results/track_a_single_gpu.json SGLangmp_31HiCache &MooncakeMUSA 5.2 IPC/RDMA:benchmarks/track4_sglang_mooncake/bench_sglang_hicache_and_mooncake.py→results/track4_sglang_mooncake.json- MUSA VMM
sleep_mode(TP=1/2) &VeOmnitraining kernels:benchmarks/track5_vmm_and_train/bench_vmm_sleep_and_train_ops.py→results/track5_vmm_and_train.json
Findings
Q1: What does MTT S5000 (mp_31) actually look like under roofline and interconnect probes?
S5000 has healthy HBM bandwidth (1,334.8 GB/s, 83.4% of spec) and strong FP8 compute (694.5 TFLOPS, ridge at M ≈ 256), but punishes eager kernel launches (8.27× cliff), naive PyTorch P2P copies (35.6 GB/s cap), and uncalibrated AllReduce routing.
| Hardware Metric | Spec / Topology | Measured on 8×S5000 | Practical Consequence |
|---|---|---|---|
| Compute & Cache | 56 MPs, 60.0 MB L2, 80 GiB VRAM | L2 3,006.4 GB/s (≤60 MB); HBM 1,334.8 GB/s |
Working sets >60 MB drop straight to 1,328 GB/s; L2 is the main contention surface. |
| GEMM Roofline | 1,000 TFLOPS FP8 | BF16 379.4 TFLOPS; FP8 DeepGEMM 694.5 TFLOPS |
FP8 ridge sits at M ≈ 256; M = 1 → 128 takes only 35 → 42 μs. |
| Launch Overhead | MUSA 5.2.0 runtime | Eager 16.04 μs/op vs. MUSA Graph 1.94 μs/op |
8.27× cliff: any graph break in decode creates immediate CPU-launch bubbles. |
MTLink MT2 Mesh |
14 links/GPU (7 peers × 2) | PyTorch copy_: 35.6 GB/s (even 7 streams); MCCL A2A: 321.1 GB/s bi-dir |
Never write naive peer copy_ loops; MCCL is 9.0× faster across the mesh. |
| AllReduce Crossover | MusaJitCustomAllreduce vs. MCCL |
CAR 20.1–21.6 μs (128–512 KB) vs. MCCL 144–201 μs (up to 9.5×) |
CAR wins cleanly from 4 KB to 32 MB; crossover sits at 64 MB (728 vs. 745 μs). |
| PCIe Gen5 x16 DMA | 2 async copy engines | Pinned H2D 56.05 GB/s / D2H 56.79 GB/s |
Independent of the 56 MPs and L2—ideal for host KV tiering and RDMA. |
We also tested vllm_musa's hidden VLLM_MUSA_CUSTOM_AR_VECTOR_LOAD=1 knob on all 8 GPUs: it only helps at 1–2 MB (33.7 μs vs. 66.4 μs) while slowing down decode payloads (4 KB–512 KB) by 1.5×–2.7× (32.5–77.5 μs vs. 20.1–28.6 μs), so leaving the default 0 is strictly better for decode.
Microbenchmark details (01_roofline, 02_comm_mtlink, 06_car_vs_mccl)
- L2 bandwidth drops from
3,006.4 GB/s(2 × 32 MB) to1,477 → 1,328 GB/sonce buffers exceed the 60.0 MB L2 capacity. - Thermal steady-state BF16 GEMM (
8192³) settles around311.5 TFLOPSunder the 750W TDP ceiling versus379.4 TFLOPSburst atM = 512. - Raw JSON files:
results/01_roofline.json,results/02_comm_mtlink.json,results/06_car_vs_mccl_crossover.json.
Q2: Why does naive compute–communication overlap regress on S5000, and how do we break it?
Blindly overlapping stock mate/deep_gemm or FA3 with intra-node MCCL slows execution down by 32%–49% (-96.6% to -111.0% efficiency). The root cause is twofold: deep_gemm.set_num_sms(N) is a no-op on S5000 (flooding all 56 MPs), and heavy Tensor-Core ops thrash the shared 60 MB L2 against SM-driven MCCL. Enforcing true SM disjointness (MT-DeepEP 16 SM + Triton GEMM 40 SM) flips overlap to +87.4% (1.50×).

Overlap efficiency across 8 controlled experiments on MTT S5000. Positive bars hide communication behind compute; negative bars run strictly slower than serial execution.
This splits S5000 multi-stream concurrency into three concrete regimes:
- Off-chip PCIe Gen5 DMA + heavy compute (
+89.4%to~100%,1.81×): Independent copy engines bypass both the 56 MPs and L2. This directly powers Track 2 (musa_kvcacheio). - SM-disjoint
MT-DeepEP Normal+ SM-capped compute (+76.2%to+87.4%,1.50×): When we verified whydeep_gemm.set_num_sms(8)still hung or degraded againstMT-DeepEP, we foundMoE_Grouped_FP8ran in364 μsat 56 SMs and369 μsat 8 SMs—mate.set_num_mpsdoes not actually cap the launched grid. Switching compute to a persistent Triton GEMM that strictly occupies56 - ep_smsMPs immediately unlocked+87.4%overlap (1,495.5 → 994.0 μs,1.50×) vs. MCCL's+45.3%on the exact same GEMM. - Uncapped
mate/deep_gemm+ intra-node MCCL (-96.6%to-192.9%): Even leaving 36/56 MPs idle in a persistent GEMM still regressed-192.9%against MCCL (0.74×) due to L2 and memory-pipeline contention, and tuningMCCL_ACE_LARGE_SIZE_THRESHOLD=0orMCCL_MAX_NCHANNELS=4did not rescue it.
Overlap experiment record (03*.py and track3_deepep.json)
FP8 GEMM (4K) + PCIe Pinned H2D (32 MB): serial1.206 ms→ concurrent0.667 ms(1.81×,+89.4%).MT-DeepEP Normal_CombBF16 (16 SM) + Triton Persistent GEMM (40 SM): serial1,495.5 μs→ concurrent994.0 μs(1.50×,+87.4%).MT-DeepEP Normal_DispFP8 (8 SM) + Triton Persistent GEMM (48 SM): serial2,243.7 μs→ concurrent1,872.8 μs(1.20×,+76.2%).MT-DeepEP Low-Latencyuses 1,024-thread blocks with intra-GPU grid barriers and cross-GPU spin-wait; 2-stream overlap against uncapped 56-SM GEMM deadlocks onasync_finish=Trueor degrades, whereas DualPipe hook hiding (send → GEMM → recv_hook) yields a clean+14.8%(1.07×).- Raw records:
results/03_overlap_feasibility.json,results/track3_deepep.json.
Q3: What breaks production vLLM-MUSA on real 48-layer MoE weights out of the box?
Three non-obvious system bugs dominate before any kernel optimization matters: a MUSA live graph cap (~1,900) that thrashes every ≥37-layer model, an FX metadata bug crashing fuse_allreduce_rms=True, and unlogged 18–84s cold prefill shape JIT compilations.
- MUSA Graph-Cap (
cap=1900) rotation (patches/0002+s5000_opt/graph_budget.py): DefaultvLLM-MUSAcaptures 51 piecewise sizes plus 51 full graphs. On a 48-layer model (Qwen3-30B-A3B), , triggeringtorchada graph-exec rotation:655scapture,832.8scold start,11.72 GiB/GPUgraph VRAM, and online decode collapse (BS=1:6.8 tok/s,BS=8:11.1 tok/s—slower thanBS=32!). Auto-budgetingMUSAPlatformBase.apply_config_platform_defaultstoFULL_DECODE_ONLYwith geometric capture sizes (strictly enforcingestimate_musa_graphs(...) <= safe_cap) cuts capture to20s(32.8×), cold start to76.4s(10.9×), frees9.7 GiB/GPU(+77 GiB/node), and preserves native MUSAfused_add_rms_normpriority instead of Piecewise mode's forcedVLLM_MUSA_CUSTOM_OP_USE_NATIVE=1fallback. - Upstream
fuse_allreduce_rmscrash (patches/0001+ runtime guard): MUPTI showedAllReduce + fused_add_rms_normtaking ~18% of decode GPU time, yet enablingfuse_allreduce_rms=TruecrashedVllmIRLoweringPasswithInductorError: KeyError: 'val'. Root cause:_manual_rewrite_residual_musa_jit_car_rmsnorminvllm_musa/_inductor/musa_allreduce_rms_fusion.pyomittednode.meta["val"]on newly inserted FX nodes. Propagating fake-tensor metadata across both rewrite paths (and auto-repairing unpatchedvllm-musaat runtime underS5000_OPT_ENABLE=1) fixes compilation cleanly and yields +2.1% to +3.3% steady-state gain. - Silent first-prefill JIT cliff (
scripts/warmup_prefill_shapes.py): Even afterDeepGEMM warmup: 746/746and zero Tritonjit_monitorwarnings, the first unseen prefill length (BS=8, 5,168 tokens) silently compiles for18–84sbefore settling to3.26swarm. Bucketed pre-traffic warmup removes the tail spike completely.
2×2 ablation record on real Qwen3-30B-A3B-FP8 (8×S5000 TP8+EP8)
- Stock Default (51 sizes,
cap=1900thrashing): init832.8s(capture655s),11.72 GiBVRAM,BS=1:6.8 tok/s,BS=8:11.1 tok/s. - Opt A (
FULL_AND_PIECEWISE12 sizes, no AR+RMS): init84.8s,3.75 GiB,BS=1:51.3,BS=8:314.1,BS=32:1,067.6,BS=64:2,335.3,BS=128:3,183.7 tok/s. - Opt B (
FULL_AND_PIECEWISE12 sizes + fixedfuse_ar_rms):BS=32:1,090.2 (+2.1%),BS=64:2,412.6 (+3.3%),BS=128:3,231.4 (+1.5%). - Opt D (
FULL_DECODE_ONLY12 sizes + fixedfuse_ar_rms, warm control): init77.5s,<2 GiB,BS=1:51.6,BS=8:316.1,BS=32:1,332.0(+22% over Piecewise),BS=64:2,427.4,BS=128:3,179.6 tok/s. - Raw files:
results/07_real_*.json,results/vllm_qwen3_tp8_mupti/profiler_out_0.txt.
Q4: After system fixes, can custom mp_31 MoE fusion kernels move real 8-GPU serving numbers?
Yes. MUPTI revealed that vllm::silu_and_mul_per_block_quant alone took 6.44% of total GPU time (8.10% including the colmajor Triton path). Replacing MoE and DeepGEMM glue bottlenecks with five bit-exact, hand-tuned mp_31 MUSA C++ kernels adds another +3.5% to +13.3% end-to-end throughput (BS=1..64) on 8×S5000.

Left: fused_silu_mul_fp8_block_quant speedup over vllm::_C.silu_and_mul_per_block_quant under MUSA Graph replay (1.67× → 28.1×, peaking at 1,007.8 GB/s, 0 differing FP8 bytes / scales). Right: combined 48-layer Qwen3-30B-A3B MoE glue latency per layer (1.89× at BS=8, 2.56× at BS=32, 4.23× at BS=128).
Writing native MUSA C++ (mcc --offload-arch=mp_31 + tvm_ffi) surfaced three architecture-specific mp_31 rules—plus an important numerical-exactness lesson caught during independent audit:
- Eliminate non-power-of-2
int64division: Moving from 1D flattened modulo indexing to 2D grid tiling doubled effective memory bandwidth (538 → 1,287 GB/s). - Avoid
tanhf(0.5f * x)and-ffast-mathfor FP8 SiLU despite SFU shortcuts: Our initial prototype followed vendor kernels in using0.5*g*(1 + tanhf(0.5*g)), which hadcos = 0.99999994on standard Gaussian inputs—yet suffered catastrophic cancellation on negative gates (g ∈ [-30, -5], causing 27.6% FP8 byte divergence on extreme activations) and flipped greedy token #2 onQwen3-30B-A3B-FP8. Compiling without-ffast-mathand using cancellation-free(g * u) / (1.0f + expf(-g))(matching Triton'sexp2f(-g * kLog2E)onnarrow_silu_mul=Trueforcolmajorue8m0=False/True,min_scaling_factor = 1/(448*512), andscale_ubclamped ongroup_scale) achieves 0 differing FP8 bytes & 0 differing FP32 scale bits across all 65,280 finite BF16 patterns, all 63,488 finite FP16 patterns, and4096×1536random FP16/BF16 sweeps (0 / 42.5Mdiffering FP8 bytes on live 8-rank × 48-layer prefill;results/07_real_full_arrms1_phase15.jsonmatches07_real_full_decode_ar_rms_fused.jsonacross the first 52 greedy TP8+EP8 tokens before diverging at token 53, whereas repeated unpatched TP8+EP8 runs themselves diverge across runs—e.g. at token 5 between07_real_full_arrms1_ctrl_warm.jsonand07_real_full_decode_ar_rms_fused.json, and at token 54 across back-to-back single-prompt audit runs) while keeping 28.1× speedup overvllm::_Cand full +13.3% BS=64 E2E gain. - Mask-safe Ballot-Argmax (
__ballot_sync/__ffs) for Top-K & Grouped Top-K routing: Replaces(val, idx)warp butterflies using an available-slot bitmask (compiled without-ffinite-math-onlyso-inf/NaNmasked experts never produce duplicate IDs), generalizesfused_topk_softmax_renormtoE ∈ {8, 16, 32, 64, 128, 256}andK ∈ {1, 2, 4, 6, 8}, adds MUSA-Graph-safefused_grouped_topk(E ∈ {128, 256},sigmoid/softmax+correction_bias) for DeepSeek-V3/R1 and Qwen3.5 MoE, and fusestopk + renorm + moe_align_block_size(E=128, K=8) into a single CTA (1.62×–1.86×Graph,3.41×–5.12×Eager).
Wired into all 8 vLLM-MUSA workers via our zero-touch hook (S5000_OPT_ENABLE=1, s5000_opt/vllm_patch.py), real back-to-back warm A/B serving on Qwen3-30B-A3B-FP8 improves monotonically across all batch sizes:
| Batch Size | Phase 1 Warm Control | Phase 1.5 (+ mp_31 MoE Kernels) |
Warm A/B Gain | Step Latency Saved |
|---|---|---|---|---|
BS = 1 |
51.6 tok/s (19.38 ms) |
54.2 tok/s (18.45 ms) |
+5.0% (8.0× vs. stock) |
-0.93 ms/step |
BS = 8 |
316.1 tok/s (25.31 ms) |
327.3 tok/s (24.44 ms) |
+3.5% (29.5× vs. stock) |
-0.87 ms/step |
BS = 32 |
1,332.0 tok/s (24.02 ms) |
1,424.1 tok/s (22.47 ms) |
+6.9% | -1.55 ms/step |
BS = 64 |
2,427.4 tok/s (26.37 ms) |
2,750.2 tok/s (23.27 ms) |
+13.3% | -3.10 ms/step |
BS = 128 |
3,179.6 tok/s (40.26 ms) |
3,184.5 tok/s (40.20 ms) |
+0.2% (19,284 total tok/s) |
-0.06 ms/step |
Per-kernel verification and benchmark record (track1_moe_fusion.json)
fused_moe_weighted_sum:2.29×–3.71×vs. weightedtorch.sum(2.78×–3.07×at decodeBS=8..32),1.14×–1.15×vs.vllm_musafast sum, up to1,822.8 GB/s, bit-exact under MUSA Graph.fused_silu_mul_fp8_block_quant:1.74×–19.53×(N=768) up to28.10×(N=2048,1,007.8 GB/s) vs.vllm::_C,1.09×–1.18×faster onmusa_silu_deepgemm_fp8_op, and1.38×–1.41×lower eager latency thanvllm_musa'sjit_quant_v2atM ≤ 256(automatically delegatingM > 256tojit_quant_v2's multi-row-tiled kernel, which leads inside MUSA Graphs atM ≥ 512); 0 differing FP8 bytes and 0 differing FP32 scale bits across all 65,280 finite BF16, 63,488 finite FP16,scale_ub, and Tritoncolmajor(ue8m0=False/True)sweeps, plus0 / 42.5Mdiffering FP8 bytes on live 8-rank × 48-layerQwen3-30B-A3B-FP8.fused_add_rmsnorm_fp8_group_quant:1.50×–1.81×vs.vllm_musaJIT norm+quant (1.75×–4.04×vs._C,1,401.9 GB/s), supporting simultaneous FP8 + BF16 dual output and acceleratingmusa_fused_add_rms_deepgemm_fp8_opby3.70×–3.98×onH=2048/7168and1.11×–1.14×onH=4096.fused_topk_softmax_renorm,fused_topk_renorm_align, &fused_grouped_topk: generalizedE ∈ {8..256}, K ∈ {1..8}topk_softmaxandE ∈ {128, 256}grouped_topkhooked online; single-CTAfused_topk_renorm_align(1.62×–1.86×Graph,12.80–17.68 μs,3.41×–5.12×Eager) provided via library API.
Q5: Can we close S5000's two missing engine pieces: PCIe Gen5 KV offloading and MUSA 5.2.0 MT-DeepEP?
Yes—and both uncover concrete architectural boundaries that determine how to route transfers in production.
Track 2: musa_kvcacheio — Turning 1 TiB Host RAM + PCIe Gen5 into a 23× TTFT Accelerator
MUSA 5.2.0 musaMemcpyBatchAsync does not coalesce scattered descriptors (10–11.8 GB/s), and stock vLLM 0.24.1's SingleDirectionOffloadingHandler drops to 1.81 GB/s D2H / 7.95 GB/s H2D on standard 48-layer per-layer KV caches (8 KB/block, TP8 block_size=16). We built musa_kvcacheio (kernels/musa_kvcacheio/), a pure extern "C" ABI MUSA library (immune to PyTorch C++ ABI drift) that gathers/scatters scattered pages on GPU at 1,319 GB/s (uint4) and moves contiguous slabs over bulk 56 GB/s PCIe Gen5 DMA.

Left: live vLLM 0.24.1 SingleDirectionOffloadingHandler on 48-layer per-layer KV (201.3 MB), showing 12.9×–18.2× D2H and 4.3× H2D gains (bit_exact = True). Right: 48-layer real Qwen3-30B-A3B-FP8 (deep_gemm + FA3) double-buffered async prefetch achieving 6.5× / 12.9× / 23.2× TTFT speedup at 16K / 32K / 64K with 24× less KV VRAM.
Honest boundary caught during live 8×S5000 testing (microbench/09_vllm_kv_offload_e2e.py): when vLLM 0.24.1 uses its FA3 cross-layer packed layout (block_size=64), a single block is already 1.5 MB, so stock bulk DMA already reaches 35.7 / 39.5 GB/s (3.0× steady-state TTFT speedup on evicted 15.3K docs: 450 ms → 149–153 ms). Our vllm_patch.py hook therefore auto-routes unpadded page_bytes < 256 KB → musa_kvcacheio Mode B (with RAII per-GPU MusaDeviceGuards, thread-safe HostThreadPool, and stream-synchronized StagingPools so concurrent multi-GPU and bidirectional D2H+H2D streams never race—verified 0 / 96 duplex corruptions across 32/128/512 pages × 48 layers and 0 byte diffs across 24 paired 2-GPU Subcase B2 iterations; per-layer / PagedAttention / SGLang: 12.9×–18.3× D2H, standalone Mode B up to 51.8–52.2 GB/s) while delegating ≥ 256 KB cross-layer blocks and padded hybrid-attention KV groups → native vLLM transfer with zero regression.
Track 3: Rebuilding MT-DeepEP for MUSA 5.2.0 and the 8×S5000 EP8 Crossover Law
The container's preinstalled deep_ep and mtshmem transports linked legacy libmusart.so.4, failing on import under MUSA 5.2.0. Our 5-file patch (patches/0003-mt-deepep-musa52-build.patch) compiles MooreThreads/MT-DeepEP cleanly against libmusart.so.5 + static libnvshmem_{host,device}.a with guarded single-node P2P (NVSHMEM_IB_ENABLE_IBGDA=0 NVSHMEM_REMOTE_TRANSPORT=none, automatically configured alongside third_party/MT-DeepEP under S5000_OPT_ENABLE=1), passing 24/24 test_intranode.py, 16/16 test_low_latency.py, and booting live 8-GPU vLLM-MUSA (all2all_backend="deepep_low_latency").

8×S5000 full-mesh EP8 combine latency (E=128, K=8) across T = 1..2048. Low-Latency MT-DeepEP dominates decode (T ≤ 128) by 1.70×–2.67× (H=2048) and 1.43×–2.08× (H=7168), while 8-rank MCCL overtakes 20-SM MT-DeepEP Normal at T ≥ 512.
This yields a crisp hybrid EP8 routing policy for 8×S5000:
- Decode (
T ≤ 128):MT-DeepEP Low-Latency(24.7–64.6 μscombine, 1.70×–2.67× faster than MCCL). - Standalone Prefill (
T ≥ 512):MCCL All-to-All(341–417 μsvs.764–777 μsfor 20-SM Normal Mode across 7 peers). - Overlapped Chunked Prefill:
MT-DeepEP Normal (8–16 SM) + SM-disjoint GEMM (40–48 SM)(+76.2% to +87.4% true overlap).
Track 2 & Track 3 reproducibility and verification records
- Track 2 correctness (
kernels/musa_kvcacheio/test_correctness.py): 100%torch.equal=Trueacross Mode A, Mode B (contiguous, host-contig, both-scattered), strided vLLM/SGLang wrappers, and 48-layer 240-handshake async stress test. Raw JSON:results/track2_kvcacheio.json,results/09_handler_48l_ab.json,results/09_kv_offload_*.json. - Track 3 8-GPU EP8 benchmark (
benchmarks/track3_deepep/bench_ep8_fullnode.py):H=2048, T=1LL Disp35.8 μs(2.22×), LL Comb24.7 μs(2.67×);H=7168, T=1LL Disp41.3 μs(1.69×), LL Comb32.8 μs(2.08×). Raw JSON:results/track3_ep8_fullnode.json,results/track3_deepep.json.
Q6: Can one drop-in toolkit unblock single-GPU serving, SGLang, Mooncake IPC, RL sleep_mode, and VeOmni training?
Yes—and adversarial real-silicon auditing uncovered two severe driver-level silent data corruption traps (MUSA 5.2 IPC sub-slice base handles and dirty recycled VMM pages) that any S5000 infrastructure stack must explicitly guard against.

*Left: rebuilt Mooncake MUSA 5.2 MT2 IPC bandwidth—async per-device stream batching plus muMemGetAddressRange_v2 offset resolution speeds up 64×64 KiB slice batches 6.0×–6.4× (9.78 / 10.32 GB/s) and reaches 29.14 GB/s write / 37.56 GB/s read at 32 MiB (0 byte diffs). Right: custom mp_31 post-grad DeepGEMM and VeOmni/PyTorch training operator speedups (1.31×–5.82×).*
When teams receive a fresh 8×S5000 node, they rarely stop at 8-GPU vLLM serving: they run single-GPU TP=1 workloads, SGLang with host-RAM hierarchical KV caching (HiCache), Mooncake KV transfer, co-located RL rollout/training (sleep_mode), and VeOmni multimodal MoE training—nearly all of which fail out of the box due to unmaintained PTX/DLPack assumptions, libmusart.so.4 ABI drift, or missing VMM allocators. We closed all five gaps under the same S5000_OPT_ENABLE=1 autoload hook:
- Single-GPU
TP=1, Full BF16 FP8 Post-Grad Fusions &s5000-opt doctor/profile(results/track_a_single_gpu.json):- Stock
vllm-musarestrictedMusaRMSDeepGemmFusionPassandMusaSiluDeepGemmFusionPassbehind narrow MoE checks and cloned residuals on out-of-place graphs. Adding an out-of-placeresidual_outpointer tofused_rmsnorm_fp8_quant.mu(plus strictrow_major_scales,!e8m0,16Balignment, andPassManager.uuid()cache isolation) unlocks post-grad DeepGEMM fusions across all BF16 FP8mp_31Dense & MoE models:1.77×–2.27×vs. unfused onadd_rms_deepgemmacrossH ∈ {2048, 2560, 4096, 5120, 7168}(including1.02×–1.11×over stock onH=4096) and1.24×–1.41×onsilu_deepgemm. On single-GPUTP=1Qwen3-30B-A3B-FP8, auto-budgeting saves7.3 GiBVRAM (71.8 → 64.5 GiB, init64.1s → 48.6s) while serving71.8 / 459.5 / 1,127.0 / 1,501.8 out tok/s(BS=1/8/32/64), andmusa_kvcacheioextends contiguous-host KV offload up to≤512 KiB(+29%–72%on256–512 KiBpages). s5000-opt doctorinspects MUSA 5.2 libraries, PCIe Gen5 link widths, VMM/DMA-BUF/mt_peermemRoCEv2 readiness, anddeep_ep/mooncakeABIs in one command;s5000-opt profileattributesPrivateUse1MUPTI kernel durations across eager launches vs. graph replays.
- Stock
SGLangmp_31HiCache, Shared Graph-Cap & Offset-SafeMooncakeMUSA 5.2 IPC (patches/0004..0005,results/track4_sglang_mooncake.json):- Upstream
SGLanghicachefailed onmp_31with 20mccerrors from inline CUDA PTXld.global.L1::no_allocateandkDLCUDAchecks, andhost::LaunchKernelomittedmusaSetDevice(crashing withillegal memory accesswhenevermusa:1tensors were launched fromcurrent_device() == 0). Our nativemp_31HiCache kernel (kernels/sglang_hicache/,patches/0004) adds RAIIMusaDeviceGuards + cross-GPU checks, passes 10/10 upstreamtest_hicache.pytests, clamps shared decode/piecewise/speculative graphs tocap=1750, and restores 752 evicted host-RAM tokens on liveQwen3-30B-A3B-FP8in260.5 mswarm (61.4 tok/s, 100% greedy token match; uncachedBS=4:237.9 tok/s). - Silent corruption trap #1 (MUSA 5.2 IPC sub-slices): On MUSA 5.2, calling
musaIpcGetMemHandle(&handle, base + offset)on a PyTorch Caching Allocator sub-tensor exports a handle to the underlyingmusaMallocallocationbase + 0. NaiveNvlinkTransportrelocation droppedoffset, returningrc = 0while silently overwriting Layer 0! Resolving(base_ptr, base_offset)viamuMemGetAddressRange_v2with refcounted handle deduplication, POSIX shm atomic epochs for freed/re-registered buffers, and per-device non-blocking stream batching fixes both corruption classes (0byte diffs) and lifts64 × 64 KiBbatch IPC6.0×–6.4×(1.62 → 9.78 GB/swrite /10.32 GB/sread;32 MiBMT2IPC hits29.14 GB/swrite /37.56 GB/sread alongside 400Gbps RoCEv2 RDMA).
- Upstream
- Native MUSA VMM
sleep_modefor RL &VeOmniTraining Operators (kernels/musa_vmm/,kernels/train_ops/,results/track5_vmm_and_train.json):vllm-musaadvertisesis_sleep_mode_available() -> True, yetvLLM'sCuMemAllocatorfails immediately on MUSA. Even though S5000 supports full driver VMM (VMM_SUPPORTED=1), multi-GPUTP=2P2P (MusaJitCustomAllreduce/ MCCL) faults unlessmuMemSetAccessgrantsPROT_READWRITEacross all peer GPUs—and silent corruption trap #2 appeared on liveTP=2wake:muMemCreatereturned recycled physical VRAM pages containing1.58e8–3.17e8non-zero dirty values per layer into discarded KV caches, whichvllm_musaFlashAttention 3 read into attention output and turned greedy English into gibberish! Asynchronously zeroing (musaMemsetAsync) newly mapped unbacked regions on wake and synchronizing only active MUSA primary contexts (muDevicePrimaryCtxGetState) yields rock-solidTP=2Qwen3-30B-A3B-FP8sleep/wake: Level-1 frees98.62 GiB(49.31 GiB/GPU, wake1.04s) and Level-2 frees98.78 GiB(sleep148 ms, wake370 ms, weight reload19.74s) with 100% greedy token match and0MUSA Graph recaptures.- For
VeOmniand PyTorch training, three nativemp_31autograd operators close key operator gaps: overflow-safefused_swiglu(1.09×–1.70×fwd+bwdacross aligned4096×4096and unaligned1025×1537), 128-bit vectorizedfused_vision_rope_3dsupporting non-contiguousQwen3-VL/Qwen3.5qkv.unbind()views (3.98×–5.82×vs. eager and up to1.25×faster thanVeOmnimuDNN), andMATEMUBINmusa_moe_grouped_gemmwith GPU-resident expert counts (2.08×–2.55×fwd+bwdvs. eager,4.2×–10.7×faster thantorch._grouped_mmon raw primitives).
Takeaways & Phase 2 Roadmap
- Measure hardware invariants before writing kernels: On MTT S5000, the single highest-leverage fix (
cap=1900graph budgeting +fuse_allreduce_rms) was a systems bug worth 10× cold start and 8×–29× latency before touching a line of MUSA C++. - Respect the 60 MB L2 and 56-MP boundaries: Never overlap uncapped
mate/deep_gemmwith intra-node MCCL; reserve overlap for independent PCIe Gen5 DMA (+89.4%–100%) or strictly SM-disjointMT-DeepEP + GEMM(+87.4%). - Verify vendor/driver edge cases adversarially on real multi-GPU silicon: Passing single-GPU unit tests is not enough—MUSA 5.2 IPC sub-slice base handles (
muMemGetAddressRange_v2), missingLaunchKerneldevice guards onmusa:1, and dirty recycledmuMemCreateVMM pages all fail or silently corrupt multi-GPU workloads unless explicitly tested and guarded. - Build drop-in production leverage: Packaging
vLLM,SGLang,MooncakeIPC, VMMsleep_mode,VeOmnitraining kernels, ands5000-opt doctor/profilebehind a single opt-inpip install -e .+S5000_OPT_ENABLE=1autoload hook makes an entire 8×S5000 node productive on day one.
Next, I hope to extend this work to multiple machines and make them work together more efficiently.
Citation
@misc{sheng2026s5000infra,
author = {Sheng, Pingyue},
title = {Dissecting MTT S5000: Hardware Roofline, Overlap Laws, Custom mp\_31 Kernels, and Full-Stack LLM/RL Infrastructure},
year = {2026},
url = {https://ravenembodied-blog.chengpy23.workers.dev/posts/dissecting-mtt-s5000}
}
把 NVIDIA 的大模型推理经验原封不动搬到国产 GPU 上,通常会以两种方式踩空:要么重复卷官方已经写好的基础算子,要么照抄 CUDA 的多流重叠套路,结果越优化越慢。在动手写第一行核函数之前,我们先对这台 8× 摩尔线程 MTT S5000(PH100,第四代 MUSA 平湖架构 mp_31)上的 mate 0.2.7、vllm-musa 0.1.24 和 sglang-musa 做了源码级审计,确认不再重复造 deep_gemm、flash_attn_3 和 flash_mla 的轮子。
真正空缺的是五件硬核工程:全网第一份可复现的 mp_31 微架构与通信画像、S5000 多流计算-通信重叠的真实硬件边界、vLLM-MUSA 在真实深层 MoE 模型上的三大隐蔽生产杀手,以及面向 mp_31 的 MoE 融合核、PCIe Gen5 KV 卸载引擎与 MUSA 5.2.0 MT-DeepEP 重建。我们把每一条结论都在 8 卡真机上跑通实证,并将全部代码、补丁与原始 JSON 数据开源在 github.com/spyzss/s5000-infra。

8×S5000 真实权重 Qwen3-30B-A3B-FP8(48 层、128 专家、Top-8、TP8+EP8,背靠背热缓存 A/B 实测)。左:修复 MUSA Graph-Cap 抖动后相对官方默认恢复 8.0×–29.5×,叠加逐比特精确的自研 mp_31 MoE 融合核后再全 Batch 提速 +3.5% ~ +13.3%(BS=64 达 2,750.2 tok/s,BS=128 达 3,184.5 out / 19,284 total tok/s)。右:冷启动加速 10.7×(832.8s → 77.6s)、Graph 捕获加速 32.8×(655s → 20s)、单卡 Graph 显存压降超 6 倍(11.7 → <2 GiB)。
太长不看
- 写核之前先治图句柄上限:默认
vLLM-MUSA捕获 51 档 Piecewise Graph,所有 ≥37 层模型(48 层 Qwen3-30B 为 )都会撞穿 MUSA 活跃图上限,引发 11 分钟冷启动与 27× 解码崩塌。FULL_DECODE_ONLY几何分桶预算器 +fuse_allreduce_rmsFX 元数据修复(支持pip install -e .+S5000_OPT_ENABLE=1零手工补丁自动生效)直接打满基盘,整机多腾出 64+ GiB KV 显存。- S5000 多流重叠存在清晰的硬件分水岭:片外 PCIe Gen5 DMA 与 FP8 GEMM/FA3 重叠率高达 +89.4% ~ ~100%;机内
MCCL + mate/deep_gemm则是 -96.6% ~ -192.9% 负重叠(根因是deep_gemm.set_num_sms为空操作,洪泛 56 MP 并争用 60 MB 共享 L2)。严格执行 SM 互斥(MT-DeepEP 16 SM + Triton GEMM 40 SM)后,机内重叠一举翻正至 +87.4%(1.50×)。- 自研
mp_31MoE 与 DeepGEMM 融合核在不牺牲逐比特精度的前提下拉动 8 卡端到端吞吐:MUPTI剖面显示vllm::silu_and_mul_per_block_quant单算子就吃掉整机 GPU 时间的 6.44%。5 个手写mp_31MUSA C++ 融合核(消除 int64 除法、无灾难相消的精确(g*u)/(1+expf(-g))FP8 量化且遍历全量有限 BF16/FP16 零位差 + 8 卡 48 层真机前向 0/42.5M 字节差异、单趟 Add+RMSNorm+FP8 量化、掩码安全的广谱 Ballot-Argmaxtopk_softmax/grouped_topk)实现 1.67×–28.1× 单算子提速(musa_fused_add_rms_deepgemm_fp8_op在H=2048/7168提速 3.70×–3.98×),通过S5000_OPT_ENABLE=1接入 8 卡vLLM-MUSA在BS=1..64带来 +3.5% ~ +13.3% 真实端到端净收益。- 补齐两块生态底层拼图(
musa_kvcacheio+ MUSA 5.2.0MT-DeepEP):用具备多卡MusaDeviceGuard与跨流同步的 GPUuint4Gather/Scatter 缓冲池(双向并发 D2H+H2D 实测 0/96 串写,双卡并发 B2 零字节差异)+ 单次 56 GB/s 连续 DMA 接入vLLM≤512 KiB逐层OffloadingHandler,实现最高 18.3× D2H / 4.3× H2D 提速(64K 异步预取 TTFT 加速 23.2×、显存省 24×);MUSA 5.2.0 源码重建的MT-DeepEP通过官方 40/40 用例,8 卡 Decode(T ≤ 128)比 MCCL 快 1.70×–2.67×。- 把一台 8×S5000 打造成开箱即用的全栈推理/RL/训练底座(
SGLang、MooncakeIPC、VMMsleep_mode、VeOmni训练算子与s5000-opt doctor/profile):同一个S5000_OPT_ENABLE=1自动钩子进一步打通全模型 BF16 FP8 Post-Grad DeepGEMM 融合(add_rms_deepgemm提速 1.77×–2.27×,单卡 TP1 省 7.3 GiB 显存)、修复SGLangmp_31HiCache(热恢复 260.5 ms,贪婪输出 100% 一致)、构建支持子切片偏移与原子纪元失效的MooncakeMUSA 5.2MT2IPC(32 MiB29.14 GB/s 写 / 37.56 GB/s 读,小切片批传输提速 6.0×–6.4×)、补齐原生 MUSA VMMCuMemAllocator打通vLLMRLsleep_mode(TP=2释放 98.62–98.78 GiB,唤醒 1.04s / 370 ms,0 次图重捕获),并提供VeOmni/PyTorch 训练核(SwiGLU1.09×–1.70×、Vision RoPE较 eager 快 3.98×–5.82× 且反超muDNN达 1.25×、MATEMUBINMoE Grouped GEMM2.08×–2.55×)。
问题地图
| # | 状态 | 问题 | 回答 / 结论 |
|---|---|---|---|
| Q1 | 已有结论 | MTT S5000 (mp_31) 的微架构、显存与 MTLink 真实画像是什么? |
56 MP、60 MB L2(3,006 GB/s)、1,335 GB/s 显存、694.5 TFLOPS FP8、8.27× 启动悬崖、PyTorch copy_ 35.6 GB/s 陷阱 vs. MCCL 321 GB/s,以及 64 MB CAR/MCCL 拐点。 |
| Q2 | 已有结论 | 为什么 S5000 机内多流重叠会越叠越慢?能不能打破负重叠魔咒? | deep_gemm.set_num_sms 是空操作且争用 60 MB L2(-96.6%)。片外 PCIe DMA 达 +89.4%,严格 SM 互斥的 MT-DeepEP (16 SM) + Triton GEMM (40 SM) 达 +87.4%(1.50×)。 |
| Q3 | 已有结论 | 官方默认 vLLM-MUSA 跑 48 层真实 MoE 模型时,哪三个隐蔽杀手最致命? |
MUSA cap=1900 图轮换抖动(832.8s 启动、BS=8 仅 11.1 tok/s;单卡 TP1 同样多占 7.3 GiB)、fuse_allreduce_rms 报 KeyError: 'val' 崩溃、首次未缓存 Prefill 静默 JIT 编译 18–84 秒。 |
| Q4 | 已有结论 | 修完系统瓶颈后,手写 mp_31 MoE 与 Post-Grad DeepGEMM 融合核还能继续提速吗? |
能:8 卡真实推理再提 +5.0% (BS=1)、+6.9% (BS=32)、+13.3% (BS=64,省 3.10 ms/step)(0/42.5M 字节差异),全系 Dense/MoE add_rms_deepgemm 提速 1.77×–2.27×。 |
| Q5 | 已有结论 | 怎样把 S5000 的 1 TiB 主存与 MTLink 全互联变成可用的 KV 卸载与 EP8 引擎? | musa_kvcacheio 让 ≤512 KiB 逐层 vLLM 卸载最高提速 18.3× D2H / 4.3× H2D(64K TTFT 23.2×);重建的 MT-DeepEP 在 8 卡 T ≤ 128 比 MCCL 快 1.70×–2.67×。 |
| Q6 | 已有结论 | 能否用一个零侵入包一次性打通 SGLang、Mooncake IPC、RL sleep_mode、VeOmni 训练与诊断 CLI? |
能:mp_31 HiCache(热恢复 260.5 ms)、子切片安全的 Mooncake MUSA 5.2 IPC(29.1 / 37.6 GB/s)、VMM sleep_mode(TP=2 释放 98.6 GiB、0 重捕获)、VeOmni 训练核(1.09×–5.82×)与 s5000-opt doctor/profile。 |
| Q7 | 计划中(Phase 2) | 这项工作扩展到多台机器后,性能会怎样? | 下一步基于 8× 400Gbps RoCEv2 研究多机 EP16/32 与 PD 分离的协同效率。 |
实验设置
所有单机测试均在一台 8× MTT S5000 节点上完成(PH100、mp_31、单卡 80 GiB / 整机 640 GiB 显存、单卡 14 条 MTLink MT2 全 UP、8× 400Gbps ConnectX-7 RoCEv2、双路 Intel Xeon Platinum 8558 96C/192T、1.0 TiB 主机内存)。软件底座:Driver 5.2.0-server、MUSA Toolkit 5.2.0(mcc 5.2.0、libmusart.so.5、libmccl 2.11.4、MUPTI 1.3.0)、torch 2.11.0.post2、torch_musa 2.11.0.post2、mate 0.2.7、vLLM 0.24.1(vllm-musa 0.1.24)与 mtshmem 3.1.7。真实权重端到端评测统一使用 Qwen/Qwen3-30B-A3B-FP8(48 层、128 专家、Top-8、32 GB 真实 FP8 权重)。
开源代码与原始数据:github.com/spyzss/s5000-infra(Apache-2.0,支持 pip install -e . 按需自动加载与 s5000-opt CLI、零硬编码路径、8 阶段 scripts/verify_phase1.sh 一键复验)。
完整软硬件基线与产物映射
- 算力与访存 Roofline:
microbench/01_compute_memory_roofline.py→results/01_roofline.json - 机内互联与 AllReduce:
microbench/02_comm_mtlink_bench.py、06_car_vs_mccl_crossover.py→results/02_comm_mtlink.json、results/06_car_vs_mccl_crossover.json - 多流重叠控制变量:
microbench/03*.py(03–03f)+benchmarks/track3_deepep/bench_overlap_*.py→results/03_overlap_feasibility.json、results/track3_deepep.json - 真实权重 8 卡端到端:
microbench/07_real_qwen3_ablation.py、08_vllm_deepep_smoke.py、09_vllm_kv_offload_e2e.py、09b_vllm_offload_handler_microbench.py→results/07_*.json、results/09_*.json - 单卡服务、Post-Grad DeepGEMM 融合与诊断 CLI(
doctor/profile):s5000_opt/{doctor,profiler,cli}.py→results/track_a_single_gpu.json SGLangmp_31HiCache 与MooncakeMUSA 5.2 IPC/RDMA:benchmarks/track4_sglang_mooncake/bench_sglang_hicache_and_mooncake.py→results/track4_sglang_mooncake.json- MUSA VMM
sleep_mode(TP=1/2)与VeOmni训练算子:benchmarks/track5_vmm_and_train/bench_vmm_sleep_and_train_ops.py→results/track5_vmm_and_train.json
实验与发现
Q1:MTT S5000 (mp_31) 的微架构、访存与 MTLink 真实表现如何?
S5000 的显存带宽利用率很健康(1,334.8 GB/s,达标称 83.4%),FP8 算力扎实(694.5 TFLOPS,拐点在 M ≈ 256),但对三件事惩罚极重:Eager 启动开销(8.27× 悬崖)、PyTorch 原生 P2P 拷贝(卡死 35.6 GB/s),以及未按包长分流的 AllReduce。
| 硬件维度 | 标称 / 拓扑 | 8×S5000 实测 | 工程含义 |
|---|---|---|---|
| 计算单元与缓存 | 56 MPs、60.0 MB L2、80 GiB VRAM | L2 3,006.4 GB/s(≤60 MB);HBM 1,334.8 GB/s |
工作集超过 60 MB 立刻掉回 1,328 GB/s,L2 是并发争用的主战场。 |
| GEMM Roofline | 1,000 TFLOPS FP8 | BF16 379.4 TFLOPS;FP8 DeepGEMM 694.5 TFLOPS |
FP8 Ridge 在 M ≈ 256;M = 1 → 128 耗时仅 35 → 42 μs。 |
| Kernel 启动悬崖 | MUSA 5.2.0 Runtime | Eager 16.04 μs/op vs. MUSA Graph 1.94 μs/op |
8.27× 落差:Decode 阶段任何断图都会制造严重的启动气泡。 |
MTLink MT2 全互联 |
单卡 14 链路(7 对端 × 2) | PyTorch copy_ 仅 35.6 GB/s(开 7 流仍串行);MCCL A2A 321.1 GB/s 双向 |
严禁手写对端 copy_ 循环;走 MCCL 才能吃满 Full-Mesh(9.0×)。 |
| AllReduce 拐点 | MusaJitCustomAllreduce vs. MCCL |
CAR 20.1–21.6 μs(128–512 KB)vs. MCCL 144–201 μs(最高 9.5×) |
4 KB–32 MB 全面由 CAR 统治,拐点在 64 MB(728 vs. 745 μs)。 |
| PCIe Gen5 x16 DMA | 2 个独立异步拷贝引擎 | Pinned H2D 56.05 GB/s / D2H 56.79 GB/s |
独立于 56 MP 与 L2,天然适合做主存 KV 卸载与跨机 RDMA。 |
我们还实测了 vllm_musa 隐藏的 VLLM_MUSA_CUSTOM_AR_VECTOR_LOAD=1 开关:它只在 1–2 MB 更快(33.7 μs vs. 66.4 μs),但在 Decode 核心区间(4 KB–512 KB)反慢 1.5×–2.7×(32.5–77.5 μs vs. 20.1–28.6 μs),因此保持默认 0 是对的。
微基准实验记录(01_roofline、02_comm_mtlink、06_car_vs_mccl)
- L2 有效带宽在
2 × 32 MB驻留区间达3,006.4 GB/s,超出 60.0 MB 后回落至1,477 → 1,328 GB/s。 8192³满载 BF16 GEMM 在 750W 功耗墙稳态回落至311.5 TFLOPS(突发峰值379.4 TFLOPS于M = 512)。- 原始数据:
results/01_roofline.json、results/02_comm_mtlink.json、results/06_car_vs_mccl_crossover.json。
Q2:为什么机内多流重叠在 S5000 上反倒变慢?怎样打破负重叠魔咒?
直接把 mate/deep_gemm 或 FA3 与机内 MCCL 叠在两条流上,耗时反而比串行慢 32%–49%(重叠效率 -96.6% ~ -111.0%)。根因有二:deep_gemm.set_num_sms(N) 在当前软件栈上是空操作(抢满全部 56 MP),且重型 Tensor-Core 算子会与 SM 驱动的 MCCL 剧烈争用 60 MB 共享 L2。只要严格做到 SM 互斥(MT-DeepEP 16 SM + Triton GEMM 40 SM),重叠率立刻翻正到 +87.4%(1.50×)。

8 组控制变量实验测出的 S5000 重叠效率 。正值代表真并行隐藏了通信开销,负值代表并发比串行还慢。
由此可以把 S5000 的多流并发划成三条清晰铁律:
- 片外 PCIe Gen5 DMA + 重计算(
+89.4% ~ ~100%,1.81×):独立硬件拷贝引擎既不占 56 MP 也不搅动 L2,直接支撑 Track 2 主存 KV 异步预取。 - SM 互斥的
MT-DeepEP Normal+ SM 受限计算核(+76.2% ~ +87.4%,1.50×):排查deep_gemm.set_num_sms(8)失效时我们实测发现,MoE_Grouped_FP8在 56 SM 跑364 μs,设成 8 SM 依然跑369 μs——底层mate.set_num_mps根本未生效。换用严格限制在56 - ep_sms个 MP 内的 Persistent Triton GEMM 后,立刻跑出+87.4%真重叠(1,495.5 → 994.0 μs,1.50×),同算子下领先 MCCL(+45.3%)整整 42 个百分点。 - 无配额
mate/deep_gemm+ 机内 MCCL(-96.6% ~ -192.9%):即便我们在自写 Persistent GEMM 里强行空出 36/56 个 MP,与 MCCL 并发依然退化-192.9%(0.74×),调整MCCL_ACE_LARGE_SIZE_THRESHOLD=0与MCCL_MAX_NCHANNELS=4同样无济于事。
多流重叠控制变量记录(03*.py 与 track3_deepep.json)
FP8 GEMM (4K) + PCIe Pinned H2D (32 MB):串行1.206 ms→ 并发0.667 ms(1.81×,+89.4%)。MT-DeepEP Normal_CombBF16 (16 SM) + Triton Persistent GEMM (40 SM):串行1,495.5 μs→ 并发994.0 μs(1.50×,+87.4%)。MT-DeepEP Normal_DispFP8 (8 SM) + Triton Persistent GEMM (48 SM):串行2,243.7 μs→ 并发1,872.8 μs(1.20×,+76.2%)。MT-DeepEP Low-Latency采用 1024 线程块 + 跨卡自旋等待,不可与无 SM 限流的 56-SM GEMM 硬叠;但用 DualPipe Hook(send → GEMM → recv_hook)可稳定拿到+14.8%(1.07×)收益。- 原始数据:
results/03_overlap_feasibility.json、results/track3_deepep.json。
Q3:官方默认 vLLM-MUSA 跑真实 48 层 MoE 模型时,哪三个系统杀手最致命?
在动任何算子之前,三个隐蔽的系统级问题就能把整台 8 卡机器拖垮:MUSA Graph 约 1,900 的活跃句柄上限、fuse_allreduce_rms 的 FX 元数据崩溃 Bug,以及未缓存 Prefill 形状触发的 18–84s 静默 JIT 编译。
- MUSA Graph-Cap(
cap=1900)抖动(patches/0002+s5000_opt/graph_budget.py):默认vLLM-MUSA捕获 51 档 Piecewise + 51 档 Full Graph。任何 ≥37 层的模型(如 48 层 Qwen3-30B、61 层 DeepSeek-V3/R1、94 层 Qwen3-235B)句柄数都会飙到 ,触发torchada graph-exec rotation:捕获耗时655s、总冷启动832.8s、吃掉11.72 GiB/卡显存、在线解码BS=1仅6.8 tok/s、BS=8仅11.1 tok/s。在MUSAPlatformBase.apply_config_platform_defaults阶段自动规划为FULL_DECODE_ONLY几何分桶(严格满足estimate_musa_graphs(...) <= safe_cap)后,捕获降到20s(32.8×)、启动降到76.4s(10.9×)、省出9.7 GiB/卡(整机+77 GiB),同时保留原生 MUSAfused_add_rms_norm优先级、解除了 Piecewise 模式下被迫开启的VLLM_MUSA_CUSTOM_OP_USE_NATIVE=1降级。 - 修复
fuse_allreduce_rms崩溃 Bug(patches/0001+ 运行时自动守卫):MUPTI显示AllReduce + fused_add_rms_norm占 Decode GPU 时间约 18%,但开fuse_allreduce_rms=True会在VllmIRLoweringPass直接报InductorError: KeyError: 'val'。根因是vllm_musa/_inductor/musa_allreduce_rms_fusion.py手工重写融合节点时漏传node.meta["val"]。补齐两条重写分支的元数据透传(并在S5000_OPT_ENABLE=1下对未打补丁环境自动修复)后,48 层全部平滑融合,稳态吞吐稳定提升 +2.1% ~ +3.3%。 - 消除首次 Prefill 静默 JIT 悬崖(
scripts/warmup_prefill_shapes.py):即便启动已完成DeepGEMM warmup: 746/746且 Triton 零告警,首次遇到未缓存的长度(如BS=8合计 5,168 tokens)仍会无日志卡顿18–84s,热缓存后恢复为3.26s。接入流量前分桶预热即可彻底消除毛刺。
8×S5000 真实权重 Qwen3-30B-A3B-FP8 2×2 消融明细
- Stock 默认(51 档,
cap=1900抖动):启动832.8s(捕获655s),11.72 GiBVRAM,BS=1:6.8 tok/s,BS=8:11.1 tok/s。 - Opt A(
FULL_AND_PIECEWISE12 档,无融合):启动84.8s,3.75 GiB,BS=1:51.3、BS=8:314.1、BS=32:1,067.6、BS=64:2,335.3、BS=128:3,183.7 tok/s。 - Opt B(
FULL_AND_PIECEWISE12 档 + 修复后fuse_ar_rms):BS=32:1,090.2 (+2.1%)、BS=64:2,412.6 (+3.3%)、BS=128:3,231.4 (+1.5%)。 - Opt D(
FULL_DECODE_ONLY12 档 + 修复后fuse_ar_rms,热缓存对照):启动77.5s,<2 GiB,BS=1:51.6、BS=8:316.1、BS=32:1,332.0(比 Piecewise 高 22%)、BS=64:2,427.4、BS=128:3,179.6 tok/s。 - 原始数据:
results/07_real_*.json、results/vllm_qwen3_tp8_mupti/profiler_out_0.txt。
Q4:修完系统瓶颈后,自研 mp_31 MoE 融合核真能在 8 卡推理上继续提速吗?
能。MUPTI 剖面显示,非 GEMM 排名第一的热点竟是 vllm::silu_and_mul_per_block_quant(单核占整机 GPU 时间 6.44%,加上 colmajor Triton 变体达 8.10%)。用 5 个逐比特精确的手写 mp_31 MUSA C++ 融合核替换 MoE 与 DeepGEMM 胶水瓶颈后,8×S5000 真实端到端吞吐在 BS=1..64 再提 +3.5% ~ +13.3%。

左:fused_silu_mul_fp8_block_quant 在 MUSA Graph 下相对 vllm::_C 的加速比(1.67× → 28.1×,峰值有效带宽 1,007.8 GB/s,FP8 字节与 Scale 全零位差)。右:48 层 Qwen3-30B-A3B 单层 MoE 胶水总延迟对比(BS=8 1.89×、BS=32 2.56×、BS=128 4.23×)。
基于 mcc --offload-arch=mp_31 + tvm_ffi 手写核函数,我们沉淀出三条 mp_31 架构优化规律,同时也在独立审计中收获了一条极具价值的数值教训:
- 干掉非 2 次幂
int64除法:用 2D Grid 分块替代一维展开取模,单核显存有效带宽直接翻倍(538 → 1,287 GB/s)。 - 切勿为了 SFU 捷径在 FP8 SiLU 中用
tanhf(0.5f * x)或-ffast-math:早期原型沿用厂商快路径0.5*g*(1 + tanhf(0.5*g)),在标准高斯输入下余弦相似度虽高达0.99999994,但在负门控区间(g ∈ [-30, -5])存在严重的1 + tanh灾难相消(极端输入下 27.6% FP8 字节偏离),并导致Qwen3-30B-A3B-FP8贪婪解码第 2 个 token 翻转。关闭-ffast-math并改为无相消的(g * u) / (1.0f + expf(-g))(在narrow_silu_mul=True的 Tritoncolmajorue8m0=False/True路径上精确对齐exp2f(-g * kLog2E)、将scale_ub作用在group_scale、对齐min_scaling_factor = 1/(448*512))后,遍历全部 65,280 个有限 BF16、全部 63,488 个有限 FP16 与4096×1536随机 FP16/BF16 均达 0 FP8 字节差异与 0 FP32 Scale 位差(8 卡 48 层真机前向 0 / 42.5M 字节差异;results/07_real_full_arrms1_phase15.json与07_real_full_decode_ar_rms_fused.json前 52 个 greedy token 完全一致并在第 53 token 起分叉,而未打补丁同配置跨轮次运行自身受分布式归约非确定性影响最早在第 5 token——如07_real_full_arrms1_ctrl_warm.jsonvs07_real_full_decode_ar_rms_fused.json——及单 prompt 背靠背审计的第 54 token 即分叉),同时保持相对vllm::_C28.1× 加速与BS=64+13.3% 端到端收益。 - 掩码安全的 Ballot-Argmax(
__ballot_sync/__ffs)选 Top-K 与 Grouped Top-K:用可用槽位位掩码替代-FLT_MAX哨兵并关闭-ffinite-math-only(杜绝-inf/NaN掩码专家产生重复 ID),将fused_topk_softmax_renorm泛化至E ∈ {8, 16, 32, 64, 128, 256}、K ∈ {1, 2, 4, 6, 8},新增 MUSA Graph 安全的fused_grouped_topk(E ∈ {128, 256},支持sigmoid/softmax与correction_bias) 覆盖 DeepSeek-V3/R1 与 Qwen3.5 MoE,并把topk + renorm + moe_align_block_size(E=128, K=8)压进单个 CTA(Graph1.62×–1.86×、Eager3.41×–5.12×)。
通过零侵入 Hook(S5000_OPT_ENABLE=1,s5000_opt/vllm_patch.py)自动注入全部 8 个 vLLM-MUSA Worker 后,在真实 Qwen3-30B-A3B-FP8 同场热缓存 A/B 下全 Batch 单调提速:
| Batch Size | Phase 1 热缓存对照 | Phase 1.5(+ mp_31 MoE 核) |
同场热缓存净收益 | 每步节省耗时 |
|---|---|---|---|---|
BS = 1 |
51.6 tok/s(19.38 ms) |
54.2 tok/s(18.45 ms) |
+5.0%(较官方默认 8.0×) |
-0.93 ms/step |
BS = 8 |
316.1 tok/s(25.31 ms) |
327.3 tok/s(24.44 ms) |
+3.5%(较官方默认 29.5×) |
-0.87 ms/step |
BS = 32 |
1,332.0 tok/s(24.02 ms) |
1,424.1 tok/s(22.47 ms) |
+6.9% | -1.55 ms/step |
BS = 64 |
2,427.4 tok/s(26.37 ms) |
2,750.2 tok/s(23.27 ms) |
+13.3% | -3.10 ms/step |
BS = 128 |
3,179.6 tok/s(40.26 ms) |
3,184.5 tok/s(40.20 ms) |
+0.2%(19,284 total tok/s) |
-0.06 ms/step |
5 个自研核单算子验证与基准记录(track1_moe_fusion.json)
fused_moe_weighted_sum:较加权torch.sum快2.29×–3.71×(DecodeBS=8..32为2.78×–3.07×),较vllm_musafast sum 快1.14×–1.15×,峰值1,822.8 GB/s,MUSA Graph 逐比特复现。fused_silu_mul_fp8_block_quant:较vllm::_C快1.74×–19.53×(N=768)至28.10×(N=2048,1,007.8 GB/s),在musa_silu_deepgemm_fp8_op上提速1.09×–1.18×,在M ≤ 256时 Eager 延迟较vllm_musa jit_quant_v2低1.38×–1.41×(M > 256自动交回多行分块jit_quant_v2);全量 65,280 有限 BF16、63,488 有限 FP16、scale_ub与 Tritoncolmajor(ue8m0=False/True)均实现 0 FP8 字节差异、0 FP32 Scale 位差,8 卡 48 层真机前向0 / 42.5M字节差异。fused_add_rmsnorm_fp8_group_quant:较vllm_musaJIT 快1.50×–1.81×(较_C快1.75×–4.04×,1,401.9 GB/s),同步输出 FP8 + BF16,并已在线接管任意H % 128 == 0的musa_fused_add_rms_deepgemm_fp8_op(H=2048/7168提速3.70×–3.98×,H=4096提速1.11×–1.14×)。fused_topk_softmax_renorm、fused_topk_renorm_align与fused_grouped_topk:广谱E ∈ {8..256}, K ∈ {1..8}topk_softmax与E ∈ {128, 256}grouped_topk已在线接管;单 CTAfused_topk_renorm_align(Graph1.62×–1.86×、12.80–17.68 μs,Eager3.41×–5.12×)通过库 API 提供。
Q5:能否补齐 S5000 缺失的两块底层引擎——PCIe Gen5 KV 卸载与 MUSA 5.2.0 MT-DeepEP?
可以,而且实测清晰标出了两套组件各自的生产路由边界。
Track 2:musa_kvcacheio —— 激活 1 TiB 主存与 56 GB/s PCIe Gen5 DMA
MUSA 5.2.0 的 musaMemcpyBatchAsync 不会合并离散描述符(实测掉到 10–11.8 GB/s),导致 vLLM 0.24.1 自带的 SingleDirectionOffloadingHandler 在标准 48 层逐层 KV 布局(8 KB/block,TP8 block_size=16)下暴跌至 1.81 GB/s D2H / 7.95 GB/s H2D。我们编写了纯 extern "C" ABI(免疫 PyTorch C++ 符号漂移)的 musa_kvcacheio 库,先在 GPU 侧用 1,319 GB/s uint4 核完成离散页聚合/打散,再走单次 56 GB/s 连续 PCIe Gen5 DMA。

*左:vLLM 0.24.1 SingleDirectionOffloadingHandler 在 48 层逐层 KV(201.3 MB)上的实测对比,D2H 提速 12.9×–18.2×、H2D 提速 4.3×(bit_exact = True)。右:48 层真实 Qwen3-30B-A3B-FP8(deep_gemm + FA3)双缓冲异步预取在 16K / 32K / 64K 下分别获得 6.5× / 12.9× / 23.2× TTFT 加速,且 KV 显存压缩 24×。*
我们在 8×S5000 真机 OffloadingConnector 联调(microbench/09_vllm_kv_offload_e2e.py)中也客观捕捉到一个关键边界:vLLM 0.24.1 在 FA3 跨层融合布局(block_size=64)下,单个 KV 块已达 1.5 MB,原生连续 DMA 本身即可跑出 35.7 / 39.5 GB/s(15.3K 文档满载驱逐再恢复实现 3.0× 稳态 TTFT 加速:450 ms → 149–153 ms)。因此 vllm_patch.py 自动按未填充 page_bytes < 256 KB 走 musa_kvcacheio Mode B(配备按卡 RAII MusaDeviceGuard、线程安全 HostThreadPool 与跨流事件同步的 StagingPool,确保多卡与双向并发 D2H+H2D 流零竞争——32/128/512 页 × 48 层并发双向压测 0 / 96 串写,双卡并发 24 轮 Subcase B2 0 字节差异;逐层 KV / PagedAttention / SGLang:12.9×–18.3× D2H,独立 Mode B 散列页峰值达 51.8–52.2 GB/s),而对 ≥ 256 KB 跨层大块与带行尾填充的混合注意力 KV 组自动交回原生传输,零回归。
Track 3:MUSA 5.2.0 源码重建 MT-DeepEP 与 8×S5000 EP8 路由铁律
容器预装的 deep_ep 与 mtshmem 仍链接旧版 libmusart.so.4,在 MUSA 5.2.0 下开机即报 ImportError。我们的 5 文件补丁(patches/0003-mt-deepep-musa52-build.patch)将 MooreThreads/MT-DeepEP 干净编译链接至 libmusart.so.5 + 静态 libnvshmem_{host,device}.a,并在 S5000_OPT_ENABLE=1 下自动挂载 third_party/MT-DeepEP 与单机 MTLink P2P 默认环境变量(NVSHMEM_IB_ENABLE_IBGDA=0 NVSHMEM_REMOTE_TRANSPORT=none),顺利通过官方 24/24 test_intranode.py、16/16 test_low_latency.py 以及 8 卡 vLLM-MUSA(all2all_backend="deepep_low_latency")真机拉起验证。

8×S5000 全互联 EP8 Combine 延迟(E=128, K=8)随每卡 Token 数 T = 1..2048 变化。Decode 区间(T ≤ 128)MT-DeepEP Low-Latency 全面领先 1.70×–2.67×(H=2048)与 1.43×–2.08×(H=7168);大批量 Prefill(T ≥ 512)8 卡 MCCL 反超 20-SM Normal Mode。
由此确立 8×S5000 的 EP8 混合路由策略:
- Decode(
T ≤ 128):MT-DeepEP Low-Latency(24.7–64.6 μsCombine,快于 MCCL 1.70×–2.67×)。 - 独立大批量 Prefill(
T ≥ 512):MCCL All-to-All(341–417 μsvs. 20-SM Normal Mode 的764–777 μs)。 - 需与 GEMM 重叠的 Chunked Prefill:
MT-DeepEP Normal (8–16 SM) + SM 互斥 GEMM (40–48 SM)(+76.2% ~ +87.4% 真重叠)。
Track 2 与 Track 3 校验及原始结果记录
- Track 2 正确性(
kernels/musa_kvcacheio/test_correctness.py):Mode A、Mode B(连续、主机连续、双向随机散射)、Strided vLLM/SGLang 封装及 48 层 240 次跨流握手零竞争压测全部torch.equal=True。原始数据:results/track2_kvcacheio.json、results/09_handler_48l_ab.json、results/09_kv_offload_*.json。 - Track 3 8 卡 EP8 实测(
benchmarks/track3_deepep/bench_ep8_fullnode.py):H=2048, T=1LL Disp35.8 μs(2.22×)、LL Comb24.7 μs(2.67×);H=7168, T=1LL Disp41.3 μs(1.69×)、LL Comb32.8 μs(2.08×)。原始数据:results/track3_ep8_fullnode.json、results/track3_deepep.json。
Q6:能否用一个即插即用工具包一次性补齐单卡服务、SGLang、Mooncake IPC、RL sleep_mode 与 VeOmni 训练算子?
可以——而且实机多卡对抗审计揪出了两类极其隐蔽的驱动级“返回 rc = 0 却静默写坏显存”陷阱(MUSA 5.2 IPC 子切片基址句柄与 muMemCreate 脏回收页),任何在 S5000 上做底层基建的团队都必须显式设防。

*左:MUSA 5.2 重建版 Mooncake MT2 跨进程 IPC 实测带宽——每卡独立非阻塞流批量提交 + muMemGetAddressRange_v2 子切片偏移修正将 64×64 KiB 批传输提速 6.0×–6.4×(9.78 / 10.32 GB/s),32 MiB 达 29.14 GB/s 写 / 37.56 GB/s 读(0 字节差异)。右:mp_31 Post-Grad DeepGEMM 融合与 VeOmni/PyTorch 原生训练算子前反向加速比(1.31×–5.82×)。*
拿到一台 8×S5000 的团队很少只跑 8 卡 vLLM:大家还会跑单卡 TP=1 服务、SGLang 主存分层缓存(HiCache)、Mooncake KV 传输、RL 训推同卡休眠(sleep_mode)以及 VeOmni 多模态 MoE 训练——而在算子生态尚未维护到位的新卡上,这些链路几乎全部开机即挂(内联 CUDA PTX 报错、kDLCUDA vs kDLExtDev 不匹配、libmusart.so.4 符号断代、CuMemAllocator 崩溃)。我们在同一个 S5000_OPT_ENABLE=1 自动挂载机制下一次性补齐了这五块拼图:
- 单卡
TP=1、全模型 BF16 FP8 Post-Grad 融合与s5000-opt doctor/profile(results/track_a_single_gpu.json):- 原生
vllm-musa将MusaRMSDeepGemmFusionPass与MusaSiluDeepGemmFusionPass锁在狭窄条件内,且在非原地残差路径上触发residual.clone()。我们在fused_rmsnorm_fp8_quant.mu中支持 out-of-placeresidual_out(配合严格的row_major_scales/!e8m0/16B对齐守卫与PassManager.uuid()缓存隔离),对全部 BF16 FP8mp_31Dense 与 MoE 模型打通 Post-Grad 融合:add_rms_deepgemm在H ∈ {2048, 2560, 4096, 5120, 7168}较未融合提速1.77×–2.27×(在H=4096上同样较原生融合算子快1.02×–1.11×),silu_deepgemm提速1.24×–1.41×。单卡TP=1跑Qwen3-30B-A3B-FP8自动省下7.3 GiB显存(71.8 → 64.5 GiB,热启动64.1s → 48.6s,BS=1/8/32/64达71.8 / 459.5 / 1,127.0 / 1,501.8 out tok/s),并将连续主机内存的 KV 卸载加速上限扩展至≤512 KiB(256–512 KiB页提速+29%–72%)。 - 新增
s5000-opt doctor一键体检 MUSA 5.2 动态库、PCIe Gen5 速率、VMM/DMA-BUF/mt_peermem8×400Gbps RoCEv2 状态与deep_ep/mooncakeABI;s5000-opt profile自动采集PrivateUse1MUPTI 核耗时并区分 Eager 启动与 MUSA Graph 回放。
- 原生
SGLangmp_31HiCache、共享图上限守卫与偏移安全的MooncakeMUSA 5.2 IPC(patches/0004..0005,results/track4_sglang_mooncake.json):- 上游
SGLang的hicache因写死 CUDA PTXld.global.L1::no_allocate与kDLCUDA在mp_31上直接报 20 个mcc编译错误,且host::LaunchKernel未调用musaSetDevice(当前设备为musa:0操作musa:1张量时直接illegal memory access)。我们的mp_31原生 HiCache 核(kernels/sglang_hicache/、patches/0004)补齐 RAIIMusaDeviceGuard与跨卡一致性校验,通过上游 10/10test_hicache.py测试,在 Decode/Piecewise/投机采样多 Runner 间共享cap=1750图预算,并在真实Qwen3-30B-A3B-FP8上实现驱逐后 752 token 主存热恢复260.5 ms(61.4 tok/s,贪婪输出 100% 一致;无缓存BS=4达237.9 tok/s)。 - 静默损坏陷阱 #1(MUSA 5.2 IPC 子切片基址句柄):在 MUSA 5.2 上,对 PyTorch Caching Allocator 切出的偏移张量
base + offset调用musaIpcGetMemHandle,导出的是底层整块分配基址base + 0的句柄!朴素移植NvlinkTransport会直接丢失offset,返回rc = 0却把第k层 KV 静默覆写到第0层。我们通过muMemGetAddressRange_v2解析(base_ptr, base_offset)并按底层块引用计数去重、用 POSIX 共享内存原子纪元(epoch)使释放重分配的旧句柄即时失效、再将多切片拷贝合并到每卡独立非阻塞流批末单次同步,既彻底消灭两类静默错写(0字节差异),又将64 × 64 KiB批量 IPC 提速6.0×–6.4×(1.62 → 9.78 GB/s写 /10.32 GB/s读;32 MiBMT2IPC 达29.14 GB/s写 /37.56 GB/s读,同时跑通 400Gbps RoCEv2 DRAM 与 GPUDirect RDMA)。
- 上游
- 原生 MUSA VMM RL
sleep_mode分配器与VeOmni训练算子(kernels/musa_vmm/、kernels/train_ops/、results/track5_vmm_and_train.json):vllm-musa宣称is_sleep_mode_available() -> True,但调用CuMemAllocator会立即崩溃。基于 S5000 硬件原生 VMM(VMM_SUPPORTED=1)实现muMemAddressReserve/muMemCreate/muMemMap与torch_musaMemPool后,我们在双卡TP=2真机审计中进一步抓出两个深水区问题:一是必须对全部可见对端 GPU 设置muMemSetAccess(..., PROT_READWRITE)才能保证MusaJitCustomAllreduce/ MCCL P2P 不越界崩溃;二是静默损坏陷阱 #2——muMemCreate分配的回收物理显存页每层残留1.58e8–3.17e8个非零脏值,唤醒后进入未备份的 discardedkv_cache,被vllm_musaFlashAttention 3 读入注意力计算导致贪婪解码静默吐出乱码!对无主机备份的重映射页执行zero_async(musaMemsetAsync(0))并仅同步muDevicePrimaryCtxGetState已激活的设备后,多进程TP=2Qwen3-30B-A3B-FP8(开启默认CustomAllReduce)稳健跑通:一级休眠释放98.62 GiB(唤醒1.04s),二级休眠释放98.78 GiB(休眠148 ms、唤醒370 ms、原地重载权重19.74s),两级唤醒贪婪 token 100% 逐位一致、MUSA Graph 重捕获次数为0、显存与锁页主存零泄漏。- 面向
VeOmni与 PyTorch 训练补齐三大mp_31原生反向算子:防溢出/防伪 NaN 的fused_swiglu(对齐4096×4096与非对齐1025×1537前反向全面快于 eager 与torch.compile1.09×–1.70×)、直接支持Qwen3-VL/Qwen3.5非连续qkv.unbind()视图的 128-bit 向量化fused_vision_rope_3d(较 eager 快3.98×–5.82×,且反超VeOmnimuDNN达1.25×),以及基于MATEMUBIN 支持 GPU 驻留counts零同步的musa_moe_grouped_gemm(前反向较 eager 提速2.08×–2.55×,底层原语较torch._grouped_mm快4.2×–10.7×)。
结论与 Phase 2 路线图
- 先摸硬件底牌,再动算子:在 MTT S5000 上,投入产出比最高的第一刀(
cap=1900图预算 +fuse_allreduce_rms)根本不是写核,而是治掉系统级抖动,先拿回 10× 启动与 8×–29× 延迟。 - 敬畏 60 MB L2 与 56 MP 边界:绝不把无配额的
mate/deep_gemm与机内 MCCL 硬叠;把多流重叠留给独立的 PCIe Gen5 DMA(+89.4%–100%)或严格 SM 互斥的MT-DeepEP + GEMM(+87.4%)。 - 用多卡真机对抗测试检验驱动假设:单卡 happy-path 全过远远不够——MUSA 5.2 IPC 子切片基址句柄(
muMemGetAddressRange_v2)、musa:1缺失设备上下文守卫、以及muMemCreate脏回收显存页,只有放在真实多进程多卡负载下做破坏性复验才能彻底拦截。 - 做成即插即用的全栈杠杆:通过
pip install -e .+S5000_OPT_ENABLE=1把vLLM、SGLang、MooncakeIPC、VMMsleep_mode、VeOmni训练核与s5000-opt doctor/profile收敛进同一个零侵入入口,任何刚拿到 S5000 的团队第一天就能跑通全套主流工作流。
接下来,我希望把这项工作扩展到多台机器,让它们协同运行得更高效。
引用
@misc{sheng2026s5000infra,
author = {Sheng, Pingyue},
title = {Dissecting MTT S5000: Hardware Roofline, Overlap Laws, Custom mp\_31 Kernels, and Full-Stack LLM/RL Infrastructure},
year = {2026},
url = {https://ravenembodied-blog.chengpy23.workers.dev/posts/dissecting-mtt-s5000}
}

Setup
One 8× Moore Threads MTT S5000 node (PH100, 4th-gen MUSA mp_31, 56 MPs, 60 MB L2, 80 GiB VRAM/GPU, 14 MTLink MT2 links/GPU, 1.0 TiB host RAM, 8× 400Gbps ConnectX-7 RoCEv2). Stack: MUSA 5.2.0, torch_musa 2.11, mate 0.2.7, vLLM 0.24.1 (vllm-musa 0.1.24), SGLang, Mooncake, and VeOmni, tested on real 32 GB Qwen3-30B-A3B-FP8 weights (48 layers, 128 experts, Top-8, 1-GPU TP1, 2-GPU TP2, and 8-GPU TP8+EP8).
Code: github.com/spyzss/s5000-infra
Hardware roofline summary
- Memory & compute: L2
3,006.4 GB/s(≤60 MB), HBM1,334.8 GB/s(83.4% spec), BF16 GEMM379.4 TFLOPS, FP8 DeepGEMM694.5 TFLOPS(ridgeM ≈ 256). - Launch & links: Eager
16.04 μs/opvs. MUSA Graph1.94 μs/op(8.27×); PyTorchcopy_caps at35.6 GB/svs. MCCL A2A321.1 GB/sbi-dir (9.0×);MusaJitCustomAllreducebeats MCCL up to9.5×with crossover at64 MB; PCIe Gen5 pinned DMA hits56.1 / 56.8 GB/s; driver supports VMM, DMA-BUF, andmt_peermemGPUDirect RDMA.
Questions
| # | Question | Finding |
|---|---|---|
| Q1 | Why does stock vLLM-MUSA collapse on ≥37-layer models? |
Default 51 piecewise sizes exceed MUSA's ~1,900 live graph cap (2,499 > 1,900), causing an 11-min cold start and 27× decode thrashing (-7.3 GiB saved on 1-GPU TP1 too). |
| Q2 | Does compute–communication overlap work on S5000? | Off-chip PCIe DMA hits +89.4%. Uncapped mate + MCCL regresses -96.6% to -192.9%; SM-disjoint MT-DeepEP (16 SM) + Triton GEMM (40 SM) flips it to +87.4% (1.50×). |
| Q3 | Can custom mp_31 MoE & DeepGEMM kernels move serving speed? |
Yes: 5 bit-exact mp_31 C++ kernels cut MoE glue 1.89×–4.23×, speed up Dense/MoE post-grad add_rms_deepgemm 1.77×–2.27×, and add +3.5% to +13.3% (BS=1..64) 8×S5000 E2E throughput. |
| Q4 | How fast can we offload KV cache to 1 TiB host RAM on S5000? | GPU uint4 gather/scatter + bulk PCIe DMA speeds up ≤512 KiB per-layer vLLM offload up to 18.3× D2H / 4.3× H2D and cuts 64K TTFT 23.2× (24× less VRAM). |
| Q5 | When should 8×S5000 EP8 use MT-DeepEP vs. MCCL? |
Rebuilt MUSA 5.2.0 MT-DeepEP wins decode (T ≤ 128) by 1.70×–2.67×; MCCL wins standalone large prefill (T ≥ 512). |
| Q6 | Can we fix SGLang, Mooncake IPC, RL sleep_mode, & training ops in one drop-in package? |
Yes: mp_31 HiCache (260.5 ms warm restore), offset-safe Mooncake MUSA 5.2 IPC (29.1 / 37.6 GB/s, 6.0×–6.4× batch), VMM sleep_mode (98.6 GiB freed on TP2, 0 graph recaptures), VeOmni training ops (1.09×–5.82×), and s5000-opt doctor/profile. |
Findings
Q1. Fix the MUSA Graph cap and fuse_allreduce_rms first
Any model with ≥37 layers overflows MUSA's ~1,900 live graph-exec cap under default 51-size piecewise capture (832.8s cold start, 655s capture, 11.72 GiB VRAM, 6.8 tok/s at BS=1, 11.1 tok/s at BS=8). Switching to a FULL_DECODE_ONLY geometric budget (patches/0002) plus fixing a missing node.meta["val"] crash in fuse_allreduce_rms (patches/0001)—both auto-applied at runtime via pip install -e . + S5000_OPT_ENABLE=1—cuts cold start 10.7× (77.6s), capture 32.8× (20s), frees 64+ GiB/node (7.3 GiB saved on single-GPU TP1 Qwen3-30B-A3B-FP8 as well, reaching 1,501.8 out tok/s at BS=64), and restores 51.6 tok/s (BS=1) and 316.1 tok/s (BS=8).
Q2. Respect the 60 MB L2 and strict SM disjointness for overlap

Positive overlap requires either independent PCIe copy engines (+89.4%) or strict SM disjointness (+87.4%).
Stock deep_gemm.set_num_sms(N) is a no-op on S5000 (364 μs at 56 SMs vs. 369 μs at 8 SMs), so mate/deep_gemm floods all 56 MPs and thrashes the shared 60 MB L2 against MCCL (-96.6% to -192.9%). Pairing MT-DeepEP Normal (16 SM) with a persistent Triton GEMM strictly capped to 40 SMs breaks the curse at +87.4% overlap (1.50×).
Q3. Bit-exact mp_31 MoE & post-grad DeepGEMM fusions add +3.5% to +13.3% end-to-end

Five mp_31 kernels eliminate the top MUPTI non-GEMM hotspot (silu_and_mul_per_block_quant, 6.44% of GPU time) and accelerate Dense & MoE DeepGEMM RMSNorm/SiLU + MoE routing with 0/42.5M live FP8 byte diffs.
Three mp_31 engineering rules drove both speed and exactness: 2D power-of-2 tiling (538 → 1,287 GB/s), cancellation-free (g*u)/(1+expf(-g)) compiled without -ffast-math (0 differing FP8 bytes across all 65,280 finite BF16 and 63,488 finite FP16 patterns, 28.1× vs. vllm::_C), out-of-place residual_out single-pass fused_add_rmsnorm_fp8_group_quant unlocked across all BF16 FP8 mp_31 Dense & MoE models via MusaPostGradPassManager (1.77×–2.27× vs. unfused across H ∈ {2048..7168}, including 1.02×–1.11× over stock on H=4096), and mask-safe Ballot-Argmax topk_softmax (E ∈ {8..256}, K ∈ {1..8}) + grouped_topk (E ∈ {128, 256}). Hooked into 8-GPU vLLM-MUSA (S5000_OPT_ENABLE=1), real Qwen3-30B-A3B-FP8 serving improves across all batches: BS=1 +5.0% (54.2 tok/s), BS=8 +3.5% (327.3), BS=32 +6.9% (1,424.1), BS=64 +13.3% (2,750.2, -3.10 ms/step), BS=128 +0.2% (3,184.5 out / 19,284 total tok/s).
Q4. musa_kvcacheio fixes scattered PCIe offload (18.3× D2H, 23.2× TTFT)

GPU uint4 staging bypasses MUSA 5.2.0 musaMemcpyBatchAsync's scattered slowdown and overlaps 48-layer prefetch at 87%–100%.
On per-layer KV (≤512 KiB/page), our multi-GPU MusaDeviceGuard-safe pure extern "C" engine gives each SingleDirectionOffloadingHandler a stream-synchronized StagingPool (verified 0 / 96 concurrent bidirectional D2H+H2D corruptions) and lifts 48L TP8 bandwidth from 1.81 / 7.95 GB/s to 23.3–33.2 GB/s D2H (12.9×–18.3×) and 34.0–34.3 GB/s H2D (4.3×) (+29%–72% on 256–512 KiB single-GPU pages), while auto-routing both_scat, strided/padded hybrid-attention groups, and >512 KiB cross-layer blocks (1.5 MB) straight to native vLLM DMA. On 48L real deep_gemm + FA3, double-buffered prefetch cuts 64K TTFT 23.2× (5.85s → 252 ms) with 24× less VRAM.
Q5. Rebuilt MUSA 5.2.0 MT-DeepEP sets a clean EP8 crossover

Decode (T ≤ 128) belongs to MT-DeepEP Low-Latency; standalone large prefill (T ≥ 512) belongs to MCCL.
Our 5-file build patch (patches/0003) fixes the container's broken libmusart.so.4 deep_ep binary, passes 40/40 official tests, boots live 8-GPU vLLM-MUSA (deepep_low_latency), and beats MCCL by 1.70×–2.67× (H=2048) and 1.43×–2.08× (H=7168) at decode (24.7–64.6 μs).
Q6. Full S5000 onboarding: SGLang HiCache, Mooncake MUSA 5.2 IPC, RL sleep_mode, VeOmni training & doctor/profile

Offset-safe async stream batching speeds up Mooncake 64×64 KiB IPC 6.0×–6.4× (32 MiB hits 29.14 / 37.56 GB/s), while custom mp_31 post-grad & VeOmni training kernels deliver 1.31×–5.82× speedups.
SGLang-MUSA&MooncakeMUSA 5.2 (patches/0004..0005,s5000_opt/sglang_patch.py): Replaces broken CUDA PTXld.global.L1::no_allocateandkDLCUDAchecks withmp_31vectorized loads +kDLExtDev+MusaDeviceGuard(10/10 upstreamtest_hicache.pyPASS; liveQwen3-30B-A3B-FP8restores 752 evicted host tokens in260.5 mswarm with 100% greedy token match and237.9 tok/suncachedBS=4), enforces a sharedcap=1750graph budget across decode/piecewise/speculative runners, and rebuildsMooncakeagainstlibmusart.so.5withmuMemGetAddressRange_v2Caching-Allocator sub-slice offset resolution, POSIX shm epoch handle invalidation, and per-device stream batching (29.14 GB/swrite /37.56 GB/sread at32 MiBoverMT2IPC;6.0×–6.4×batch speedup on64×64 KiB).- Native MUSA VMM
sleep_mode&VeOmniTraining Kernels (kernels/musa_vmm/,kernels/train_ops/): ImplementsmuMemCreate/muMemMap/peermuMemSetAccess+torch_musaMemPool+zero_asyncclearing of dirty recycled VRAM pages (preventing MUSA FA3 attention corruption after wake). On live multi-processTP=2Qwen3-30B-A3B-FP8(CustomAllReduceON), Level-1/Level-2 sleep frees98.62 / 98.78 GiB, wakes in1.04s / 370 mswith0MUSA Graph recaptures and exact greedy tokens. Nativemp_31training ops speed upSwiGLUfwd+bwd1.09×–1.70×, non-contiguousQwen3-VL/Qwen3.5Vision RoPE3.98×–5.82×vs. eager (up to1.25×faster thanVeOmnimuDNN), andMATEMUBINMoE Grouped GEMM2.08×–2.55×.s5000-opt doctorands5000-opt profileprovide instant hardware/ABI checks and MUPTI kernel attribution.
Takeaways
- Fix graph budgeting and FX pass bugs before writing custom kernels—they account for the first order of magnitude on S5000.
- Use independent PCIe DMA (
+89.4%–100%) or strictly SM-disjointMT-DeepEP + GEMM(+87.4%) for overlap; never overlap uncappedmate/deep_gemmwith MCCL. - Audit vendor/driver assumptions adversarially on real silicon: MUSA 5.2 IPC sub-slice base handles (
muMemGetAddressRange_v2) and unzeroed recycled VMM pages (muMemCreate) both returnrc = 0while silently corrupting multi-layer KV tensors unless explicitly guarded.
Citation
@misc{sheng2026s5000infra,
author = {Sheng, Pingyue},
title = {Dissecting MTT S5000: Hardware Roofline, Overlap Laws, Custom mp\_31 Kernels, and Full-Stack LLM/RL Infrastructure},
year = {2026},
url = {https://ravenembodied-blog.chengpy23.workers.dev/posts/dissecting-mtt-s5000}
}