Skip to content

[TRTLLM-14620][feat] Add confidence-guided dynamic verification for DeepSeek-V4 DSpark - #18392

Closed
zhaoyuanh-nvidia wants to merge 5 commits into
NVIDIA:mainfrom
zhaoyuanh-nvidia:feature/dsv4-dspark-confidence-head
Closed

zhaoyuanh-nvidia wants to merge 5 commits into
NVIDIA:mainfrom
zhaoyuanh-nvidia:feature/dsv4-dspark-confidence-head

Conversation

@zhaoyuanh-nvidia

@zhaoyuanh-nvidia zhaoyuanh-nvidia commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Umbrella for confidence-guided verification in embedded DeepSeek-V4 DSpark. A trained confidence head scores the drafted positions, and in decode-only steps the runtime may verify fewer rows, choosing among budgets whose step times were measured in a cost table. Drafting still produces the full block, and target verification and acceptance are unchanged. The feature is experimental and disabled by default.

This branch is the head of #20078 merged with current main (PR6, the last implementation PR; PR1-PR5 are merged, including #20072) plus a reproduction guide, benchmark scripts and the measured B300 artifacts. It is kept as a draft for review and reproduction; code changes land through the stacked PRs.

Reproduce

Follow CONFIDENCE_REPRODUCTION.md. The scripts in dspark_benchmark/ cover each step:

  • build_datasets.py rebuilds the four prompt sets from pinned Hugging Face revisions and checks them against the published files.
  • make_configs.py writes the fixed-K and confidence runtime YAMLs for each batch size.
  • run_benchmark.sh runs one setting with trtllm-bench.
  • analyze.py averages repeats and compares the methods at equal per-user speed.

Enabling the feature takes three settings:

speculative_config:
  decoding_type: DSpark
  max_draft_len: 5
  enable_confidence_scheduling: true
  confidence_cost_table_path: dspark-costs.json
  confidence_calibration_path: calibration.json   # optional
  • Reuse a table: dspark_artifacts/costs-b300-dep8.json holds K3 and K4 for graph batch sizes 16-256 and K5 for 8-256 on 8x B300 with attention DP and 8-way EP, with the matching calibration. It covers every configuration in the guide. Startup stops with the command to regenerate if the table has no entry for max_draft_len, lacks a captured graph batch size, or was measured on another GPU model or parallel layout; a different TensorRT LLM version only warns.

  • Generate one (about 10 minutes per K on 8x B300):

    python -m tensorrt_llm.tools.dspark_profile_costs \
      --model /path/to/checkpoint --config dynamic.yaml --k 3 4 5 --output dspark-costs.json

Results

One node of 8x B300, attention DP with 8-way EP, FP8 KV cache, main (2d1a7d1) plus #20078. Each dataset was sent at constant concurrency equal to the batch size (64 to 2048). Decoding is greedy, and requests stop at end-of-sequence or after 1,024 output tokens.

Confidence scheduling (K3-K5) against fixed DSpark draft lengths (K1-K5) at equal per-user speed: for each method the best points over all batch sizes and draft lengths form a line, and the table shows where the confidence line is furthest above the fixed one.

Dataset Largest gain at equal per-user speed At tok/s/user Fixed → confidence, tok/s/GPU
SPEED-Bench throughput_1k +21.9% 48.9 1,469 → 1,791
ShareGPT +19.9% 63.8 1,948 → 2,335
Arena-Hard v0.1 +12.3% 73.2 2,892 → 3,248
GSM8K 5-shot +1.5% 38.9 595 → 604

Best fixed draft length against the best confidence setting at the same batch size:

Batch size 64 128 256 384 512 768 1024 2048
SPEED-Bench +1.7% -0.6% +6.1% +4.7% +2.7% +3.4% +2.8% -3.7%
ShareGPT +0.6% -0.3% +2.4% +3.1% +4.2% +3.1% +3.8% -1.0%
Arena-Hard +0.7% +0.2% -0.2% +1.3% +1.5% +1.2% +4.3% +1.5%
GSM8K -0.2% +0.8% -0.8% -0.3% -0.3% -0.3%
  • Where confidence scheduling gains, it also runs faster per user at the same batch size (by up to 5.6 tok/s/user), and between batch sizes 256 and 512 throughput per GPU changes steeply with per-user speed, so the equal-speed gains are larger than the same-batch-size ones. All three large peaks are at batch sizes 256 to 384.
  • GSM8K gains little: its 5-shot prompts average 880 tokens and its answers are short, so prefill dominates.
  • Points that set a peak are the mean of three runs on different nodes; the others are single runs. Run-to-run variation in throughput per GPU is mostly within 2%.
  • The minimum predicted gain (confidence_min_predicted_gain, default 0.04) was swept from 0 to 0.08 on SPEED-Bench and ShareGPT at batch sizes 256-1024; every setting was within run-to-run variation of the default, so configs leave it unset.

Device re-ranking (this branch only)

This branch also adds an opt-in setting, enable_fused_confidence_scheduler: true in speculative_config, that keeps the host's verifier budget but re-ranks which draft positions are verified on the GPU with the confidence of the block being verified. make_configs.py --rerank writes these configs, and the analysis keeps the faster setting at each batch size. Over 15 dataset and batch-size settings (same node, two runs each) it raised throughput in 13, by up to 5.5% (Arena-Hard +3.4% to +5.5%, ShareGPT +3.3% at BS256-1024), and lowered it in two (SPEED-Bench BS384 -2.2%, GSM8K BS256 -0.4%). GSM8K accuracy was unchanged (96.6-96.8% with it, 96.8% without). Details: section 8 of the guide.

Remaining work

  • Review and land #20078.
  • Recover the same-batch-size loss at BS2048 (SPEED-Bench -3.7%, ShareGPT -1.0%).
  • Mixed-step (context + decode) compaction as a separate opt-in, with its cost profiling added to the same tool and table.

Keep this PR draft.

@zhaoyuanh-nvidia zhaoyuanh-nvidia changed the title Add confidence-guided dynamic verification for DeepSeek-V4 DSpark [TRTLLM-14620][feat] Add confidence-guided dynamic verification for DeepSeek-V4 DSpark Aug 28, 2026
@zhaoyuanh-nvidia
zhaoyuanh-nvidia force-pushed the feature/dsv4-dspark-confidence-head branch 2 times, most recently from 60ec034 to b1dde8d Compare August 31, 2026 01:59
@zhaoyuanh-nvidia zhaoyuanh-nvidia added the api-compatible Accepted LLM API contract change that is backwards-compatible label Aug 31, 2026 — with ChatGPT Codex Connector
@zhaoyuanh-nvidia
zhaoyuanh-nvidia force-pushed the feature/dsv4-dspark-confidence-head branch 9 times, most recently from 9967579 to 38a5b33 Compare September 7, 2026 08:01
@zhaoyuanh-nvidia
zhaoyuanh-nvidia force-pushed the feature/dsv4-dspark-confidence-head branch from f49ef1e to 1ec04e5 Compare October 6, 2026 20:25
@zhaoyuanh-nvidia
zhaoyuanh-nvidia force-pushed the feature/dsv4-dspark-confidence-head branch from 1ec04e5 to 790bd2c Compare October 16, 2026 09:40
@zhaoyuanh-nvidia
zhaoyuanh-nvidia force-pushed the feature/dsv4-dspark-confidence-head branch 6 times, most recently from d80f6e4 to a65862a Compare November 2, 2026 13:52
@zhaoyuanh-nvidia
zhaoyuanh-nvidia force-pushed the feature/dsv4-dspark-confidence-head branch from a65862a to 39e72e0 Compare November 2, 2026 19:46
Add confidence-guided verification for embedded DeepSeek-V4 DSpark decode
batches. A trained confidence head scores the drafted positions, and in
decode-only steps the runtime may verify fewer rows, choosing among budgets
whose step times were measured in a cost table. Drafting still produces the
full block, and target verification and acceptance are unchanged. The
feature is experimental and disabled by default.

- Config: enable_confidence_scheduling, confidence_cost_table_path,
  confidence_calibration_path and confidence_min_predicted_gain (0.04).
  Unsupported combinations are rejected at config validation, including the
  acceptance-rate gate and graph-disabling dynamic EPLB.
- Cost tables hold several K. Startup checks the entry for max_draft_len, a
  row per captured CUDA-graph batch size and the measured setup; tables in
  the earlier single-K format still load.
- tensorrt_llm.tools.dspark_profile_costs profiles a table for a runtime
  YAML and adds or replaces the profiled (K, G) rows of an existing file.
- Connect the policy to decoder inputs, metadata, graph selection and
  attention-DP executor scheduling, reserve the native KV-cache index slots,
  and remove the planner's admission-receipt, live-fingerprint and
  drain-guard code, which had no public producer.
- Document the opt-in and the cost-table workflow in the DeepSeek-V4 README.

Signed-off-by: Zhaoyuan He <[email protected]>
Document how to reproduce the DeepSeek-V4-Pro confidence-scheduling
results end to end: results from BS128 to BS4096 and on long prompts,
runtime YAMLs and why each setting was chosen, dataset format,
cost-table reuse and generation with
tensorrt_llm.tools.dspark_profile_costs, calibration, benchmark commands,
the throughput metric and the startup errors. Ship the cost tables
measured on 8x B300 with DEP8 (K3/K4/K5 for graph sizes 16-128, K4/K5
for 16-256, K5 for 16-512) and the matching calibration so the same
setup can reuse them.

Signed-off-by: Zhaoyuan He <[email protected]>
@zhaoyuanh-nvidia
zhaoyuanh-nvidia force-pushed the feature/dsv4-dspark-confidence-head branch from 39e72e0 to bad3954 Compare November 2, 2026 20:08
Rewrite CONFIDENCE_REPRODUCTION.md around the four-dataset real-data
sweep (SPEED-Bench, Arena-Hard, ShareGPT, GSM8K) on 8xB300 DEP8, with
equal-speed and same-batch-size results, and replace the short-prompt
synthetic section.

Add dspark_benchmark/ so the results can be reproduced from public data:
- build_datasets.py rebuilds the benchmark prompt files from pinned
  Hugging Face revisions and checks them against datasets_manifest.json,
  which stores only record IDs and truncated text hashes.
- make_configs.py writes the fixed-K and confidence configs per batch size.
- run_benchmark.sh and sampler.yaml run one trtllm-bench setting.
- analyze.py averages repeats and computes the equal-speed comparison.

Replace costs-b300-dep8.json with the cost table used for all real-data
runs and remove the separate BS2048/BS4096 tables. Document a sweep of
confidence_min_predicted_gain (0-8%), which is flat on real data, so the
4% default stays and configs leave the knob unset.

Signed-off-by: Zhaoyuan He <[email protected]>
Expose enable_fused_confidence_scheduler on the DSpark config (default
off) and pass it to the verify planner. With it on, compact steps keep the
host's verifier budget but re-rank which draft positions are verified on
the GPU, using the confidence of the block being verified instead of the
previous step's host copy. The device path already exists in the input
preparer and attention metadata; until now no setting turned it on.

On DeepSeek-V4-Pro (8x B300, attention DP) it raised throughput in 13 of
15 dataset and batch-size settings, by up to 5.5%, and lowered it in two
(-2.2% and -0.4%). GSM8K accuracy was unchanged. It stays opt-in.

Update the serve config schemas and the LLM-args telemetry manifest for
the new field, and add config and worker tests.

Signed-off-by: Zhaoyuan He <[email protected]>
make_configs.py --rerank also writes bs<BS>-confidence-rerank-k<K>.yaml,
the confidence config with enable_fused_confidence_scheduler on, so the
option is one flag away. analyze.py counts those runs as confidence
scheduling, labels them, and keeps the faster setting at each batch size.

The guide shows the option in the quick start, the example config and the
run instructions, and section 8 explains it with an A/B over 15 dataset
and batch-size settings (same node, two runs each) and a GSM8K accuracy
check. Troubleshooting moves to section 9.

Signed-off-by: Zhaoyuan He <[email protected]>
@zhaoyuanh-nvidia

Copy link
Copy Markdown
Collaborator Author

Closing this PR as the DSpark confidence head implementation has been merged into main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-compatible Accepted LLM API contract change that is backwards-compatible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant