Repository navigation
feat: Adding quantization aware training support with Model-Optimizer - #1756
Conversation
Signed-off-by: Meng Xin <[email protected]>
|
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
|
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. |
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
|
Signed-off-by: Meng Xin <[email protected]>
|
The core changes can be gathered to folder, some minor changes to RL code are still needed. Just restructured. |
|
@mxinO Also Ccing Kinjal @kinjalpatel27 |
The modules support is using modelopt existing ones, the worker patch is somewhat different, it doesn't require calibration because the amax will come from the the policy. |
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Add tests/functional/qa_distillation_megatron.sh that runs 1 step of on-policy QA-Distillation (W4A4 / NVFP4_DEFAULT_CFG, the verified- converging recipe per docs/guides/quantization-aware-rl.md) on Qwen/Qwen3-0.6B with TP=2 PP=1 CP=1, saves a quantized Megatron checkpoint, then invokes the Megatron-Bridge export script (3rdparty/Megatron-Bridge-workspace/Megatron-Bridge/examples/quantization/export.py) to convert the checkpoint into the HuggingFace safetensors layout. The test asserts the export directory ends up with config.json and at least one .safetensors file. Per PR review feedback, the modelopt -> Megatron-Bridge -> HF export pipeline is brittle and benefits from regular regression coverage in addition to the (long-running) nightly distillation test. Wire the new test into tests/functional/L1_Functional_Tests_GPU.sh in the full-mode lane next to distillation_megatron.sh. QAD uses self-distillation (policy and teacher are the same HF model), which is the convention from the qa_distillation_math_megatron.yaml example header — explained in an inline comment so future readers don't second-guess it against the vanilla distillation test. Signed-off-by: Meng Xin <[email protected]>
The bridge quantization export script needs two env tweaks that aren't obvious from its own help: - PYTHONPATH must expose Megatron-LM's `megatron.training` because the bridge script imports it at module load but `--extra mcore` only packages megatron.core from the workspace. - `--tp 1` is required at export time (modelopt currently does not support TP>1 there). Training at TP>1 is fine — the bridge re-shards on load via mp_overrides. `--pp` may be >1 for large models with `--nproc_per_node` matching `--pp`. Update the QARL guide's Exporting Checkpoints section accordingly and align tests/functional/qa_distillation_megatron.sh: train at TP=2 to exercise the cross-TP load path, export at --tp 1 --pp 1. Signed-off-by: Meng Xin <[email protected]>
The L1_Functional_Tests_GPU.sh post-frozen-env block lists tests in alphabetical order. The original add of qa_distillation_megatron.sh clustered it next to distillation_megatron.sh; move it to its proper slot between prorlv2.sh and rm.sh. Signed-off-by: Meng Xin <[email protected]>
Thanks @ashors1 , I've addressed both. For the exporting, the script is totally managed in MBridge, not in Nemo-RL, but I still added a test, but if any issue is raised, the fix should be in MBridge side. |
|
/ok to test |
The pyrefly project-includes whitelist requires that any source file with zero type errors be listed explicitly. The QARL subtree added four empty package markers under nemo_rl/modelopt/models/* which type-check clean and were tripping pyrefly's "zero errors but not in project-includes" guard. Add them in alphabetical order alongside nemo_rl/modelopt/__init__.py. Signed-off-by: Meng Xin <[email protected]>
|
/ok to test |
|
Thank you @mxinO! Could you fix the failing lint check when you get a chance? I think |
Add the four QARL-subtree source files that pyrefly type-checks clean to the project-includes whitelist: - nemo_rl/modelopt/models/generation/vllm_quant_worker.py - nemo_rl/modelopt/models/policy/workers/dtensor_quant_policy_worker.py - nemo_rl/modelopt/models/policy/workers/dtensor_quant_policy_worker_v2.py - nemo_rl/modelopt/registry.py The remaining modelopt files (vllm_quant_backend.py, vllm_quant_patch.py, megatron_quant_policy_worker.py, models/policy/workers/utils.py, modelopt/utils.py) still have type errors and stay out of the whitelist until those are addressed. Signed-off-by: Meng Xin <[email protected]>
|
/ok to test |
What does this PR do ?
Add quantization aware (QA) training, e.g. QA-GRPO, QA-On policy distillation.
Usage
Run a QARL by enabling simulated quantization with modelopt, adding the following config,
Other quantization formats are available, but currently only tensor-wise quantization format are supported.
Before your PR is "Ready for review"
Pre checks:
Additional Information