Repository navigation
FP8 on XPU: allow on the fly FP8 loading through the torchao path - #19024
Merged
danielhanchen merged 4 commits intoNov 23, 2026
Merged
Conversation
Member
|
@codex review |
1 similar comment
Member
|
@codex review |
Codex Review Summary: ✅ CompletedThis 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. |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
danielhanchen
added a commit
that referenced
this pull request
Nov 23, 2026
…ut, kill on timeout (#19044) ## Summary `(Python 3.13, diffusion)` intermittently fails `studio/backend/tests/test_diffusion_ddp_effective_precision.py::test_real_gloo_two_ranks[fp8,fp8-SAME]` with `subprocess.TimeoutExpired` after 180 s, for example the staging run for #19024 on a base that already has #19027. Locally the test takes about 1.4 s per case, so this is a hang, not a slow runner. The log has nothing to go on: the two ranks' stderr is not captured, a rank stuck in a Gloo collective waits out Gloo's 30 minute default, and on timeout the children are left running. ## Change `studio/backend/tests/test_diffusion_ddp_effective_precision.py` only; no product code changes, and the checks are the same. - Child: `init_process_group(..., timeout=timedelta(seconds=60))`, so a stuck collective raises inside the rank with its own error instead of hanging. - Parent: each rank writes stdout and stderr to files under `tmp_path` instead of pipes, so one rank cannot block on a full pipe while the other is being waited on. - Both ranks share one 180 s deadline. On expiry both are killed and the test fails with each rank's return code, stdout and stderr, so the next occurrence names the stuck rank and where it was. - A nonzero exit also reports both ranks' output. This bounds the hang and makes it diagnosable; it does not claim a root cause, since no failing run has captured the ranks' output yet. ## Testing - The file: 13 passed, also under `-n 2`. - Sabotage, rank 1 stalled before `init_process_group` (deadline shortened for the check): the test fails after the deadline with `rank 0 rc=-9` / `rank 1 rc=-9` and both outputs, and no child process is left behind. - Sabotage, rank 1 exits right after init: rank 0 reports the closed connection and the test fails on the verdict within seconds.
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
Enables on the fly
load_in_fp8on Intel XPU through the torchao path. Currently_get_fp8_mode_and_check_settingsonly allows CUDA sm90+, so on XPUFastLanguageModel.from_pretrained(..., load_in_fp8 = True)on a model with no pre-quantized FP8 repo fails with the error:On the fly load_in_fp8 requires H100 GPUs or after. XPU is already supported on torchao's FP8 hardware check for rowwise and 1x128/128x128 block scaling.Changes
unsloth/models/loader_utils.py,_get_fp8_mode_and_check_settings:fast_inference = False.fast_inference = Trueraisesneeds fast_inference = False. (vLLM's on the fly FP8 on XPU is not validated in this PR)tests/test_fp8_onthefly_device_gate.py- New tests on a mocked device. Tests:fast_inference = Truetorchao < 0.18.0Float8Tensorround trips through torchao's safetensors loaderBehavior on CUDA
Unchanged. CUDA still needs sm90+ and torchao 0.15.0+.
Tests
Unit Tests
tests/test_fp8_onthefly_device_gate.py: 16 passed.tests/test_fp8_offline_quantize_gate.pyandtests/test_fp8_device_gate.py: 50 passed.Ran 10 LoRA SFT steps using
unsloth/alpaca-cleaneddataset on an Intel Arc Pro B60 withunsloth/Qwen2.5-0.5B-Instruct, which has no FP8 repo, on transformers 5 and torchao 0.18. The script setsload_in_fp8 = Truefor rowwise torchao path.Environment:
2.13.0+xpu3.7.20.18.05.17.00.24.00.20.02026.11.102026.11.9Summary:
Float8TensorRun results (FP8 vs bf16)
grad_normgrad_norm10 LoRA SFT steps on transformers 4.57.3, with the same model, dataset, LoRA settings and other packages as above:
load_in_fp8 = "block": Unsloth saves the quantized checkpoint aspytorch_model.bin, reloads it with 168Float8Tensorweights and trains (loss 1.3337 -> 1.6110).load_in_fp8 = True: 168Float8Tensorweights, trains (loss 1.3468 -> 1.6234).Block mode on transformers 5 (all devices)
Observed with transformers 5.17.0 / 5.18.0 and torchao 0.18.0:
load_in_fp8 = "block"failed to reload its quantized checkpoint withFailed to find class PerBlock, on CUDA as well as XPU and CPU. transformers 5 writesmodel.safetensorseven withsafe_serialization = False, and torchao's safetensors loader allow-listsPerRowbut notPerBlock(torchao 0.15 through main)._get_fp8_mode_and_check_settingsnow registersPerBlockin torchao'sALLOWED_CLASSES(idempotent, skipped when the module is absent), so block mode loads and trains on transformers 5 on every device.Verified on a Colab RTX PRO 6000 (sm120), torch 2.14.1, transformers 5.18.0, torchao 0.18.0,
unsloth/Qwen2.5-0.5B-Instruct, 3 LoRA steps:Failed to find class PerBlock)