Hugging Face 将 Inkling 2 Mini 单卡推理优化至 194.9 tok/s
Hill-climbing Inkling 2 Mini inference on one RTX PRO 6000
Hugging Face 在一张 RTX PRO 6000 上优化 Inkling 2 Mini 推理,将引擎切换至 vLLM nightly,并启用含 7 个草稿的 DSpark,使单用户解码从 136 tok/s 提升至 190.6 tok/s。部署后的 Inference Endpoint 测得 194.9 tok/s,约达到硬件带宽上限的 95%。实验采用候选配置前后各运行一次控制配置的流程,并公开了 PLAN.md、驱动脚本和原始运行记录。
推荐理由
精选AI 评分 71
这套控制实验与验收流程展示了如何定位推理瓶颈,并将可复现的优化配置迁移到线上端点。
主题
正文
The setup
The inference-optimisation skill gives an agent a fixed experimental protocol and a small, engine-agnostic benchmark script ( bench.py ):
Measure the hardware and estimate theoretical ceilings before tuning.
Change one variable at a time and bracket every candidate between two control runs ( control → candidate → control ). Keep a change only if it beats both controls without regressing other metrics.
Log every run in PLAN.md , including regressions and dead ends.
Pass long-context, concurrency, and greedy-equivalence checks before declaring a winner.
bench.py measures single-user decode, aggregate decode at concurrency N, cold prefill at several lengths, and TTFT, using token counts directly from the server's usage response. All runs used a fixed panel of six prompts (code, an explanation, a story, a comparison table, a bash script, and a history summary) at temperature 1.0 (the model's default), thinking on, 512 output tokens, and 12 repetitions whenever speculative decoding was enabled.
The skill was written for a local GPU, so we adapted it to Hugging Face infrastructure:
HF Jobs for compute. The rtx-pro-6000 Job flavor uses the same GPU as the nvidia-rtx-pro-6000 Inference Endpoint ($2.75/h for both), so Job numbers transfer directly. A ~150-line driver ( jobs/driver.py ) takes a list of server configs, starts each one, runs an unmeasured warmup, calls bench.py unmodified, shuts the server down, and prints one ledger line per run. Because Jobs run on separate machines, the agent swept SGLang ( lmsysorg/sglang:inkling-2-mini ) and vLLM nightly ( vllm/vllm-openai:nightly ) in parallel.
CPU Jobs for reading engine source. When a flag was undocumented, the agent ran a cheap cpu-upgrade Job to grep the installed Python package inside the container. That is how it found SGLang's SGLANG_OPT_* environment variables and vLLM's speculative-config fields.
Inference Endpoints for deployment, created via hf endpoints deploy using the exact image digest and flags that passed verification.
The baseline was our existing org endpoint config: SGLang with --attention-backend fa4 and no speculative decoding.
Results
Single-user decode speed (median of 12 requests). vLLM + DSpark reaches ~95% of the memory-bandwidth ceiling at its measured acceptance rate.
¹ SGLang's RTX PRO 6000 DSpark recipe caps --max-running-requests at 4. Raising it to 8 reached 660 tok/s, still behind vLLM. ² Includes ~160 ms of client-to-endpoint network round trip.
All of the speedup comes from switching to vLLM nightly (+15% over SGLang without speculation, 136 → 157 tok/s), enabling DSpark with 7 drafts and probabilistic draft sampling (+21% on top, 157 → 190.6 tok/s across four runs: 189.3, 190.4, 191.1, and 190.7), and adding two memory flags so vLLM's DSpark setup actually starts on 96 GB:
Both num_speculative_tokens: 7 and draft_sample_method: "probabilistic" were validated directly: shorter draft counts (such as 5) are rejected at startup because both engines enforce the checkpoint's fixed block size, and switching to greedy draft sampling dropped vLLM decode speed by 11% at temperature 1.0 (see What didn't work ).
Why it stops around 190 tok/s
Before tuning, the agent probed the RTX PRO 6000 inside a Job ( 1,469 GB/s copy bandwidth, 416 TFLOPS BF16, 792 TFLOPS FP8) and read tensor sizes from the safetensors header. Because every token makes 48 layer visits, plain decode re-reads ~2.7 GB of attention and dense weights, ~2 GB of routed experts (8 of 128 per layer), and ~0.9 GB for the LM head. At 1,469 GB/s, that gives a single-user bandwidth ceiling of ~256 tok/s . Without speculation, vLLM at 157 tok/s hits 61% of that ceiling, mostly limited by kernel launch latency across 48 visits.
Speculative decoding changes the memory math on an MoE. Verifying 8 positions together activates the union of their routed experts, reading roughly 40% of each layer's experts instead of 6%. At our measured acceptance of ~2.3 tokens per step at temperature 1.0 (per-position acceptance drops from 0.6 on the first draft to 0.33 and 0.19), the bandwidth ceiling falls to ~201 tok/s . At 190.6 tok/s, vLLM + DSpark is already at ~95% of hardware bandwidth , so further flag tuning has almost nowhere left to go. Moving past 190 tok/s would take a drafter with higher acceptance at temperature 1.0 or a verification path that touches fewer experts per layer.
What didn't work
Most candidate flags were unsupported, noisy, or slower:
vLLM
We also skipped rejection_sample_method: "fly" and "synthetic" on purpose because they alter the output distribution, and we wanted a strictly lossless speedup.
SGLang
Benchmarking gotchas
A few measurement issues caught us along the way:
Triton JIT during timed prefill. vLLM's first 4K prefill came back at 202 tok/s instead of 20K because Triton was compiling kernels during the timed request. Running an unmeasured warmup across prompt lengths and concurrency fixed 4K prefill, though the first run in each Job still under-reported 32K prefill due to last-chunk shape differences (flagged in the ledger).
Orphaned servers holding GPU memory. The initial driver stopped servers via a PID saved from setsid … & , which is not guaranteed to match the process group ID. The previous server stayed alive on port 8000, broke the next launch, and turned into a zombie that still passed kill -0 . Managing the process with subprocess.Popen(start_new_session=True) and waiting until both GPU memory and port 8000 are free fixed it.
Hidden OOM errors in vLLM logs. vLLM + DSpark twice died with "Engine core initialization failed" at the end of the log while the real causes sat 200 lines up. First, the default 1M-token KV cache needed 52.6 GiB with only 48.1 GiB free alongside the drafter ( --max-model-len 262144 fixed this). Next, because vLLM v0.34.0 raised the default --gpu-memory-utilization from 0.92 to 1.0 , the KV cache claimed the remaining VRAM and OOMed the drafter's 5 GiB allocation ( --gpu-memory-utilization 0.85 fixed this). The driver now prints every error line from the server log instead of just the tail.
Engine variance. Across identical runs with speculation, vLLM stayed within 0.4% while SGLang swung by ±4.5%. That was wide enough to make SGLANG_ENABLE_NV_MEGA_RUNTIME_OPTIMIZATION=1 look like a +4% win on its first run before repeat controls ruled it out.
Verification and deployment
Before deploying, we pinned the exact vLLM nightly digest ( vllm/vllm-openai@sha256:eaa63fd6… , build 0.34.0rc1.dev1235+gf2f9edcac ) and ran the acceptance gates inside a Job:
Once those passed, we deployed the endpoint with a single hf endpoints deploy command, pinning both the image digest and model revision (authenticated access, scale-to-zero after 60 idle minutes):
Running bench.py against the live endpoint gave 194.9 tok/s single-user, matching the Job runs once network latency is accounted for.
Everything from this run ( PLAN.md , THEORY.md , jobs/driver.py , submit.sh , deploy.sh , and the raw ledger-*.jsonl files) is in NielsRogge/inkling-2-mini-hillclimb . To reuse the loop on another model, put your candidate and control server commands into a configs/plan-*.json file and submit it to whichever HF Jobs GPU flavor matches your target endpoint.
More Articles from our Blog
Run a vLLM Server on HF Jobs in One Command
AI 热点