Skip to content

[Example]: Qwen3-8B online DSpark launcher example (+ DSpark recipe)#1959

Open
h-guo18 wants to merge 1 commit into
mainfrom
haoguo/qwen3-8b-dspark-online-example
Open

[Example]: Qwen3-8B online DSpark launcher example (+ DSpark recipe)#1959
h-guo18 wants to merge 1 commit into
mainfrom
haoguo/qwen3-8b-dspark-online-example

Conversation

@h-guo18

@h-guo18 h-guo18 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Type of change: New example (launcher example + recipe)

Adds an online-mode DSpark speculative-decoding launcher example for Qwen3-8B, plus the DSpark training recipe it depends on.

Files added (2, both additive — no code changes):

  1. modelopt_recipes/general/speculative_decoding/dspark.yaml — the DSpark training recipe. Selects the DSpark head via dflash_architecture_config.projector_type=dspark (DFlash backbone + lightweight sequential/Markov head + optional confidence head) and sets the three-term loss weights (dflash_ce_loss_alpha / dflash_l1_loss_alpha / dflash_confidence_head_alpha). Online training (data.mode=online) is the default path.

  2. tools/launcher/examples/Qwen/Qwen3-8B/hf_online_dspark.yaml — online DSpark training + vLLM smoke-test pipeline for Qwen3-8B, mirroring the existing hf_online_dflash.yaml. DSpark reuses the DFlash online training script (common/specdec/dflash_online_training.sh); only the --config recipe changes to dspark.yaml. The example drops the HF AR-eval step because DSpark keeps estimate_ar=false (training-time eval runs the DFlash backbone only, without the Markov head), and measures acceptance via the vLLM smoke test instead.

Notes

Testing

  • dspark.yaml passes the validate modelopt recipes schema check.

  • hf_online_dspark.yaml passes the launcher YAML reference check (check-launcher-yaml).

  • Backward compatible?: ✅ (additive recipe + example files only)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a DSpark speculative-decoding training recipe with configurable online training, loss weighting, confidence-head support, and draft-model architecture settings.
    • Added an example workflow for training DSpark with Qwen3-8B, including distributed execution and checkpoint export.
    • Added a vLLM validation step to test speculative decoding and token acceptance using the trained checkpoint.
  • Documentation
    • Included configurable dataset, generation, scheduling, and deployment settings for reproducible training and evaluation.

Adds the DSpark speculative-decoding recipe
(modelopt_recipes/general/speculative_decoding/dspark.yaml) and an
online-mode launcher example for Qwen3-8B
(tools/launcher/examples/Qwen/Qwen3-8B/hf_online_dspark.yaml).

DSpark reuses the DFlash online mode/pipeline and adds a lightweight
sequential (Markov) head plus an optional confidence head, selected via
dflash_architecture_config.projector_type=dspark. The Qwen3-8B example
mirrors hf_online_dflash.yaml and only swaps the recipe to dspark.yaml.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: h-guo18 <67671475+h-guo18@users.noreply.github.com>
@h-guo18 h-guo18 requested review from a team as code owners July 9, 2026 22:39
@h-guo18 h-guo18 requested a review from realAsma July 9, 2026 22:39
@copy-pr-bot

copy-pr-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a DSpark speculative-decoding recipe and a Qwen3-8B launcher pipeline for online training followed by vLLM smoke testing.

Changes

DSpark speculative decoding

Layer / File(s) Summary
DSpark training recipe
modelopt_recipes/general/speculative_decoding/dspark.yaml
Defines online-training defaults, DFlash/DSpark architecture settings, Markov sequential-head configuration, confidence-head options, loss weights, and DDP handling.
Training and smoke-test pipeline
tools/launcher/examples/Qwen/Qwen3-8B/hf_online_dspark.yaml
Adds launch instructions, shared model variables, an 8-GPU DSpark training task, and a single-GPU vLLM smoke-test task using the resulting checkpoint.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Launcher
  participant DFlashOnlineTraining
  participant TrainingCheckpoint
  participant vLLM
  Launcher->>DFlashOnlineTraining: start DSpark online training
  DFlashOnlineTraining->>TrainingCheckpoint: export training checkpoint
  Launcher->>vLLM: start DSpark smoke test
  vLLM->>TrainingCheckpoint: load draft checkpoint
  vLLM-->>Launcher: report speculative-token acceptance
Loading
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: a Qwen3-8B online DSpark launcher example plus the DSpark recipe.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Anti-Patterns ✅ Passed PR only adds two YAML examples; no Python or dependency-manifest changes, and scans found no eval/exec, nosec, trust_remote_code=True, weights_only=False, or allow_pickle=True.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch haoguo/qwen3-8b-dspark-online-example

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@modelopt_recipes/general/speculative_decoding/dspark.yaml`:
- Around line 74-75: Explicitly set dflash_loss_objective to decay in the dspark
recipe so dflash_loss_decay_factor: 7.0 is applied, and update the corresponding
launcher override to use the same objective; otherwise remove or revise the
decay factor and comment.

In `@tools/launcher/examples/Qwen/Qwen3-8B/hf_online_dspark.yaml`:
- Around line 34-35: Define a single shared checkpoint path in global_vars, then
reference that variable for both the training output directory and
DRAFT_CKPT_DIR. Update all corresponding occurrences, including the locations
noted in the review, so both tasks always use the same checkpoint source.
- Around line 23-26: The comment above the launcher overrides is inaccurate
because dflash_block_size, dflash_mask_token_id, and num_hidden_layers are also
overridden. Update the documentation near the YAML override section to
explicitly list these model/generation overrides alongside the data and schedule
fields, and remove the claim that they come from dspark.yaml.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bb764e85-6b49-4476-a258-119ba6e60db7

📥 Commits

Reviewing files that changed from the base of the PR and between 089c06e and 16fd70e.

📒 Files selected for processing (2)
  • modelopt_recipes/general/speculative_decoding/dspark.yaml
  • tools/launcher/examples/Qwen/Qwen3-8B/hf_online_dspark.yaml

Comment on lines +74 to +75
# gamma for exponential loss decay (block_size=16 -> 7).
dflash_loss_decay_factor: 7.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Select the loss-weighting objective explicitly.

dflash_loss_decay_factor is only used when dflash_loss_objective=decay, but DFlashConfig defaults that field to dpace and this recipe does not override it. Therefore, 7.0 currently has no effect, despite the comment describing exponential decay. Set dflash_loss_objective: decay if that is intended; otherwise remove or update this setting and comment. The launcher repeats the same ineffective override at Line 57.

Proposed fix
 dflash:
+  dflash_loss_objective: decay
   dflash_loss_decay_factor: 7.0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# gamma for exponential loss decay (block_size=16 -> 7).
dflash_loss_decay_factor: 7.0
# gamma for exponential loss decay (block_size=16 -> 7).
dflash_loss_objective: decay
dflash_loss_decay_factor: 7.0
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@modelopt_recipes/general/speculative_decoding/dspark.yaml` around lines 74 -
75, Explicitly set dflash_loss_objective to decay in the dspark recipe so
dflash_loss_decay_factor: 7.0 is applied, and update the corresponding launcher
override to use the same objective; otherwise remove or revise the decay factor
and comment.

Comment on lines +23 to +26
# The draft dims, block_size, mask token and loss weights all come from
# dspark.yaml (Qwen3-tuned defaults); only the commonly-tuned data/schedule fields
# are overridden below. dflash_block_size=16 is the semi-AR generation block
# (training_seq_len must be divisible by it).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Keep the launcher documentation aligned with its overrides.

This comment says the block size, mask token, and draft dimensions come from dspark.yaml and only data/schedule fields are overridden. However, Lines 55-60 override dflash_block_size, dflash_mask_token_id, and num_hidden_layers. Update the comment to describe the actual override set.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/launcher/examples/Qwen/Qwen3-8B/hf_online_dspark.yaml` around lines 23
- 26, The comment above the launcher overrides is inaccurate because
dflash_block_size, dflash_mask_token_id, and num_hidden_layers are also
overridden. Update the documentation near the YAML override section to
explicitly list these model/generation overrides alongside the data and schedule
fields, and remove the claim that they come from dspark.yaml.

Comment on lines +34 to +35
global_vars:
hf_model: /hf-local/Qwen/Qwen3-8B

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Use one shared checkpoint path for both tasks.

The training output directory and DRAFT_CKPT_DIR duplicate /scratchspace/dspark_bs16. If either value changes independently, the smoke test can read a stale or missing checkpoint. Define the path once under global_vars and interpolate it in both locations.

As per coding guidelines, “Don't repeat yourself; keep a single source of truth.”

Proposed fix
   global_vars:
     hf_model: /hf-local/Qwen/Qwen3-8B
+    dspark_output_dir: /scratchspace/dspark_bs16
...
-      - training.output_dir=/scratchspace/dspark_bs16
+      - training.output_dir=<<global_vars.dspark_output_dir>>
...
-      - DRAFT_CKPT_DIR: /scratchspace/dspark_bs16
+      - DRAFT_CKPT_DIR: <<global_vars.dspark_output_dir>>

Also applies to: 46-46, 74-75

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/launcher/examples/Qwen/Qwen3-8B/hf_online_dspark.yaml` around lines 34
- 35, Define a single shared checkpoint path in global_vars, then reference that
variable for both the training output directory and DRAFT_CKPT_DIR. Update all
corresponding occurrences, including the locations noted in the review, so both
tasks always use the same checkpoint source.

Source: Coding guidelines

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.80%. Comparing base (089c06e) to head (16fd70e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1959   +/-   ##
=======================================
  Coverage   77.80%   77.80%           
=======================================
  Files         519      519           
  Lines       57960    57960           
=======================================
  Hits        45095    45095           
  Misses      12865    12865           
Flag Coverage Δ
unit 55.24% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant