You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Training with quantized checkpoints (i.e. QAT GRPO) #1099
Currently I don't think it is possible to use quantized checkpoints (containing megatron fakequant layers inserted via modelopt) to learn parameters in the quantized space during GRPO.
This could be done by consuming a PTQ checkpoint exported from modelopt or similar, or a quantized HF model (e.g. GPT-OSS) - or even a modelopt model which is then exported to the HF format. The key part is post-training in the quantized space.
I imagine loading the megatron workers is not particularly hard, and what's more likely a challenge is any refit required for passing parameters to vllm for rollout which I imagine does not expect the "fakequant" layers.
The key motivation here would be to evaluate the effectiveness of learning the quantised weights while training on the actual task rather than appending a PTQ, QAT SFT, or similar step.
Keen to hear @guyueh1's thoughts. I was motivated to try this after reading this nvidia post experimenting with PTQ vs QAT in the SFT case, and wanted to experiment with it in the GRPO case.
I also realise that this might come "for free" once:
That is - if megatron-style weights with FakeQuant layers can be directly imported, and megatron is used for the inference (no refit or architectural mismatches like there might be with vllm), I imagine that it might work without additional effort, but there may be confounding factors I am not accounting for. Although I don't know the timeline for either.
training with fp8 weights (that is, the optimizer step is still in high precision, but the weights is always quantized to fp8 and perform forward/backward);
rollout with the same fp8 weights as used in training. The refit is done by first de-quantizing to hf bf16 weights then quantizing in vllm, but the numerical values in training and rollout weights are the same
I wonder what @nathan-az needs on top of that. I think the above gives you "GRPO in quantized space". What you additionally need is to initially import from a fp8 checkpoint; it could be any hf bf16 checkpoint with values belong to the fp8 representable space, if so we don't need any additional work; if the initial checkpoint is in any quantized format, we need to add a converter, maybe in m-bridge, to load it into mcore model.
Feel free to correct any of my motivations. My specific query is whether configurable quantization (via modelopt) could be used during training. My motivations (perhaps not valid):
supporting megatron checkpoints directly removes the need for a converter in RL
removing the need to refit if megatron can also be used for inference
allowing more straightforward training of models like GPT-OSS with non-standard quantization (in their case fp4 on non-shared expert MLPs) and outputting in the same or similar format, or even QAT with brand new formats (e.g. some mxfp4/nvfp4 version of qwen3 MoE)
The FP8 integration looks great - keen to try it. I hope the above clarifies what I was inquiring about. Essentially I figured that if modelopt-exported megatron models are more "immediately compatible" with training and rollouts, that it would unlock more straightforward QAT.
That said, currently Bridge only supports HF-style checkpoints, and Megatron rollouts (in nemo RL) are quite slow. Let me know if you have any thoughts. Conscious I am far from an expert in megatron/modelopt.
Currently when using fp8 rollout, we mainly use the quant_method="fp8" in vllm, the quant_method="modelopt" is not supported yet but we can if with good motivation; supporting this quantization method will allow you to load a modelopt hf checkpoint at the beginning; but note that during the GRPO, in every refit we still need to convert model from megatron to vllm, and both sides are not aligned in (1) parameter names, (2) tensor names (like weight/weight_scale_inv vs Float8BlockwiseQuantizedTensor), so a converter is still needed. We now do the conversion by dequantizing to BF16 in the middle, in the future we may be able to improve this.
As to
removing the need to refit if megatron can also be used for inference
this will need us to finish developing the megatron-inference backend, it's WIP
From a framework perspective, we provide tools for user to explore their low precision recipes, so we are actively extending the support of low-precision training and rollout, upcoming features will allow users to flexibly choose rollout recipes (fp8 block-quant, fp8, mxfp4), and training recipes (fp8 block-quant, fp8, mxfp8), so that your GRPO algo is validated with low-precision rollout model and can directly generation low-precision checkpoint without PTQ.
the quant_method="modelopt" is not supported yet but we can if with good motivation
It appears vllm expects the model exported with modelopt, but in the HF format.
I have no attachment to leveraging modelopt, especially with vllm - it just seemed like the lowest friction path if megatron-format import and megatron inference was comparably fast.
we are actively extending the support of low-precision training and rollout, upcoming features will allow users to flexibly choose rollout recipes (fp8 block-quant, fp8, mxfp4), and training recipes (fp8 block-quant, fp8, mxfp8), so that your GRPO algo is validated with low-precision rollout model and can directly generation low-precision checkpoint without PTQ.
This is very cool. Looking forward to trying to whatever solution is eventually implemented.
If there are any issues or PRs outstanding related to this, I'd be keen to keep an eye on them.
@nathan-az you can track #943 which is our top-level issue to provide fp8 GRPO recipe targetting H100; as to fp8 block-quant GRPO, there are two PRs to track right now:
Activity
terrykong commentedon Sep 9, 2025
@guyueh1 how much of a lift would you say this is after enabling low precision on the mcore backend?
nathan-az commentedon Sep 9, 2025
Keen to hear @guyueh1's thoughts. I was motivated to try this after reading this nvidia post experimenting with PTQ vs QAT in the SFT case, and wanted to experiment with it in the GRPO case.
I also realise that this might come "for free" once:
That is - if megatron-style weights with FakeQuant layers can be directly imported, and megatron is used for the inference (no refit or architectural mismatches like there might be with vllm), I imagine that it might work without additional effort, but there may be confounding factors I am not accounting for. Although I don't know the timeline for either.
guyueh1 commentedon Sep 15, 2025
Currently we have supported
with #971 merged, we will then support
I wonder what @nathan-az needs on top of that. I think the above gives you "GRPO in quantized space". What you additionally need is to initially import from a fp8 checkpoint; it could be any hf bf16 checkpoint with values belong to the fp8 representable space, if so we don't need any additional work; if the initial checkpoint is in any quantized format, we need to add a converter, maybe in m-bridge, to load it into mcore model.
nathan-az commentedon Sep 15, 2025
Hey @guyueh1 thanks for responding!
Feel free to correct any of my motivations. My specific query is whether configurable quantization (via modelopt) could be used during training. My motivations (perhaps not valid):
The FP8 integration looks great - keen to try it. I hope the above clarifies what I was inquiring about. Essentially I figured that if modelopt-exported megatron models are more "immediately compatible" with training and rollouts, that it would unlock more straightforward QAT.
That said, currently Bridge only supports HF-style checkpoints, and Megatron rollouts (in nemo RL) are quite slow. Let me know if you have any thoughts. Conscious I am far from an expert in megatron/modelopt.
guyueh1 commentedon Sep 22, 2025
Currently when using fp8 rollout, we mainly use the
quant_method="fp8"in vllm, thequant_method="modelopt"is not supported yet but we can if with good motivation; supporting this quantization method will allow you to load a modelopt hf checkpoint at the beginning; but note that during the GRPO, in every refit we still need to convert model from megatron to vllm, and both sides are not aligned in (1) parameter names, (2) tensor names (like weight/weight_scale_inv vs Float8BlockwiseQuantizedTensor), so a converter is still needed. We now do the conversion by dequantizing to BF16 in the middle, in the future we may be able to improve this.As to
this will need us to finish developing the megatron-inference backend, it's WIP
From a framework perspective, we provide tools for user to explore their low precision recipes, so we are actively extending the support of low-precision training and rollout, upcoming features will allow users to flexibly choose rollout recipes (fp8 block-quant, fp8, mxfp4), and training recipes (fp8 block-quant, fp8, mxfp8), so that your GRPO algo is validated with low-precision rollout model and can directly generation low-precision checkpoint without PTQ.
nathan-az commentedon Sep 23, 2025
It appears vllm expects the model exported with modelopt, but in the HF format.
I have no attachment to leveraging
modelopt, especially with vllm - it just seemed like the lowest friction path if megatron-format import and megatron inference was comparably fast.This is very cool. Looking forward to trying to whatever solution is eventually implemented.
If there are any issues or PRs outstanding related to this, I'd be keen to keep an eye on them.
guyueh1 commentedon Sep 23, 2025
@nathan-az you can track #943 which is our top-level issue to provide fp8 GRPO recipe targetting H100; as to fp8 block-quant GRPO, there are two PRs to track right now: