Repository navigation
Carry the float8 training mode into the parallel capability query - #16637
Merged
Merged
Conversation
_mode only returned lora, qlora or full, so the cp x precision and tp / pp x precision rules never matched a real model and float8 training ran unguarded under context and pipeline parallel (tensor parallel only refuses fp8 checkpoint weights). The query now reports fp8 when the model was loaded with float8_training for LoRA, when fp8 LoRA bases are attached, or when torchao Float8Linear layers are present. Models without these markers keep the lora, qlora and full detection.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…not fp8 enable_fp8_lora leaves an empty bases tuple when no layer is eligible, so the request marker alone no longer reports fp8. Also read _unsloth_float8_linears only as a non-empty list or tuple. [skip ci]
[skip ci]
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The capability registry has two rules for low precision training,
cp x precisionandtp / pp x precision, and alow_precisionfeature. All three testq.mode in ("fp8", "nvfp4", "mxfp8"), but_mode(model)only ever returnedlora,qloraorfull. On a real model the rules never fired, so float8 training ran unguarded under pipeline parallel and context parallel. Tensor parallel only refuses fp8 checkpoint weights (tp_native._refuse_base), which does not cover fp8 LoRA bases or torchaoFloat8Linear, since both keep a 16-bit weight.Change
unsloth/parallel_capabilities.py:_low_precision(model)returns"fp8"when the model carries one of the markers the float8 code actually sets:_unsloth_fp8_lora_recipe(frommark_fp8_loraat load, before the adapters exist, for exampleSFTTrainer(peft_config = ...)), looked up throughbase_model/modellike_fp8_lora_request;__dict__["_unsloth_fp8_lora"](attach_fp8_lora_base);_unsloth_float8_linears, or a torchaoFloat8Linearmodule (convert_model_to_float8_training, full finetuning).enable_fp8_lorahas run: when no layer was eligible it leaves an empty bases tuple and training stays in 16 bit, so that model keeps its 16-bit mode._unsloth_float8_linearscounts only as a non-empty list or tuple._modechecks it first. Without a marker the lora / qlora / full detection is unchanged.plannedinprecision/recipes.py, andresolve_float8_trainingrefuses them by name), so nothing sets those modes. The rule predicates still list them.Order at the entry points: the Trainer
__init__wrapper runs_parallel_capabilities_pre(which callscheck_layoutwith the model) before the pipeline split and the tensor parallel apply in the same wrapper. Context parallel callscheck_layoutbefore the trainer__init__. So a refused launch leaves the model unsplit. One caveat: withUNSLOTH_TP_SIZEalone, sharded loading andget_peft_modelshard the model before the Trainer exists. In that case the refusal comes at the Trainer, before training starts, not before the shard.Behaviour change:
modeis nowfp8for these models instead oflora/full, so they no longer match the LoRA / full-finetuning evidence cells. WithoutUNSLOTH_PARALLEL_STRICT=1nothing changes for fp8 under DDP or FSDP2 (an unverified cell only refuses when gated). With strict on, fp8 under DDP or FSDP2 is now reported as unverified, since no cell carries fp8 evidence yet. Thelora/fullfeatures only declare hooks, not exclusive ones, so the composition check loses nothing.Testing
New
tests/test_parallel_capabilities_precision.py, CPU only. It uses the tiny Qwen3 config with its widths raised to the fp8 minimum (dims % 16, otherwise no layer converts). The fp8 LoRA bases are attached through the realenable_fp8_lora(allow_cpu = True), and full finetuning goes throughconvert_model_to_float8_trainingwith an emulatedFloat8LinearConfig. The test checks that cp 2, tp 2, pp 2 and cp 2 x tp 2 raise the precision rule with parameter data pointers, devices and dtypes unchanged, and that the Trainer pre-init check refuses underUNSLOTH_PP_SIZE/UNSLOTH_TP_SIZEbefore the split. It also checks that dp alone (DDP, FSDP2) is not refused, and that models without a marker keepfull/lora/qlora.test_parallel_capabilities_precision.py(rebased on current main)lora/full, no rule fires; the no-eligible-layer case passes on both, since main never reports fp8)test_parallel_env.py,test_context_parallel_compose_refusal.py,test_parallel_cp_compose_gloo.py,test_tp_native_oracle.py,test_float8_training.py,test_fp8_lora.py,test_precision_registry.py,test_float8_training_fsdp2_gloo.pyGPU-marked tests were not run (CPU-only host session).