Skip to content

Deprecate HF acceptance-rate validation of draft models - #3107

Draft
h-guo18 wants to merge 1 commit into
mainfrom
haoguo/deprecate-hf-ar-validation
Draft

h-guo18 wants to merge 1 commit into
mainfrom
haoguo/deprecate-hf-ar-validation

Conversation

@h-guo18

@h-guo18 h-guo18 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Type of change: Deprecation

HF acceptance-rate (AR) validation drafts with Hugging Face generation instead of the serving engine. It covers examples/speculative_decoding/scripts/ar_validate.py and the periodic validation that the ar_validate_steps training argument enables. Each draft-model type also needs its own pseudo_speculative_generate before it can be measured at all:

Every shipped recipe already turns it off (ar_validate_steps is 0 or -1), and most launcher examples measure acceptance with examples/specdec_bench in vLLM, SGLang or TRT-LLM.

This PR deprecates it. Nothing is removed yet:

  • AcceptanceRateValidation now emits a FutureWarning. ar_validate.py, the training callback and Megatron's validation all construct it. It is a FutureWarning because Python's default filters hide a DeprecationWarning raised from library code.
  • The training callback warns at startup when ar_validate_steps > 0, rather than at the first validation. The argument's default is 1000.
  • The README's Model Validation section and the skill's validate stage point to examples/specdec_bench.
  • The changelog lists the deprecation.

estimate_ar is unaffected: it estimates acceptance from the training accuracies and runs no generation. Removing AcceptanceRateValidation, the per-model pseudo_speculative_generate methods, ar_eval_mtbench.sh and the launcher tasks that use it is left for a later release.

Usage

No API change. To measure acceptance, export the draft model and benchmark it in a serving framework, as described in examples/specdec_bench/README.md.

Testing

  • tests/unit/torch/speculative/plugins/test_{fakebase,hf_dflash,hf_speculative_offline}.py, tests/unit/torch/speculative/test_speculative_utils.py and tests/unit/examples/test_speculative_decoding_main.py all pass: 177 tests on Python 3.12, torch 2.10 and transformers 5.18.0.
  • A plain script run under the default warning filters:
    • Constructing AcceptanceRateValidation prints the FutureWarning at the caller's line.
    • EagleTrainingPlot(ar_validate_steps=1000) prints the startup warning on rank 0.
    • EagleTrainingPlot(ar_validate_steps=0) prints nothing.
  • No new tests: the change only adds warnings.

Before your PR is "Ready for review"

Make sure you read and follow Contributor guidelines and your commits are signed (git commit -s -S).

Make sure you read and follow the Security Best Practices (e.g. avoiding hardcoded trust_remote_code=True, torch.load(..., weights_only=False), pickle, etc.).

  • Is this change backward compatible?: ✅ It adds warnings only; behavior is unchanged.
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: N/A
  • Did you write any new necessary tests?: N/A
  • Did you update Changelog?: ✅ Under Deprecations.
  • Did you get Claude approval on this PR?: ❌ Not run yet.

Additional Information

Related: #2762 makes Domino's HF AR validation raise. Three launcher examples still run ar_eval_mtbench.sh and will show the warning; moving them to specdec_bench is a follow-up.

🤖 Generated with Claude Code

HF AR validation drafts with Hugging Face generation, not the serving engine, and every
draft-model type needs its own pseudo_speculative_generate to be measured at all. DFlash2
and LiLiCorr inherit DFlash's, which skips their selector and reranker, and Domino's drafted
one block position off. Every shipped recipe already turns it off (ar_validate_steps 0 or
-1), and most launcher examples measure acceptance with examples/specdec_bench in vLLM,
SGLang or TRT-LLM.

AcceptanceRateValidation, which scripts/ar_validate.py, the ar_validate_steps training
argument and Megatron's validation all construct, now warns that it is deprecated. It is a
FutureWarning because Python hides a DeprecationWarning raised from library code. The
training callback also says so at startup when ar_validate_steps > 0, which is the
argument's default, instead of at the first validation thousands of steps in. The README
and the skill's validate stage point to examples/specdec_bench, and the changelog lists the
deprecation.

estimate_ar is untouched: it estimates acceptance from the training accuracies and runs no
generation. Nothing is removed yet; AcceptanceRateValidation and pseudo_speculative_generate
go in a later release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: h-guo18 <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://NVIDIA.github.io/Model-Optimizer/pr-preview/pr-3107/

Built to branch gh-pages at 2026-10-29 08:51 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@codecov

codecov Bot commented Oct 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.07%. Comparing base (bdc4536) to head (dbde270).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
modelopt/torch/speculative/utils.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3107      +/-   ##
==========================================
- Coverage   78.09%   78.07%   -0.02%     
==========================================
  Files         662      662              
  Lines       76122    76313     +191     
==========================================
+ Hits        59445    59583     +138     
- Misses      16677    16730      +53     
Flag Coverage Δ
unit 61.95% <0.00%> (-0.01%) ⬇️

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.

h-guo18 added a commit that referenced this pull request Nov 15, 2026
…Domino export the head they built (#2762)

### What does this PR do?

Type of change: Bug fix

A DFlash-family drafter's label alignment belongs to its algorithm.
DSpark and Domino train block position `k` on the token at `anchor + k +
1`: next-token, so the anchor is itself a prediction. DFlash, DFlash2
and LiLiCorr train it on `anchor + k`: each masked position predicts
itself. Since #2757 the class constant `_label_shift` drives the
training targets, but on `main` the same fact is still written in four
more places, and the exports read it from the user's config:

- `DSparkModule.shift_label`, hard-coded `True`.
- `DominoModule.shift_label`, read from the config.
- A `NotImplementedError` in `HFDominoModel.modify`.
- The exporters' `getattr(draft_config, "shift_label", True)`, plus a
literal `sample_from_anchor: True` in the vanilla DSpark export.

Three bugs follow:

1. **`shift_label` in the config is ignored or contradicted.**
- DSpark with `shift_label: false` trains next-token alignment anyway
and exports `shift_label: false`, so a loader that honors the field
reads every drafted position one token off.
   - Domino refuses it, but only after building the draft.
   - DFlash, DFlash2 and LiLiCorr accept the field and ignore it.
2. **The exporters re-read head fields from the raw config.**
- `DSparkModule` casts `markov_rank` to int, so a rank written as `64.0`
trains a rank-64 head and exports `64.0`.
- The vanilla export copies that value to the top level, where vLLM's
`Qwen3DSparkModel` sizes its Markov table.
- `use_confidence_head` and Domino's `pure_draft_prefix_len` are re-read
with defaults of their own.
3. **Domino's HF AR validation drafts one position off, without its
head.** `HFDominoModel` inherits DFlash's `pseudo_speculative_generate`,
which decodes block positions `1..bs-1` with the backbone alone, so
every draft is scored against the wrong target. Shipped training is
unaffected: `domino.yaml` keeps AR validation off.

The fixes:

- **The alignment comes from `projector_type` alone.**
- `shift_label` is deprecated and will be removed in 0.50. Before
converting the model, `convert_to_dflash_model` compares it with the
wrapper class's `_label_shift`:
- A matching value is dropped with a `FutureWarning`. Configs copied
from the old Domino recipe (`shift_label: true`) keep working through
the migration window in the README's deprecation policy.
    - A contradicting value raises, because it never took effect.
- Why the check does not warn and override, as `HFDFlashModel.modify`
does for RoPE: on `main` a contradicting value was already ignored or
refused. DFlash, DFlash2 and LiLiCorr ignored it, DSpark trained
next-token anyway, and Domino refused `false`. Overriding it with a
warning would let a run go on that does not train what its config says.
- Why it is not a `DFlashConfig` validator: the alignment lives on the
plugin's wrapper class, which the config layer does not import. A
validator would also run on restore, where old checkpoints carry
contradicting values.
- `restore_dflash_model` drops the key unchecked before replaying
convert, so checkpoints that carry it still load. DSpark ones saved with
`shift_label: false` now re-export `true`.
- Both halves read one table, `_DEPRECATED_ARCHITECTURE_KEYS` in
`dflash/conversion.py`. It pairs each key with the model attribute that
now fixes its value, and the reason, so the check and the restore filter
cannot drift apart.
- The exports write `shift_label`, and DSpark's `sample_from_anchor`
(vLLM's name for the same alignment), from `_label_shift`.
- The modules' `shift_label` attributes and Domino's own check are gone.
The Domino recipe, the skill sheets and the test configs no longer set
the key.
- **The exporters read the built head** for `markov_rank`,
`markov_head_type`, `use_confidence_head`, `pure_draft_prefix_len`,
`gru_hidden_dim` and `emb_dim`, as `LiLiCorrExporter` already does.
- **Domino's `pseudo_speculative_generate` raises
`NotImplementedError`.**
- HF AR validation is being deprecated (#3107), so Domino gets no decode
of its own.
  - Domino acceptance cannot be measured anywhere yet:
- The inherited decode drafts with the backbone alone, one block
position off.
- The export declares `DFlashDraftModel`, so vLLM would serve it the
same way.
    - `examples/specdec_bench` has no Domino route.

The error, the changelog and the skill sheet now say so, matching the
launcher example's note.
- The eval-time warning that called acceptance rates "backbone-only" is
removed. The `forward` docstring and the skill sheet now note that eval
loss and accuracy exclude the correction head; the recipe sets `do_eval:
false`.
- During training, the AR callback already catches the error and logs
`AR validation not available.`
- **Changelog (0.49.0):** a Deprecations entry for `shift_label`, and a
Bug Fixes entry for the exports and Domino's AR validation.

### Usage

Remove `shift_label` from DFlash-family configs, since `projector_type`
fixes the alignment. Until 0.50 a value that matches the variant only
warns:

```yaml
dflash:
  dflash_architecture_config:
    projector_type: domino
    # shift_label: true  # deprecated: warns until 0.50; false raises
```

### Testing

- New and changed tests:
- `test_deprecated_shift_label[dflash|dspark|domino x true|false]`
restores a modelopt_state that carries `shift_label`, then converts with
it. A matching value warns, converts, and is not saved in the new
modelopt_state. A contradicting one raises and leaves the model
unconverted.
    - All 6 cases fail on `main` (09a14b9).
- With the previous revision's refusal (39ffc25), the 3 matching
cases fail.
- Without the restore filter, the 3 contradicting cases fail at restore.
- `test_export_config_has_dspark_fields` converts with `markov_rank`
given as a float and expects an int at both config levels. All 8 cases
fail without the exporter change.
- `TestDominoForward::test_ar_validation_is_refused` fails without the
override, because the inherited decode then runs.
- Rebased onto `main` (ef893e7) as bd19e2d. `git range-diff` shows
the same changes commit for commit; only the skill sheets' new location
under `skills/modelopt-speculative-decoding/` and CHANGELOG context
differ.
- At bd19e2d, Python 3.12, transformers 5.18.0, torch 2.13:
`test_hf_{dflash,dflash2,dspark,domino,lilicorr}.py`,
`tests/unit/recipe`,
`tests/unit/torch/export/test_hf_spec_rope_export.py`,
`tests/unit/examples/test_deepseek_v4_recipe.py` and
`tools/launcher/tests/test_examples_resolve.py`: 987 passed.
- Before the rebase, at a944d85, Python 3.12, transformers 5.18.0,
torch 2.10: `test_hf_{dflash,dflash2,dspark,domino,lilicorr}.py`, 318
passed.
- At 39ffc25, which differs from the head only in the `shift_label`
check, Domino's error text and docs:
- Those five files plus `tests/unit/recipe/test_loader.py`,
`tests/unit/torch/export/test_hf_spec_rope_export.py` and
`tests/unit/examples/test_deepseek_v4_recipe.py`: 834 passed.
  - `tools/launcher/tests/test_examples_resolve.py`: 75 passed.
- `tests/gpu/torch/speculative/plugins/test_hf_dflash.py` on 2 GPUs
(torch 2.13): 16 passed.
- Not run:
- transformers 5.5 and 5.12, which CI's multi-version job covers. An
earlier revision passed 792 of these tests on 5.5.4, 5.12.1 and 5.18.0.
  - A bitwise A/B, because no training code changes.

### Before your PR is "*Ready for review*"

Make sure you read and follow [Contributor
guidelines](https://github.com/NVIDIA/Model-Optimizer/blob/main/CONTRIBUTING.md)
and your commits are signed (`git commit -s -S`).

Make sure you read and follow the [Security Best
Practices](https://github.com/NVIDIA/Model-Optimizer/blob/main/SECURITY.md#security-coding-practices-for-contributors)
(e.g. avoiding hardcoded `trust_remote_code=True`, `torch.load(...,
weights_only=False)`, `pickle`, etc.).

- Is this change backward compatible?:
- ✅ for a `shift_label` that matches the variant, including the shipped
Domino recipe's `true`. Such configs convert as before, with a
deprecation warning.
- ❌ for a contradicting `shift_label`, which now raises at convert: it
never took effect. That is DFlash, DFlash2 or LiLiCorr with `true`, and
DSpark or Domino with `false`.
  - Existing checkpoints still load.
- Domino with `shift_label: false` raises `ValueError` instead of
`NotImplementedError`.
- Domino's HF AR validation raises instead of returning misaligned
drafts.
- If you copied code from any other sources or added a new PIP
dependency, did you follow guidance in `CONTRIBUTING.md`: N/A
- Did you write any new necessary tests?: ✅
- Did you update
[Changelog](https://github.com/NVIDIA/Model-Optimizer/blob/main/CHANGELOG.rst)?:
✅ 0.49.0: a Deprecations entry for `shift_label`, and a Bug Fixes entry,
since DSpark and Domino have shipped since 0.46.0.
- Did you get Claude approval on this PR?: ✅ Approved at 39ffc25. Its
one suggestion is addressed at the head.

### Additional Information

Follow-up to #2757, now merged. The shared-forward PRs, #2989 [1/2] and
then #2990 [2/2], build on this branch and will be restacked onto it.

Found while testing and not fixed here; it fails the same way on `main`:
with `DFlashModule` as its own FSDP2 unit, DSpark and Domino training
fails with `got mixed torch.Tensor and DTensor`, because their heads run
outside `DFlashModule.forward`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Corrected DSpark and Domino export settings to reflect the built model
configuration.
* Fixed a validation error in Domino’s Hugging Face autoregressive
validation; this validation is not supported for Domino.
* **Deprecations**
* `shift_label` is deprecated and planned for removal in version 0.50.
Matching values are ignored with a warning; conflicting values cause an
error. Existing checkpoints containing the setting can still be loaded.
* **Documentation**
* Updated speculative decoding guidance to reflect the deprecation and
Domino’s evaluation limitations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: h-guo18 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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