Skip to content

refactor: move training hyperparameters from model configs to trainer kwargs - #707

Merged
orestis-z merged 9 commits into
mainfrom
dflash-max-anchors-to-trainer-kwargs
Jul 3, 2026
Merged

refactor: move training hyperparameters from model configs to trainer kwargs#707
orestis-z merged 9 commits into
mainfrom
dflash-max-anchors-to-trainer-kwargs

Conversation

@orestis-z

@orestis-z orestis-z commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #687 as discussed in review comments:

Move training-only hyperparameters out of model configs into get_trainer_kwargsforward(). These fields don't affect model architecture or inference behavior and shouldn't be persisted in config.json.

DFlash/DSpark:

  • max_anchors — anchor sampling count, training-only
  • sliding_window_non_causal — training attention mask flag (vLLM uses its own attention path)

PEagle:

  • num_depths, down_sample_ratio, down_sample_ratio_min — COD sampling params, training-only
  • Inference-time speculation count remains in SpeculatorsConfig.proposal_methods[0].speculative_tokens

Not breaking: SpeculatorModelConfig uses extra="allow", so old checkpoints with these fields load fine.

Test plan

  • pytest tests/integration/models/test_model_forward.py -k dflash — DFlash param tests
  • pytest tests/integration/models/test_model_forward.py -k peagle — PEagle param tests
  • pytest tests/integration/models/test_model_forward.py — all model forward tests (no regressions)
  • Existing checkpoints load without error (removed fields silently accepted by extra="allow")

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2539896d-f9ea-4b4a-9168-3fa83cb1ac52

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

[!WARNING]

Walkthrough skipped

File diffs could not be summarized.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dflash-max-anchors-to-trainer-kwargs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@orestis-z orestis-z self-assigned this Jul 2, 2026
@orestis-z
orestis-z marked this pull request as draft July 2, 2026 12:24
@orestis-z orestis-z changed the title refactor(dflash): move max_anchors from model config to trainer kwargs refactor: move training hyperparameters from model config to trainer kwargs Jul 2, 2026
@orestis-z orestis-z changed the title refactor: move training hyperparameters from model config to trainer kwargs refactor: move training hyperparameters from model configs to trainer kwargs Jul 2, 2026
@orestis-z
orestis-z marked this pull request as ready for review July 2, 2026 12:38
@orestis-z
orestis-z requested review from fynnsu and shanjiaz July 2, 2026 12:38
@mergify

mergify Bot commented Jul 2, 2026

Copy link
Copy Markdown

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @orestis-z.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Jul 2, 2026
@orestis-z
orestis-z force-pushed the dflash-max-anchors-to-trainer-kwargs branch from 4974e9b to 8bd9f72 Compare July 2, 2026 14:27
@mergify mergify Bot removed the needs-rebase label Jul 2, 2026

@fynnsu fynnsu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for fixing this!

Comment thread src/speculators/models/dflash/config.py
@orestis-z
orestis-z force-pushed the dflash-max-anchors-to-trainer-kwargs branch 2 times, most recently from c0675ac to 058e920 Compare July 3, 2026 11:36
orestis-z and others added 4 commits July 3, 2026 11:39
max_anchors is a training hyperparameter, not a model architecture
parameter, so it should not be persisted in the model config. This
follows the same pattern applied to peagle in PR #687.

- Remove max_anchors field from DFlashSpeculatorConfig
- Pass max_anchors through get_trainer_kwargs → forward for both
  DFlash and DSpark
- Update tests to pass max_anchors as a forward kwarg

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
num_depths, down_sample_ratio, and down_sample_ratio_min are training
hyperparameters (COD sampling behavior), not model architecture
parameters. Move them from PEagleSpeculatorConfig to get_trainer_kwargs
→ forward(), following the same pattern as max_anchors for DFlash.

The inference-time speculation count remains in
SpeculatorsConfig.proposal_methods[0].speculative_tokens.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
sliding_window_non_causal only affects the training attention mask;
vLLM uses its own attention path at inference. Move it from
DFlashSpeculatorConfig to get_trainer_kwargs → forward() for both
DFlash and DSpark.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
…wargs"

This reverts commit 058e920.

Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
@orestis-z
orestis-z force-pushed the dflash-max-anchors-to-trainer-kwargs branch from bfcbcae to b384dc8 Compare July 3, 2026 11:39
@orestis-z
orestis-z enabled auto-merge (squash) July 3, 2026 11:39
@orestis-z orestis-z added the ready This PR is ready for review label Jul 3, 2026
@mergify

mergify Bot commented Jul 3, 2026

Copy link
Copy Markdown

The quality checks have failed. Please run make style and make quality under
the root directory to address the lint failures. You will need to install the
dev optional install to get the required linting packages:
https://github.com/vllm-project/speculators/blob/main/CONTRIBUTING.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Link Check Results (DOCS)

All links are now valid - this issue has been resolved.


Marked as resolved: 147abf9

@mergify mergify Bot removed the quality-failed label Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Link Check Results (REPO)

All links are now valid - this issue has been resolved.


Marked as resolved: 147abf9

orestis-z added 2 commits July 3, 2026 13:11
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
@orestis-z
orestis-z merged commit 15297c2 into main Jul 3, 2026
9 checks passed
@orestis-z
orestis-z deleted the dflash-max-anchors-to-trainer-kwargs branch July 3, 2026 13:36
orestis-z added a commit to Eros483/speculators that referenced this pull request Jul 3, 2026
Resolve conflicts from vllm-project#707 (max_anchors moved to trainer kwargs):
- core.py: combine global_step (domino) + max_anchors (main) in forward()
- conftest.py: keep projector_type param, drop max_anchors param
- test_model_forward.py: add max_anchors forward_kwargs to both specs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Eros483 pushed a commit to Eros483/speculators that referenced this pull request Jul 4, 2026
shift_targets=True creates an off-by-one mismatch between training
(position p predicts token p+1) and vLLM inference (position p drafts
token p). This degrades acceptance length by -46% vs DFlash baseline.

Fix:
- Set shift_targets=False to align training with inference
- Always include anchor positions in Domino loss mask (decoupled
  from shift_targets)
- Use unshifted suffix_start unconditionally
- Derive num_anchors from tensor shape (config.max_anchors removed
  in vllm-project#707)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Eros483 pushed a commit to Eros483/speculators that referenced this pull request Jul 4, 2026
… kwargs (vllm-project#707)

Follow-up to vllm-project#687 as discussed in [review
comments](vllm-project#687 (comment)):

Move training-only hyperparameters out of model configs into
`get_trainer_kwargs` → `forward()`. These fields don't affect model
architecture or inference behavior and shouldn't be persisted in
`config.json`.

**DFlash/DSpark:**
- `max_anchors` — anchor sampling count, training-only
- `sliding_window_non_causal` — training attention mask flag (vLLM uses
its own attention path)

**PEagle:**
- `num_depths`, `down_sample_ratio`, `down_sample_ratio_min` — COD
sampling params, training-only
- Inference-time speculation count remains in
`SpeculatorsConfig.proposal_methods[0].speculative_tokens`

Not breaking: `SpeculatorModelConfig` uses `extra="allow"`, so old
checkpoints with these fields load fine.

- [ ] `pytest tests/integration/models/test_model_forward.py -k dflash`
— DFlash param tests
- [ ] `pytest tests/integration/models/test_model_forward.py -k peagle`
— PEagle param tests
- [ ] `pytest tests/integration/models/test_model_forward.py` — all
model forward tests (no regressions)
- [ ] Existing checkpoints load without error (removed fields silently
accepted by `extra="allow"`)

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

---------

Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Eros483 pushed a commit to Eros483/speculators that referenced this pull request Jul 4, 2026
shift_targets=True creates an off-by-one mismatch between training
(position p predicts token p+1) and vLLM inference (position p drafts
token p). This degrades acceptance length by -46% vs DFlash baseline.

Fix:
- Set shift_targets=False to align training with inference
- Always include anchor positions in Domino loss mask (decoupled
  from shift_targets)
- Use unshifted suffix_start unconditionally
- Derive num_anchors from tensor shape (config.max_anchors removed
  in vllm-project#707)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Eros483 pushed a commit to Eros483/speculators that referenced this pull request Jul 4, 2026
… kwargs (vllm-project#707)

Follow-up to vllm-project#687 as discussed in [review
comments](vllm-project#687 (comment)):

Move training-only hyperparameters out of model configs into
`get_trainer_kwargs` → `forward()`. These fields don't affect model
architecture or inference behavior and shouldn't be persisted in
`config.json`.

**DFlash/DSpark:**
- `max_anchors` — anchor sampling count, training-only
- `sliding_window_non_causal` — training attention mask flag (vLLM uses
its own attention path)

**PEagle:**
- `num_depths`, `down_sample_ratio`, `down_sample_ratio_min` — COD
sampling params, training-only
- Inference-time speculation count remains in
`SpeculatorsConfig.proposal_methods[0].speculative_tokens`

Not breaking: `SpeculatorModelConfig` uses `extra="allow"`, so old
checkpoints with these fields load fine.

- [ ] `pytest tests/integration/models/test_model_forward.py -k dflash`
— DFlash param tests
- [ ] `pytest tests/integration/models/test_model_forward.py -k peagle`
— PEagle param tests
- [ ] `pytest tests/integration/models/test_model_forward.py` — all
model forward tests (no regressions)
- [ ] Existing checkpoints load without error (removed fields silently
accepted by `extra="allow"`)

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

---------

Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Eros483 pushed a commit to Eros483/speculators that referenced this pull request Jul 4, 2026
shift_targets=True creates an off-by-one mismatch between training
(position p predicts token p+1) and vLLM inference (position p drafts
token p). This degrades acceptance length by -46% vs DFlash baseline.

Fix:
- Set shift_targets=False to align training with inference
- Always include anchor positions in Domino loss mask (decoupled
  from shift_targets)
- Use unshifted suffix_start unconditionally
- Derive num_anchors from tensor shape (config.max_anchors removed
  in vllm-project#707)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Eros483 pushed a commit to Eros483/speculators that referenced this pull request Jul 4, 2026
… kwargs (vllm-project#707)

Follow-up to vllm-project#687 as discussed in [review
comments](vllm-project#687 (comment)):

Move training-only hyperparameters out of model configs into
`get_trainer_kwargs` → `forward()`. These fields don't affect model
architecture or inference behavior and shouldn't be persisted in
`config.json`.

**DFlash/DSpark:**
- `max_anchors` — anchor sampling count, training-only
- `sliding_window_non_causal` — training attention mask flag (vLLM uses
its own attention path)

**PEagle:**
- `num_depths`, `down_sample_ratio`, `down_sample_ratio_min` — COD
sampling params, training-only
- Inference-time speculation count remains in
`SpeculatorsConfig.proposal_methods[0].speculative_tokens`

Not breaking: `SpeculatorModelConfig` uses `extra="allow"`, so old
checkpoints with these fields load fine.

- [ ] `pytest tests/integration/models/test_model_forward.py -k dflash`
— DFlash param tests
- [ ] `pytest tests/integration/models/test_model_forward.py -k peagle`
— PEagle param tests
- [ ] `pytest tests/integration/models/test_model_forward.py` — all
model forward tests (no regressions)
- [ ] Existing checkpoints load without error (removed fields silently
accepted by `extra="allow"`)

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

---------

Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Eros483 pushed a commit to Eros483/speculators that referenced this pull request Jul 4, 2026
shift_targets=True creates an off-by-one mismatch between training
(position p predicts token p+1) and vLLM inference (position p drafts
token p). This degrades acceptance length by -46% vs DFlash baseline.

Fix:
- Set shift_targets=False to align training with inference
- Always include anchor positions in Domino loss mask (decoupled
  from shift_targets)
- Use unshifted suffix_start unconditionally
- Derive num_anchors from tensor shape (config.max_anchors removed
  in vllm-project#707)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Eros483 added a commit to Eros483/speculators that referenced this pull request Jul 4, 2026
- Add max_anchors=8 to all _backbone_forward() and model() calls
  in unit tests (PR vllm-project#707 removed max_anchors from config, so
  _backbone_forward defaults to 3072, causing CUDA OOM)
- Fix lambda_base decay: decay_steps=0 means no decay (stay at
  lambda_base_start), not immediate drop to 0.0

Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Eros483 pushed a commit to Eros483/speculators that referenced this pull request Jul 4, 2026
… kwargs (vllm-project#707)

Follow-up to vllm-project#687 as discussed in [review
comments](vllm-project#687 (comment)):

Move training-only hyperparameters out of model configs into
`get_trainer_kwargs` → `forward()`. These fields don't affect model
architecture or inference behavior and shouldn't be persisted in
`config.json`.

**DFlash/DSpark:**
- `max_anchors` — anchor sampling count, training-only
- `sliding_window_non_causal` — training attention mask flag (vLLM uses
its own attention path)

**PEagle:**
- `num_depths`, `down_sample_ratio`, `down_sample_ratio_min` — COD
sampling params, training-only
- Inference-time speculation count remains in
`SpeculatorsConfig.proposal_methods[0].speculative_tokens`

Not breaking: `SpeculatorModelConfig` uses `extra="allow"`, so old
checkpoints with these fields load fine.

- [ ] `pytest tests/integration/models/test_model_forward.py -k dflash`
— DFlash param tests
- [ ] `pytest tests/integration/models/test_model_forward.py -k peagle`
— PEagle param tests
- [ ] `pytest tests/integration/models/test_model_forward.py` — all
model forward tests (no regressions)
- [ ] Existing checkpoints load without error (removed fields silently
accepted by `extra="allow"`)

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

---------

Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Eros483 pushed a commit to Eros483/speculators that referenced this pull request Jul 4, 2026
shift_targets=True creates an off-by-one mismatch between training
(position p predicts token p+1) and vLLM inference (position p drafts
token p). This degrades acceptance length by -46% vs DFlash baseline.

Fix:
- Set shift_targets=False to align training with inference
- Always include anchor positions in Domino loss mask (decoupled
  from shift_targets)
- Use unshifted suffix_start unconditionally
- Derive num_anchors from tensor shape (config.max_anchors removed
  in vllm-project#707)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Eros483 added a commit to Eros483/speculators that referenced this pull request Jul 4, 2026
- Add max_anchors=8 to all _backbone_forward() and model() calls
  in unit tests (PR vllm-project#707 removed max_anchors from config, so
  _backbone_forward defaults to 3072, causing CUDA OOM)
- Fix lambda_base decay: decay_steps=0 means no decay (stay at
  lambda_base_start), not immediate drop to 0.0

Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Eros483 pushed a commit to Eros483/speculators that referenced this pull request Jul 7, 2026
… kwargs (vllm-project#707)

Follow-up to vllm-project#687 as discussed in [review
comments](vllm-project#687 (comment)):

Move training-only hyperparameters out of model configs into
`get_trainer_kwargs` → `forward()`. These fields don't affect model
architecture or inference behavior and shouldn't be persisted in
`config.json`.

**DFlash/DSpark:**
- `max_anchors` — anchor sampling count, training-only
- `sliding_window_non_causal` — training attention mask flag (vLLM uses
its own attention path)

**PEagle:**
- `num_depths`, `down_sample_ratio`, `down_sample_ratio_min` — COD
sampling params, training-only
- Inference-time speculation count remains in
`SpeculatorsConfig.proposal_methods[0].speculative_tokens`

Not breaking: `SpeculatorModelConfig` uses `extra="allow"`, so old
checkpoints with these fields load fine.

- [ ] `pytest tests/integration/models/test_model_forward.py -k dflash`
— DFlash param tests
- [ ] `pytest tests/integration/models/test_model_forward.py -k peagle`
— PEagle param tests
- [ ] `pytest tests/integration/models/test_model_forward.py` — all
model forward tests (no regressions)
- [ ] Existing checkpoints load without error (removed fields silently
accepted by `extra="allow"`)

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

---------

Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Eros483 pushed a commit to Eros483/speculators that referenced this pull request Jul 7, 2026
shift_targets=True creates an off-by-one mismatch between training
(position p predicts token p+1) and vLLM inference (position p drafts
token p). This degrades acceptance length by -46% vs DFlash baseline.

Fix:
- Set shift_targets=False to align training with inference
- Always include anchor positions in Domino loss mask (decoupled
  from shift_targets)
- Use unshifted suffix_start unconditionally
- Derive num_anchors from tensor shape (config.max_anchors removed
  in vllm-project#707)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Eros483 added a commit to Eros483/speculators that referenced this pull request Jul 7, 2026
- Add max_anchors=8 to all _backbone_forward() and model() calls
  in unit tests (PR vllm-project#707 removed max_anchors from config, so
  _backbone_forward defaults to 3072, causing CUDA OOM)
- Fix lambda_base decay: decay_steps=0 means no decay (stay at
  lambda_base_start), not immediate drop to 0.0

Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready This PR is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants