-
Notifications
You must be signed in to change notification settings - Fork 515
Add ModelOpt QAD skill for Slurm workflows #2010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1eb8ce6
afd59b4
8abffb7
494d46c
f8f8764
ef9be33
61aa5f0
81e57bf
95e29fa
62fda52
41ec0ac
1688751
49a456d
44b416a
23e83d7
b2188d4
7850116
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| --- | ||
| name: qad | ||
| description: >- | ||
| Run explicitly requested ModelOpt Quantization-Aware Distillation (QAD) on | ||
| Slurm through Megatron Bridge to recover a measured BF16-to-PTQ accuracy gap. | ||
| Use only when the user explicitly asks for QAD, including its topology, data | ||
| preparation, Slurm launch, resume, checkpoint export, or recovery decisions. | ||
| --- | ||
|
|
||
| # ModelOpt Quantization-Aware Distillation | ||
|
|
||
| QAD is expensive. Run it only when the user explicitly authorizes QAD for the | ||
| target model or run. A Day-0, PTQ, evaluation, comparison, or recipe-search | ||
| request alone is not authorization to start QAD. | ||
|
|
||
| ## Follow the supported workflow | ||
|
|
||
| Before constructing commands, read: | ||
|
|
||
| - `examples/megatron_bridge/README.md`, especially PTQ, data preparation, QAD, | ||
| export, and Slurm usage | ||
| - `examples/megatron_bridge/{quantize.py,distill.py}` via `--help` | ||
| - `skills/common/{environment-setup,workspace-management,slurm-setup}.md`; also | ||
| `skills/common/remote-execution.md` for remote Slurm | ||
|
|
||
| Treat the example README and `--help` output as authoritative for mutable flags, | ||
| commands, containers, and checkpoint formats. This skill supports Slurm only. | ||
|
|
||
| ## Execute in this order | ||
|
|
||
| 1. **Confirm the gap.** Reuse only validated, comparable BF16/PTQ results and | ||
| the exact benchmark configuration from preceding evaluation or recipe | ||
| search; run missing, invalid, or non-comparable baselines. Stop if the PTQ | ||
| gap to BF16 is already below 1%. | ||
| 2. **Reproduce PTQ and verify compatibility.** In the target runtime, require | ||
| `AutoBridge.can_handle()` for the target model and PTQ through `quantize.py` | ||
| to succeed while preserving the exact preceding PTQ config or recipe: | ||
| format, layer selection, calibration data/count, sequence length, and seed. | ||
| A changed quantization setting is a new PTQ candidate and must be evaluated | ||
| before QAD. In the master-rank `.quant_summary.txt`, require finite positive | ||
| `amax` for enabled static quantizers; accept `dynamic`/format-defined `None` | ||
| only when the recipe intends it. Treat the summary as rank-local under model | ||
| parallelism. | ||
| 3. **Choose topology explicitly.** Derive the smallest fitting node count and | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the sequence length fixed to 32k? the agent should ask the user for their goal for QAD (including what benchmarks) and adjust the sequence length accordingly. for example if user cares about long context benchmarks or SciCode then a longer sequence length is necessary for QAD |
||
| TP/PP/CP/EP/ETP from student and teacher architecture, 32K activation memory, | ||
| and available GPU memory. Prefer CP before TP for small long-context models; | ||
| keep EP=1 for dense models. For MoE require: | ||
|
|
||
| - `DP = world_size / (TP * PP * CP)` | ||
| - `EDP = world_size / (ETP * EP * PP)` | ||
| - integral DP/EDP, `num_experts % EP == 0`, and | ||
| `GBS % (MBS * DP) == 0` | ||
|
|
||
| 4. **Prepare the full capped dataset once.** Copy | ||
| `examples/megatron_bridge/data/nemotron-cascade-2-blend.yaml`, set the target | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the dataset also should not be fixed. it's okay that currently only 1 dataset is supported, but maybe make it clear that we can support more datasets later
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does it say generate random samples for packed 32k sequence and validation data? how is the validation data created |
||
| tokenizer and workspace path, and materialize it before training. Use the | ||
| generated random sample for packed 32K sequences and its 1% validation | ||
| holdout; do not download separate validation data or use mock data as | ||
| evidence. | ||
| 5. **Run and monitor QAD.** Run one QAD training job at a time and fold startup | ||
| validation into it; do not submit separate GPU preflight jobs or split at | ||
| recovery iterations. Let training continue while evaluating saved | ||
| checkpoints, and cancel it when a stop condition below is met. | ||
|
|
||
| ## Default training policy | ||
|
|
||
| | Setting | Default | | ||
| | --- | --- | | ||
| | Sequence length | 32768 | | ||
| | Peak / minimum LR | `1e-5` / `1e-6` | | ||
| | LR schedule | cosine | | ||
| | Training cap | 1000 iterations | | ||
| | Global batch size | 512 | | ||
| | Dataset | `nvidia/Nemotron-Cascade-2-SFT-Data` | | ||
| | Materialized token budget | 17.3B, prepared once before training | | ||
| | Training validation | every 25 iterations; deterministic 1% holdout; 2 batches | | ||
| | Checkpoint interval | 50 iterations | | ||
| | Loss logging | every 10 iterations | | ||
| | Recovery benchmark | 150, then every 100 iterations while training runs | | ||
| | Slurm duration exit | 220 minutes for a 4-hour allocation | | ||
|
|
||
| ## Run policy | ||
|
|
||
| - Keep `train_iters=1000` and leave `exit_interval` unset. | ||
| - From initial step timing, submit only enough sequential jobs to reach | ||
| checkpoint 150; never submit through iteration 1000 upfront. At each recovery | ||
| checkpoint, submit to the next only after its targeted evaluation and any | ||
| triggered full suite, and only if the BF16 gap remains at least 1% and | ||
| recovery has neither plateaued nor regressed. | ||
| - Give all training jobs the same run-specific job name and | ||
| `--dependency=singleton`; record job IDs and, on any stop, cancel pending jobs | ||
| before the active job. | ||
| - Cancel on non-finite loss, repeated skipped iterations, or a sustained spike. | ||
| At iteration 50, require the loss aggregate to be lower than at iteration 10. | ||
| - At each recovery checkpoint, first evaluate the one to three benchmarks with | ||
| the largest PTQ drops. Run the remaining original PTQ suite at that checkpoint | ||
| only after recovery beyond run noise. | ||
| - Cancel when the full-suite gap to BF16 is below 1%, benchmark recovery | ||
| regresses beyond run noise, or benchmark recovery and loss both plateau. | ||
| - After a duration exit, resume the latest QAD checkpoint in the same output | ||
| directory with unchanged prepared data paths/cache, seed, topology, optimizer, | ||
| scheduler, iteration, and consumed-sample state; do not restart from PTQ. | ||
| - Report the PTQ recipe, data sample, Slurm topology, loss/state, checkpoints, | ||
| and comparable BF16/PTQ/QAD results. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../.agents/skills/qad |
|
mxinO marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # Set to the target model's Hugging Face ID or local tokenizer path. | ||
| tokenizer: <target-model-tokenizer> | ||
| output_dir: <session-model-workspace>/data/nemotron-cascade-2-through-1000 | ||
| target_tokens: 17_300_000_000 | ||
| sources: | ||
| - hf_dataset: nvidia/Nemotron-Cascade-2-SFT-Data | ||
| config: math | ||
| split: train | ||
| content_field: messages | ||
| weight: 21.1 | ||
| - hf_dataset: nvidia/Nemotron-Cascade-2-SFT-Data | ||
| config: science | ||
| split: train | ||
| content_field: messages | ||
| weight: 10.9 | ||
| - hf_dataset: nvidia/Nemotron-Cascade-2-SFT-Data | ||
| config: chat | ||
| split: train | ||
| content_field: messages | ||
| weight: 56.2 | ||
| - hf_dataset: nvidia/Nemotron-Cascade-2-SFT-Data | ||
| config: instruction_following | ||
| split: train | ||
| content_field: messages | ||
| weight: 3.3 | ||
| - hf_dataset: nvidia/Nemotron-Cascade-2-SFT-Data | ||
| config: safety | ||
| split: train | ||
| content_field: messages | ||
| weight: 0.02 | ||
| - hf_dataset: nvidia/Nemotron-Cascade-2-SFT-Data | ||
| config: conversational_agent | ||
| split: train | ||
| content_field: messages | ||
| weight: 3.3 | ||
| - hf_dataset: nvidia/Nemotron-Cascade-2-SFT-Data | ||
| config: swe | ||
| split: train | ||
| content_field: messages | ||
| weight: 1.8 | ||
| - hf_dataset: nvidia/Nemotron-Cascade-2-SFT-Data | ||
| config: terminal_agent | ||
| split: train | ||
| content_field: messages | ||
| weight: 3.3 |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these tests seem unnecessary and can be removed |
Uh oh!
There was an error while loading. Please reload this page.