quantuminfer 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +96 -2
  3. package/bin/quantuminfer.js +61 -0
  4. package/c27/adapters.py +161 -0
  5. package/c27/harness27.py +349 -0
  6. package/data/input.txt +40000 -0
  7. package/data/wikitext/test.txt +7249 -0
  8. package/engine/API.txt +208 -0
  9. package/engine/PLUGINS.txt +4 -0
  10. package/engine/__init__.py +82 -0
  11. package/engine/adapter.py +505 -0
  12. package/engine/blocks.py +1180 -0
  13. package/engine/c12.py +324 -0
  14. package/engine/c12cu.py +1074 -0
  15. package/engine/ctx.py +87 -0
  16. package/engine/dev.py +11 -0
  17. package/engine/ds4.py +389 -0
  18. package/engine/kernels.py +833 -0
  19. package/engine/model.py +281 -0
  20. package/engine/record.py +140 -0
  21. package/engine/server.py +183 -0
  22. package/engine/spec.py +1030 -0
  23. package/engine/wcode.py +122 -0
  24. package/p27/SPEC.txt +66 -0
  25. package/p27/STATUS.txt +91 -0
  26. package/p27/bench_glm.py +354 -0
  27. package/p27/bench_multi.py +76 -0
  28. package/p27/mkfinal.py +98 -0
  29. package/p27/modal_comp.py +173 -0
  30. package/p27/modal_dl.py +63 -0
  31. package/p27/modal_p27.py +168 -0
  32. package/p27/modal_probe.py +49 -0
  33. package/p27/p27rules.py +29 -0
  34. package/p27/pblocks.py +1242 -0
  35. package/p27/pmodel.py +402 -0
  36. package/p27/pref.py +151 -0
  37. package/p27/prof_glm.py +34 -0
  38. package/p27/quant.py +850 -0
  39. package/p27/recipes/vllm_b300_single_node_tep_b300_agentx_ep.md +353 -0
  40. package/p27/recipes/vllm_b300_single_node_tp_b300_agentx.md +351 -0
  41. package/p27/recipes/vllm_b300_single_node_tp_baseline.md +250 -0
  42. package/p27/recipes/vllm_default_gb300.md +281 -0
  43. package/p27/recipes/vllm_glm53_h200.md +301 -0
  44. package/p27/run_window1.sh +21 -0
  45. package/p27/run_window2.sh +13 -0
  46. package/p27/sweep_glm.py +64 -0
  47. package/p27/t_align.py +42 -0
  48. package/p27/t_combine.py +28 -0
  49. package/p27/t_echo.py +31 -0
  50. package/p27/t_fp8dense.py +59 -0
  51. package/p27/t_fp8speed.py +48 -0
  52. package/p27/t_glm.py +340 -0
  53. package/p27/t_glu.py +30 -0
  54. package/p27/t_gsuf.py +23 -0
  55. package/p27/t_jac.py +22 -0
  56. package/p27/t_moebm.py +30 -0
  57. package/p27/t_nccl.py +36 -0
  58. package/p27/t_online_jac.py +31 -0
  59. package/p27/t_probe.py +4 -0
  60. package/p27/t_router.py +28 -0
  61. package/p27/t_symm.py +50 -0
  62. package/p27/t_tiny.py +116 -0
  63. package/package.json +34 -4
  64. package/results/ANALYSIS.md +160 -0
  65. package/results/comp_vllm_mtp_k5_b300mtp.json +235 -0
  66. package/results/glm53_b300x8_opt4.json +624 -0
  67. package/results/res_glm_c32w3_b300.json +638 -0
  68. package/results/res_glm_final_c32_b300.json +652 -0
  69. package/results/res_glm_multi_final_b300.json +1821 -0
  70. package/results/res_glm_online_b300.json +638 -0
  71. package/results/res_glm_online_fixed_b300.json +638 -0
  72. package/results/res_glm_opt4_b300.json +624 -0
  73. package/results/res_glm_t1_j8_b300.json +340 -0
  74. package/results/res_glm_text_plain_batch_b300.json +5792 -0
  75. package/results/res_glm_text_w1_b300.json +1635 -0
  76. package/results/res_glm_text_w3_b300.json +1639 -0
  77. package/results/res_sweep_echo_b300.json +129 -0
  78. package/results/res_sweep_final_b300.json +153 -0
  79. package/results/res_sweep_glm_b300.json +153 -0
  80. package/results/res_techo.json +29 -0
  81. package/results/res_tgsuf.json +21 -0
  82. package/results/res_tjac.json +17 -0
  83. package/results/res_tonline_jac.json +13 -0
@@ -0,0 +1,353 @@
1
+ # moonshotai/Kimi-K3.1-Pro — vLLM serving recipe
2
+
3
+ > 2.8T-parameter native multimodal MoE with Kimi Delta Attention, sparse MLA, and a 1M-token context window
4
+
5
+ Configuration: hardware `b300` (8× B300) · strategy `single_node_tep` (Tensor + Expert Parallel) · variant `default` (MXFP4) · features `tool_calling`, `reasoning`, `spec_decoding`, `text_only` · KV offload `simple` · preset `b300_agentx_ep` at point `c48`
6
+
7
+ - Interactive page: https://recipes.vllm.ai/moonshotai/Kimi-K3.1-Pro?hardware=b300&strategy=single_node_tep&preset=b300_agentx_ep
8
+ - This configuration as JSON: https://recipes.vllm.ai/moonshotai/Kimi-K3.1-Pro.json?hardware=b300&strategy=single_node_tep&preset=b300_agentx_ep
9
+
10
+ The commands below were rendered for exactly this configuration and take precedence over any example in the guide.
11
+
12
+ ## Other configurations
13
+
14
+ Change the query string (the same parameters as the page URL) and fetch this URL again. Unknown or incompatible values fall back to the recipe default, so check the Configuration line.
15
+
16
+ - `hardware`: `gb200`, `b300`, `gb300`, `vr200`, `mi355x`, `ironwood`, `810e`, `m890`
17
+ - `variant`: `default`
18
+ - `strategy`: `single_node_tp`, `single_node_tep`, `multi_node_tp`, `multi_node_tep`, `multi_node_dep`, `pd_cluster` (multi-node strategies also need `nodes=<n>`)
19
+ - `features`: comma-separated list of `tool_calling`, `reasoning`, `spec_decoding`, `text_only`, `low_latency_decode`, `nvfp4_kv_cache`, `strict_tool_calls` (default: `tool_calling`, `reasoning`). Use `features=none` to turn them all off.
20
+ - `prefill_nodes`, `decode_nodes`: dedicated node counts for each pool under `strategy=pd_cluster`.
21
+ - `prefill_mode`, `decode_mode`: `tp`, `tep`, `dep`.
22
+ - `prefill_rank`, `decode_rank`: zero-based node indices (`0` to the pool's node count minus one). These select the singular command; `node_commands[]` always includes every node.
23
+ - `pd_router`: `vllm`, `dynamo`, `smg`, `ascend`. Hardware and pool compatibility applies.
24
+ - `pd_connector`: `nixl`, `mooncake`, `mooncake_ascend`, `moriio`. Select independently of the router; catalog hardware/router compatibility still applies.
25
+ - `preset`: a tuned, evidence-backed configuration (`baseline` opts out of a default one). Each sets its own hardware and strategy:
26
+ - `mi355x_agentx` — AgentX TP8 (mi355x · TP · Agentic (InferenceX AgentX) · opt-in): `hardware=mi355x&strategy=single_node_tp&preset=mi355x_agentx`
27
+ - `b300_agentx` — AgentX TP8 + DCP8 (b300 · TP · Agentic (InferenceX AgentX) · opt-in): `hardware=b300&strategy=single_node_tp&preset=b300_agentx`
28
+ - `b300_agentx_mixed_graphs` — AgentX TP8 + DCP8, mixed-step graphs (b300 · TP · Agentic (InferenceX AgentX) · opt-in): `hardware=b300&strategy=single_node_tp&preset=b300_agentx_mixed_graphs`
29
+ - `b300_agentx_ep` — AgentX TP8 + DCP8 + EP8 (b300 · TEP · Agentic (InferenceX AgentX) · opt-in): `hardware=b300&strategy=single_node_tep&preset=b300_agentx_ep`
30
+ - `b300_agentx_pd` — AgentX xPyD TP8 + DCP8 (b300 · PD · Agentic (InferenceX AgentX) · opt-in): `hardware=b300&strategy=pd_cluster&preset=b300_agentx_pd`
31
+ - `v7x_validated` — Validated TEP32 (v7x) (ironwood · Multi-node TEP · Accuracy validation (GSM8K) · opt-in): `hardware=ironwood&strategy=multi_node_tep&preset=v7x_validated`
32
+ - `v7x_dcp8` — Validated TEP32 + DCP8 (v7x) (ironwood · Multi-node TEP · Accuracy validation (GSM8K) · opt-in): `hardware=ironwood&strategy=multi_node_tep&preset=v7x_dcp8`
33
+ - `gb300_agentx_pd` — AgentX 1P5D TP8 + DCP8 (gb300 · PD · Agentic (InferenceX AgentX) · opt-in): `hardware=gb300&strategy=pd_cluster&preset=gb300_agentx_pd`
34
+ - `gb300_agentx_pd_hybrid` — AgentX xP1D, DP4 x TP8 decode (gb300 · PD · Agentic (InferenceX AgentX) · opt-in): `hardware=gb300&strategy=pd_cluster&preset=gb300_agentx_pd_hybrid`
35
+ - `gb300_agentx_pd_dep16` — AgentX 1P1D DEP16 (gb300 · PD · Agentic (InferenceX AgentX) · opt-in): `hardware=gb300&strategy=pd_cluster&preset=gb300_agentx_pd_dep16`
36
+ - `gb300_agentx_pd_dep32` — AgentX 1P1D DEP32 prefill, DEP32 decode (gb300 · PD · Agentic (InferenceX AgentX) · opt-in): `hardware=gb300&strategy=pd_cluster&preset=gb300_agentx_pd_dep32`
37
+ - `gb300_agentx_c1` — AgentX TP16 + DCP16, concurrency 1 (gb300 · Multi-node TP · Agentic (InferenceX AgentX) · opt-in): `hardware=gb300&strategy=multi_node_tp&preset=gb300_agentx_c1`
38
+ - `gb200_agentx_tp16` — AgentX TP16 + DCP16 (gb200 · Multi-node TP · Agentic (InferenceX AgentX) · opt-in): `hardware=gb200&strategy=multi_node_tp&preset=gb200_agentx_tp16`
39
+ - `gb200_agentx_pd_tp16` — AgentX 1P1D TP16 + DCP16 (gb200 · PD · Agentic (InferenceX AgentX) · opt-in): `hardware=gb200&strategy=pd_cluster&preset=gb200_agentx_pd_tp16`
40
+ - `gb200_agentx_pd_pp2` — AgentX 1P1D, TP8 x PP2 prefill (gb200 · PD · Agentic (InferenceX AgentX) · opt-in): `hardware=gb200&strategy=pd_cluster&preset=gb200_agentx_pd_pp2`
41
+
42
+ ## Install
43
+
44
+ Requires vLLM >= 0.35.0 (not released yet — nightly wheel).
45
+
46
+ Docker image: `vllm/vllm-openai:kimi-k31-mc@sha256:f81998764e8594d71b40788c5285ae112acf9230129d5d0d238b5df83da5acf6`
47
+
48
+ ## Serve
49
+
50
+ ```bash
51
+ export VLLM_ENGINE_READY_TIMEOUT_S=7200
52
+ export VLLM_HTTP_TIMEOUT_KEEP_ALIVE=900
53
+ export VLLM_USE_V2_MODEL_RUNNER=1
54
+ export VLLM_USE_DIRECT_DCP_A2A=1
55
+ export VLLM_USE_DIRECT_DCP_Q_GATHER=1
56
+ export VLLM_USE_DIRECT_DCP_KV_GATHER=1
57
+ export VLLM_ALLREDUCE_USE_FLASHINFER=1
58
+ export VLLM_KIMI_K3_SHARD_SP_SHARED_EXPERT=0
59
+ export VLLM_USE_NCCL_SYMM_MEM=0
60
+ export VLLM_ENABLE_GEMM_RS=0
61
+ export TOKENSPEED_MLA_FP16_PARTIALS=0
62
+ vllm serve moonshotai/Kimi-K3.1-Pro \
63
+ --trust-remote-code \
64
+ --override-generation-config '{"temperature":1.0,"top_p":0.95}' \
65
+ --enable-expert-parallel \
66
+ --tensor-parallel-size 8 \
67
+ --moe-backend deep_gemm_mega_moe \
68
+ --load-format fastsafetensors \
69
+ --decode-context-parallel-size 8 \
70
+ --dcp-comm-backend a2a \
71
+ --cp-kv-cache-interleave-size 1 \
72
+ --enable-prefix-caching \
73
+ --kv-cache-dtype fp8 \
74
+ --mamba-ssm-cache-dtype float32 \
75
+ --use-replayssm \
76
+ --no-enable-flashinfer-autotune \
77
+ --additional-config '{"decode_backend":"latency_specialized"}' \
78
+ --prefill-schedule-interval 8 \
79
+ --max-num-batched-tokens 16384 \
80
+ --stream-interval 10 \
81
+ --disable-uvicorn-access-log \
82
+ --attention-config '{"indexer_kv_dtype":"mxfp4"}' \
83
+ --max-num-seqs 48 \
84
+ --gpu-memory-utilization 0.97 \
85
+ --enable-auto-tool-choice \
86
+ --tool-call-parser kimi_k3 \
87
+ --reasoning-parser kimi_k3 \
88
+ --speculative-config '{"model":"Inferact/Kimi-K3.1-Pro-DSpark","num_speculative_tokens":4,"method":"dspark","draft_sample_method":"probabilistic","rejection_sample_method":"block"}' \
89
+ --language-model-only \
90
+ --kv-transfer-config '{"kv_connector":"SimpleCPUOffloadConnector","kv_role":"kv_both","kv_connector_extra_config":{"cpu_bytes_to_use_per_rank":374875000000,"lazy_offload":false}}' \
91
+ --compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY","cudagraph_capture_sizes":[5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240]}'
92
+ ```
93
+
94
+ Docker equivalent:
95
+
96
+ ```bash
97
+ docker run --gpus all \
98
+ --privileged --ipc=host -p 8000:8000 \
99
+ -v ~/.cache/huggingface:/root/.cache/huggingface \
100
+ -e VLLM_ENGINE_READY_TIMEOUT_S=7200 \
101
+ -e VLLM_HTTP_TIMEOUT_KEEP_ALIVE=900 \
102
+ -e VLLM_USE_V2_MODEL_RUNNER=1 \
103
+ -e VLLM_USE_DIRECT_DCP_A2A=1 \
104
+ -e VLLM_USE_DIRECT_DCP_Q_GATHER=1 \
105
+ -e VLLM_USE_DIRECT_DCP_KV_GATHER=1 \
106
+ -e VLLM_ALLREDUCE_USE_FLASHINFER=1 \
107
+ -e VLLM_KIMI_K3_SHARD_SP_SHARED_EXPERT=0 \
108
+ -e VLLM_USE_NCCL_SYMM_MEM=0 \
109
+ -e VLLM_ENABLE_GEMM_RS=0 \
110
+ -e TOKENSPEED_MLA_FP16_PARTIALS=0 \
111
+ vllm/vllm-openai:kimi-k31-mc@sha256:f81998764e8594d71b40788c5285ae112acf9230129d5d0d238b5df83da5acf6 moonshotai/Kimi-K3.1-Pro \
112
+ --trust-remote-code \
113
+ --override-generation-config '{"temperature":1.0,"top_p":0.95}' \
114
+ --enable-expert-parallel \
115
+ --tensor-parallel-size 8 \
116
+ --moe-backend deep_gemm_mega_moe \
117
+ --load-format fastsafetensors \
118
+ --decode-context-parallel-size 8 \
119
+ --dcp-comm-backend a2a \
120
+ --cp-kv-cache-interleave-size 1 \
121
+ --enable-prefix-caching \
122
+ --kv-cache-dtype fp8 \
123
+ --mamba-ssm-cache-dtype float32 \
124
+ --use-replayssm \
125
+ --no-enable-flashinfer-autotune \
126
+ --additional-config '{"decode_backend":"latency_specialized"}' \
127
+ --prefill-schedule-interval 8 \
128
+ --max-num-batched-tokens 16384 \
129
+ --stream-interval 10 \
130
+ --disable-uvicorn-access-log \
131
+ --attention-config '{"indexer_kv_dtype":"mxfp4"}' \
132
+ --max-num-seqs 48 \
133
+ --gpu-memory-utilization 0.97 \
134
+ --enable-auto-tool-choice \
135
+ --tool-call-parser kimi_k3 \
136
+ --reasoning-parser kimi_k3 \
137
+ --speculative-config '{"model":"Inferact/Kimi-K3.1-Pro-DSpark","num_speculative_tokens":4,"method":"dspark","draft_sample_method":"probabilistic","rejection_sample_method":"block"}' \
138
+ --language-model-only \
139
+ --kv-transfer-config '{"kv_connector":"SimpleCPUOffloadConnector","kv_role":"kv_both","kv_connector_extra_config":{"cpu_bytes_to_use_per_rank":374875000000,"lazy_offload":false}}' \
140
+ --compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY","cudagraph_capture_sizes":[5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240]}'
141
+ ```
142
+
143
+ ## Tuned preset: AgentX TP8 + DCP8 + EP8
144
+
145
+ Concurrency 48 and 64 on one B300 node: TP8 + DCP8 attention with routed experts EP8 on MegaMoE, the low-latency decode backend at every decode batch on FULL decode CUDA graphs, prefill admitted every 8 engine steps, the K3.1 DSpark draft with 4 tokens, and host KV offload.
146
+
147
+ - Key: `b300_agentx_ep` · opt-in
148
+ - Qualified on: hardware `b300` · strategy `single_node_tep` (Tensor + Expert Parallel)
149
+ - Workload: Agentic (InferenceX AgentX)
150
+ - Source: [InferenceX #4871](https://github.com/SemiAnalysisAI/InferenceX/pull/4871) (lane `kimik3.1-fp4-b300-vllm-agentic-dspark`, revision `75b1a3c7b745`)
151
+ - vLLM image: `vllm/vllm-openai:kimi-k31-mc@sha256:f81998764e8594d71b40788c5285ae112acf9230129d5d0d238b5df83da5acf6` (the Docker command above uses it)
152
+ - Builder choices it implies (already in the command above): `frontend=python`, `tool_calling` on, `reasoning` on, `spec_decoding` on, `text_only` on, `nvfp4_kv_cache` off, `dcp=8`, `kv_offload=simple`
153
+ - Every point rendered as JSON: https://recipes.vllm.ai/moonshotai/Kimi-K3.1-Pro/presets/b300_agentx_ep.json
154
+
155
+ ### Concurrency points
156
+
157
+ Each point is a delta on the preset; select one with `point=<key>`.
158
+
159
+ | Point | Concurrency | Select |
160
+ |---|---|---|
161
+ | 48 (**in use**, default) | 48 | `point=c48` |
162
+ | 64 | 64 | `point=c64` |
163
+
164
+ ### Runbook
165
+
166
+ The concurrency 48 and 64 points of InferenceX's B300 vLLM AgentX lane (SemiAnalysisAI/InferenceX#4871, `agentic-ep.yaml`), measured only on the image digest the preset pins, with the preview draft `Inferact/Kimi-K3.1-Pro-DSpark-preview`. It is [AgentX TP8 + DCP8](https://recipes.vllm.ai/moonshotai/Kimi-K3.1-Pro.md?hardware=b300&strategy=single_node_tp&preset=b300_agentx) with routed experts on expert parallelism, and changes the following:
167
+ - **Routed experts EP8 on MegaMoE.** Attention stays TP8 + DCP8; the Tensor + Expert Parallel strategy adds `--enable-expert-parallel` and `--moe-backend deep_gemm_mega_moe`. The lane keeps the default all-to-all backend, so the preset drops the strategy's `--all2all-backend`.
168
+ - **Low-latency decode at every decode batch.** The specialized decode also runs this hybrid layout (TP8 attention, routed experts EP over every rank) on MegaMoE, with `VLLM_ENABLE_GEMM_RS=0`. The Low-latency decode toggle is offered only without expert parallelism, so the preset sets `--additional-config '{"decode_backend":"latency_specialized"}'` itself.
169
+ - **`--prefill-schedule-interval 8`.** Prefill is admitted once every 8 engine steps, so the specialized decode serves the pure decode steps in between.
170
+ - **Points.** `--max-num-seqs` equals the concurrency, and FULL_DECODE_ONLY graphs capture 5 rows (1 + 4 draft tokens) per request up to it. `--gpu-memory-utilization` is 0.97 at both points.
171
+ - With `VLLM_KIMI_K3_SHARD_SP_SHARED_EXPERT=0`, sequence-parallel MoE replicates the shared expert on every rank, which costs weight memory on each GPU.
172
+ - The **Simple** KV-offload option gets 374,875,000,000 bytes of host DRAM per rank. Size `cpu_bytes_to_use_per_rank` to your host.
173
+
174
+ As in the other B300 presets, the lane's `PYTHONHASHSEED=42` and `PYTHONUNBUFFERED=1` are benchmark-only and left out.
175
+
176
+ ##### Throughput measurement only (synthetic acceptance)
177
+
178
+ To measure throughput the AgentX way, replace real verification with synthetic acceptance at InferenceX's K3.1 DSpark golden acceptance length for 4 draft tokens, 3.19. Only `--speculative-config` changes:
179
+
180
+ ```bash
181
+ --speculative-config '{"model":"Inferact/Kimi-K3.1-Pro-DSpark","num_speculative_tokens":4,"method":"dspark","draft_sample_method":"probabilistic","rejection_sample_method":"synthetic","synthetic_acceptance_length":3.19}'
182
+ ```
183
+
184
+ Synthetic acceptance skips real verification. Never use it to serve users or to evaluate accuracy.
185
+
186
+ ## Guide
187
+
188
+ > Background reference. Commands in it are examples and may target another configuration — use the Serve section above.
189
+
190
+ ### Overview
191
+
192
+ Kimi-K3.1 keeps the Kimi-K3 layout (Kimi Delta Attention, 896 routed experts with 16 active
193
+ per token, a latent MoE projection and a vision encoder) and adds sparse
194
+ attention (DSA, top-2048 indexer) to 24 of its MLA layers. The checkpoint ships MXFP4
195
+ routed-expert weights; everything else is BF16.
196
+
197
+ The baseline is the simplest working setup on NVIDIA: one tensor-parallel group of 8 GPUs,
198
+ either two GB300 trays or one B300 node. Throughput was not tuned. On B300 it sets
199
+ `--max-num-seqs 128`, since the KV cache can't hold the default 1,024 sequences, and turns
200
+ FlashInfer autotuning off, which would otherwise add about two hours to startup.
201
+
202
+ VR200 (preview) takes the same TP8 layout on two trays, in the `vllm/vllm-openai:kimi-k31-cu134`
203
+ image (CUDA 13.4). It uses the Blackwell flags and hasn't been tuned or verified on Rubin.
204
+
205
+ On one B300 node, three AgentX presets follow InferenceX's B300 vLLM AgentX lane
206
+ (SemiAnalysisAI/InferenceX#4871), all with TP8 + DCP8 attention, the K3.1 DSpark draft, the
207
+ low-latency decode backend and host KV offload:
208
+ [AgentX TP8 + DCP8](https://recipes.vllm.ai/moonshotai/Kimi-K3.1-Pro.md?hardware=b300&strategy=single_node_tp&preset=b300_agentx) at concurrency 1 and 6,
209
+ [concurrency 12 and 24](https://recipes.vllm.ai/moonshotai/Kimi-K3.1-Pro.md?hardware=b300&strategy=single_node_tp&preset=b300_agentx_mixed_graphs) with CUDA graphs for prefill and mixed steps, and,
210
+ with routed experts EP8 on MegaMoE, [AgentX TP8 + DCP8 + EP8](https://recipes.vllm.ai/moonshotai/Kimi-K3.1-Pro.md?hardware=b300&strategy=single_node_tep&preset=b300_agentx_ep) at concurrency 48 and 64.
211
+
212
+ On MI355X, one node takes the same TP8 layout with the AMD profile's AITER environment, in the
213
+ `vllm/vllm-openai-rocm:kimi-k31-020490a` image. The [AgentX TP8](https://recipes.vllm.ai/moonshotai/Kimi-K3.1-Pro.md?hardware=mi355x&strategy=single_node_tp&preset=mi355x_agentx) preset
214
+ follows InferenceX's MI355X vLLM AgentX lane (SemiAnalysisAI/InferenceX#5196) with one point per
215
+ concurrency, all with the K3.1 DSpark draft: plain TP8 with GPU KV and the low-latency decode
216
+ backend at concurrency 1, DCP8 with GPU KV and the low-latency decode backend at 4, and DCP8
217
+ with host KV offload from 16 to 48. It needs the image the preset pins.
218
+
219
+ On Zhenwu PPUs, the default MXFP4 checkpoint runs without speculative decoding on
220
+ two 16-PPU 810E nodes with TP32 / EP32, or four 8-PPU M890 nodes with TP8 / DP4 / EP32.
221
+ On 810E, `ppu_deep_gemm_w4a16` loads the checkpoint with a W4A16 compute path.
222
+ Use the PPU image specified for each hardware configuration.
223
+
224
+ On TPU, the model is served by [vLLM torch-TPU](https://github.com/vllm-project/vllm-torchtpu),
225
+ text-only: the vision tower is not loaded. The validated layout is TP32 with expert
226
+ parallelism on a 2x2x4 TPU v7x slice (16 chips, 32 devices, on 4 hosts). See [TPU serving](#tpu-serving).
227
+
228
+ ### Tensor + expert parallelism
229
+
230
+ On one B300 node, the **Tensor + Expert Parallel** strategy keeps attention at TP8 and runs
231
+ the routed experts with expert parallelism on the MegaMoE kernel. It has the lowest
232
+ long-prompt time to first token of the single-node layouts: a single 340K-token prompt
233
+ prefills in about 10 s, against about 15 s at plain TP8 (8x B300, one request at a time,
234
+ pre-release checkpoint).
235
+
236
+ ### Long context: decode context parallelism
237
+
238
+ The **Decode Context Parallelism** row shards the MLA latent and indexer-key caches across
239
+ the 8 GPUs of the TP group instead of replicating them, so DCP8 holds about 7x the KV cache
240
+ tokens of TP8 (about 18.5M vs 2.6M tokens with FP8 KV on 8x B300). Prefill is as fast as
241
+ at TP8. Decode steps are 7–25% slower than TP8 at the same batch, so use DCP when KV
242
+ capacity is the limit: very long contexts or many long-lived agentic sessions.
243
+
244
+ ### Low-latency decode
245
+
246
+ The **Low-latency decode** feature switches decode steps to a fused CuTe DSL path tuned for
247
+ small batches; prefill and mixed steps still run the default path. On 8x B300 at TP8 it cuts
248
+ the decode step by 1.6–1.7x at batch 1 and 1.2–1.3x at batch 32–64. Under DCP8 it brings decode
249
+ to within 6% of TP8. It requires the V2 model runner and FULL decode CUDA graphs (the
250
+ defaults), and TP8 or TP8 + DCP8. The feature toggle is offered only without expert
251
+ parallelism; the B300 AgentX preset with routed experts EP8 on MegaMoE
252
+ ([concurrency 48 and 64](https://recipes.vllm.ai/moonshotai/Kimi-K3.1-Pro.md?hardware=b300&strategy=single_node_tep&preset=b300_agentx_ep)) sets
253
+ the same `decode_backend` in its own args.
254
+
255
+ On MI355X the same switch selects fused FlyDSL decode kernels. They cover only pure decode
256
+ steps of up to 16 rows, so among other checks they also need speculative decoding,
257
+ `--max-num-seqs` 1, 2, 4 or 8 with `--max-num-seqs` × (1 + draft tokens) ≤ 16, BF16 KDA
258
+ projections, an FP32 KDA recurrent state (`--mamba-ssm-cache-dtype float32`) and no KV
259
+ offload. Without DCP they serve only 3 or 7 draft tokens at `--max-num-seqs` 1 or 2, so the
260
+ MI355X default of 5 draft tokens needs DCP8. The concurrency-1 (no DCP) and 4 (DCP8) points
261
+ of the [AgentX TP8 preset](https://recipes.vllm.ai/moonshotai/Kimi-K3.1-Pro.md?hardware=mi355x&strategy=single_node_tp&preset=mi355x_agentx) show working setups, on the image it pins;
262
+ current vLLM main does not yet run K3.1 on this path without DCP. Its points from
263
+ concurrency 16 do not qualify, so leave the feature off there.
264
+
265
+ ### NVFP4 KV cache
266
+
267
+ The **NVFP4 KV cache** feature stores the MLA latent in NVFP4 (352 bytes per token per layer
268
+ instead of 576) and holds about 1.5x the KV cache tokens of FP8. The indexer keys stay FP8,
269
+ so the top-2048 token selection is unchanged. GSM8K matched FP8 on 8x GB300 (96.1% vs 96.2%);
270
+ long-context accuracy has not been measured yet.
271
+
272
+ ### TPU serving
273
+
274
+ TPU serving runs through [vLLM torch-TPU](https://github.com/vllm-project/vllm-torchtpu) and
275
+ is text-only: the vision tower is not loaded. K3.1 support is under review as
276
+ [vllm-torchtpu#2775](https://github.com/vllm-project/vllm-torchtpu/pull/2775); until it merges,
277
+ the Install tab on TPU builds from the `kimi-k31pro` staging branch (Python 3.12, uv). No
278
+ published image or wheel carries it yet.
279
+
280
+ The generated command uses vllm-torchtpu's default multiprocessing multi-host backend: run the
281
+ head command on the slice's first host and the worker commands on the remaining hosts (the
282
+ builder renders both). The **Multi-Node TEP** strategy at 4 nodes matches the validated flags of
283
+ [vllm-torchtpu#2775](https://github.com/vllm-project/vllm-torchtpu/pull/2775) with two
284
+ differences: #2775 ran one driver over a Ray cluster (`TPU_MULTIHOST_BACKEND=ray`), and its
285
+ GSM8K validation used the completions API, so the default-on chat and tool-call parsers were not
286
+ exercised on TPU. Validated on a 2x2x4 TPU v7x slice with an FP8 latent KV cache, the unified
287
+ block pool and prefix caching: the complete GSM8K split scored 97.50% (TP32) and 97.42%
288
+ (TP32 + DCP8), prefix-cache hits returned identical tokens and logprobs, and the BEAM-1M
289
+ long-context benchmark matched the GPU reference. The run-specific sizing of that validation
290
+ (10K context, 16 sequences, compile sizes) is not the TPU default — it lives in the two
291
+ **Validated** presets: [TEP32](https://recipes.vllm.ai/moonshotai/Kimi-K3.1-Pro.md?hardware=ironwood&strategy=multi_node_tep&preset=v7x_validated) and
292
+ [TEP32 + DCP8](https://recipes.vllm.ai/moonshotai/Kimi-K3.1-Pro.md?hardware=ironwood&strategy=multi_node_tep&preset=v7x_dcp8) for KV-capacity-bound workloads.
293
+
294
+ **Spec decoding is gated off on TPU for now**: DSpark with `--async-scheduling` (always on in
295
+ this configuration) needs [vllm-torchtpu#2770](https://github.com/vllm-project/vllm-torchtpu/pull/2770),
296
+ still open. #2775 validated DSpark with 7 draft tokens once that fix is in.
297
+
298
+ ### Prefill/decode disaggregation
299
+
300
+ The **Prefill/Decode Disaggregation** strategy runs one TP8 prefill pool (with expert
301
+ parallelism) and one DEP16 decode pool (TP1 x DP16 with expert parallelism), and decode
302
+ pulls each request's KV from prefill over NIXL. Every PD worker sets
303
+ `VLLM_SSM_CONV_STATE_LAYOUT=DS`: NIXL transfers the Kimi Delta Attention conv state in three
304
+ reads, which needs that layout, and the NIXL connector refuses to start without it.
305
+
306
+ ### KV cache offloading
307
+
308
+ The **Simple** option on the KV Offload row adds `SimpleCPUOffloadConnector`, a host-DRAM
309
+ prefix tier for each GPU. Under Prefill/Decode Disaggregation it is added to the prefill pool
310
+ only, next to NIXL in a MultiConnector; decode keeps plain NIXL. The tier pins
311
+ `cpu_bytes_to_use_per_rank` of host memory for every GPU, so size it from the host DRAM that
312
+ is free after the engines are up. The tested GB300 prefill workers used 128 GiB per GPU
313
+ (512 GiB per tray).
314
+
315
+ ### Strict tool calls
316
+
317
+ Without a grammar, K3.1 sometimes calls a tool with empty or placeholder arguments. The opt-in
318
+ **Strict tool calls** feature adds `--tool-strict-level parameter`, which constrains every
319
+ tool call to a declared tool and to that tool's declared argument names and types, as if each
320
+ tool had set `strict: true`. On the
321
+ [Kimi Vendor Verifier](https://github.com/MoonshotAI/Kimi-Vendor-Verifier) Tool Call benchmark
322
+ (70 samples x 5 epochs, 8x MI355X, single-node TP8, Python frontend) K3.1 Pro scored 0.786
323
+ without the flag and 0.980 with it. The Rust frontend builds its own grammar and was not
324
+ measured. The limits are those in the
325
+ [Kimi-K3 recipe](https://recipes.vllm.ai/moonshotai/Kimi-K3)'s Tool calling note: a tool
326
+ schema the grammar cannot compile fails the whole request, and arguments still need
327
+ validating on the client. The feature is not offered for prefill/decode disaggregation:
328
+ Dynamo workers do not accept the flag and constrain tool calls through their own
329
+ `--dyn-enable-structural-tag`, which the AgentX PD presets set.
330
+
331
+ ### Client usage
332
+
333
+ ```bash
334
+ curl http://localhost:8000/v1/chat/completions \
335
+ -H "Content-Type: application/json" \
336
+ -d '{
337
+ "model": "moonshotai/Kimi-K3.1-Pro",
338
+ "messages": [{"role": "user", "content": "Explain sparse attention in two sentences."}]
339
+ }'
340
+ ```
341
+
342
+ The model card reports its results at `temperature = 1.0` and `top-p = 0.95`, but the
343
+ checkpoint's `generation_config.json` sets no sampling defaults, so the command passes them
344
+ as server defaults with `--override-generation-config`. They apply only to the parameters a
345
+ request omits; a value sent by the client still wins. Without the flag vLLM serves such a
346
+ request at `top_p = 1.0`: on DeepSWE (113 tasks, 8x MI355X, one run each) a coding agent that
347
+ sends neither parameter resolved 75 tasks at that fallback and 88 with `temperature = 1.0`
348
+ and `top_p = 0.95` set in the agent.
349
+
350
+ ### References
351
+
352
+ - [Model card](https://huggingface.co/moonshotai/Kimi-K3.1-Pro)
353
+ - [Kimi-K3 recipe](https://recipes.vllm.ai/moonshotai/Kimi-K3)