English · 简体中文
EPLB · DeepSeek-V4.1 · 🐋 mini-DeepInfer · 📚 Engineering notes
DeepSeek inference & Ascend NPU engineering
SGLang DeepSeek Ascend 910C Ascend 950
I work on DeepSeek inference on Ascend 910C and Ascend 950, with contributions to SGLang and sgl-kernel-npu. My work follows the serving path from MoE routing and expert placement through weight migration, graph replay, and performance measurement.
In an expert-parallel MoE, one overloaded rank can hold up the rest. Dynamic EPLB uses recent routing counts to decide where expert replicas should live. The change only pays off if it reduces the work on slow ranks enough to cover the cost of planning, moving weights, and switching the routing table.
EPLB study guide · GPU and NPU implementations · How the storage PR evolved
- Bring dynamic EPLB to Ascend. Added the initial NPU support in #47574.
- Keep draft forwards out of target statistics. I reported the rolling-window issue in #48603 and supplied the original fix in #47922. Ch-wan’s merged #48751 incorporates the core fix.
- Move expert storage in place. #49701 uses writable byte views to move complete physical blocks, preserving NZ padding and the allocations used by captured graphs. It reuses the TP/HCCL group where compatible, isolates draft warmup and capture from target statistics, and covers FP4 NZ format 50 on Ascend 950PR.
- Async HCCL migration · Open. #50784 stages one layer at a time over a dedicated HCCL P2P group while inference continues using the current layout. Once every rank is ready, the forward stream writes the staged weights and routing rows in place. The PR includes Ascend 910C migration and correctness checks. In an EP16 fixed-layout test, the worst forward step fell from 11.48 to 3.79 ms while step P95 rose from 0.61 to 2.71 ms.
- Dynamic rebalance interval · Open. #53290 uses a rolling window of routing counts to recommend how many target forwards should elapse between rebalance checks.
recommendreports a candidate.autotries it on comparable batches and accounts for check and migration costs. On colocated workers, a P95 regression in prefill, decode, or mixed batches can veto the trial. PD endpoints tune independently. Supported DeepSeek-V4-Flash PD configurations on Ascend 910C get role-specific window defaults. The window capacity stays fixed while serving. CPU and Gloo checks are complete, with end-to-end Ascend performance still unmeasured for the change. - Per-batch replica selection with LPLB · Draft. #50517 uses the current batch’s demand to route tokens across existing expert replicas while preserving logical top-k choices. Preallocated solver buffers are refreshed in place after an EPLB update so captured graphs can keep using them. In the earlier matched long-decode P/D test, throughput fell 6.33% and mean TPOT rose from 19.07 to 20.87 ms.
Choosing prefill and decode sampling windows and update intervals
Measured EPLB OFF → ON: output throughput 2,648.89 → 3,627.05 token/s (+36.93%) and mean E2E 50.49 → 36.39 s in the documented DeepSeek-V4-Flash W8A8 PD copying workload. Mean TPOT increased from 8.85 to 10.52 ms/token.
🔬 Experiment setup, acceptance counters & latency
The paired run at 08865d168 used Ascend 910C: 16 physical cards / 32 chips across P+D, TP16/EP16/attention-DP16 per endpoint, DSpark gamma 5 / verify 6, 16,384 input and 1,024 output tokens, concurrency 128, prefix/index caches disabled, and matched actual KV limits.
Throughput counts received generated tokens in the common [60, 360) s window. Latencies use successful requests started inside that window.
| Metric | EPLB OFF | EPLB ON |
|---|---|---|
| Output throughput, token/s | 2,648.89 | 3,627.05 |
| Mean TTFT, s | 41.43 | 25.63 |
| Mean TPOT, ms/token | 8.85 | 10.52 |
| Mean E2E, s | 50.49 | 36.39 |
| Acceptance length, tokens/verify | 5.988304 | 5.988304 |
| Measured strict draft acceptance | 100% | 100% |
| Correct / proposed draft tokens, latency cohort | 658,350 / 658,350 | 908,010 / 908,010 |
| Full-run successful / failed requests | 3,072 / 0 | 3,072 / 0 |
All 3,072 paired generated texts match. EPLB ON feeds a larger observed decode batch, alongside the higher per-request TPOT. For the separate comparison of old ND and physical-byte migration costs, see the storage migration write-up.
- Merged SGLang backend. #47660 adds low-ratio KV compression, two-level indexing, mixed-quantization sparse attention, graph replay, and DSpark. I contributed the migrated operator API integration and metadata validation. Related upstream alignment is tracked in draft #49005.
- Merged NPU operators. I worked with ClownBin on seven CANNBot-DSL compute and metadata APIs in sgl-kernel-npu #964, covering dispatch contracts, PyTorch references and tests, and a K-tail storage fix. #1012 aligned the wrappers, registry, tests, and docs on explicit
_dslnames.
Two follow-up runs of DeepSeek-V4.1-Flash reached 29,553.51 output tok/s across the full runs on November 28, up 3.70% from the earlier 28,500.16 tok/s on the same workload. Each run used 6,144 requests at concurrency 768, with 131,072 input tokens, 1,024 output tokens, and 99.90% on-device prefix hits. All 12,288 requests succeeded. Mean TTFT was 3.42 s, TPOT 21.50 ms/token, and E2E latency 25.42 s.
The earlier write-up covers prefill admission, MegaMoE, expert placement, device-side sequence lengths, and expert work reuse on the uncached tail page. 128K decode tuning report up to 28,500.16 tok/s
Per-run throughput and DSpark counters
- Full-run throughput: 29,033.89 and 30,092.06 tok/s. The combined value uses total generated tokens divided by the two runs’ total elapsed time.
- Combined steady-state throughput: 30,398.04 tok/s. Mean acceptance length in the two formal runs was 4.0373 tokens per verification. The colocated runs used DSpark with gamma 4 and verification width 5.
- Measured strict draft acceptance: 76.26% (593,055 accepted / 777,688 proposed, 194,422 verifies) in a separate 768-request diagnostic. Strict acceptance counters were unavailable for the formal throughput runs.
- Merged · A3 prefill/decode handoff. SGLang #47934 fixes C4 state transfer between different prefill and decode ring sizes using row-sized registration and peer-local addressing.
- Open · Allocator compilation. sgl-kernel-npu #1077 keys the Ascend Triton allocator by the number of loop blocks, allowing inputs with the same kernel geometry to share a compiled kernel.
Selected open patches · state transfer, memory, precision & timing (9 PRs)
| Area | Engineering change | PR |
|---|---|---|
| PD state | Preserve empty components across PP stages; use request-local C4 rows on AMD | #47937 / #47938 |
| Gateway lifecycle | Cancel pending prefill on early decode failure | #49792 |
| Decode memory | Bound DeepSeek-V4 SWA storage by request slots | #47740 |
| Numerical precision | Preserve Softplus accuracy in GDN gating and decode | kernel #933 |
| Sparse attention | Exclude padded lanes from non-power-of-two TopK reduction | kernel #935 |
| Quantization | Preserve AWQ fallback dtype; correct GPTQ zero-point offsets | #47639 / #47637 |
| Benchmark timing | Record non-streaming PD decode handoff time | #47772 |
📦 More open SGLang patches (12 PRs)
- #47721 · Bound DeepSeek-V4 RoPE tables by serving context · Open
- #47720 · Bound DeepSeek-V4 prefill query intermediates · Open
- #47718 · Release temporary DeepSeek-V4 RoPE tables · Open
- #47713 · dsv4: Reuse verify sequence lengths · Open
- #47665 · dsv4: Generate compression positions with stepped arange · Open
- #47663 · dsv4: Reuse CPU query lengths for prefill metadata · Open
- #47659 · MLA: preserve NZ cache data during CPU retraction · Open
- #47656 · moe: Honor SwiGLU clamp for BF16 and INT8 experts · Open
- #47654 · sparse-kv: Preserve shared prefixes in physical host slots · Open
- #47647 · dsv4: Avoid unused packed indexer cache allocation · Open
- #47634 · attention: Slice MLA latent K after TP all-gather · Open
- #47629 · moe: honor simple TopK scoring and routing scale · Open
📦 More open NPU operator patches (8 PRs)
- #936 · include dtypes in legacy add RMSNorm cache key · Open
- #934 · compute weightless RMSNorm in float32 · Open
- #932 · normalize strided gating inputs · Open
- #930 · preserve tiling configurations across graph replays · Open
- #926 · include sparse attributes in the tiling cache key · Open
- #925 · handle cache-location windows larger than 16 tokens · Open
- #924 · handle fully masked leading tiles in argmax probability · Open
- #922 · preserve arch22 accumulation order across batch sizes · Open
- mini-DeepInfer is a runnable teaching inference engine covering scheduling, batching, KV-slot reclamation, and speculative decoding, with CPU examples and Qwen3.5 generation on Ascend 910C. Repository
- LLM Inference Notes is my Chinese-language technical blog. It follows the code from routing and tensor storage to whole-service measurements, with source references and worked examples. Blog

Inference, kernels, and a well-reproduced bug. Let's talk 🐋
DeepSeek whale girl · Community fan art



