Skip to content

Studio: load plain FP8 encoder safetensors without torchao - #12333

Merged
danielhanchen merged 2 commits into
unslothai:mainfrom
oobabooga:fix/amd-plain-fp8-encoder
Sep 30, 2026
Merged

danielhanchen merged 2 commits into
unslothai:mainfrom
oobabooga:fix/amd-plain-fp8-encoder

Conversation

@oobabooga

Copy link
Copy Markdown
Member

On Windows ROCm, Studio rejects the Qwen-Image-2.1 FP8 text-encoder safetensors because the generic prequant capability check requires torchao serialization helpers. It then tries an unavailable .pt artifact and falls back to loading the dense encoder and casting it to FP8. The supplied encoder contains ordinary tensors and does not need torchao.

Fix

Read plain encoder safetensors directly through safetensors.safe_open, and use that capability when resolving the artifact. Validate the header, tensor names and plain-tensor metadata before reading weights; keep the existing component, scheme, base-model and state-dict checks. The transformer tensor-subclass reader is unchanged.

Tests

Live A/B against main at 4700dbc, using Qwen-Image-2.1 Q4_K_M, Auto memory, 1024x1024, four steps and three renders per variant on Radeon 8060S (gfx1151), Windows and Linux. PyTorch 2.11 / ROCm 7.13; the planner sees 20 GiB total and 19 GiB free, with a 19 GiB PyTorch allocation cap.

After the third render Main This PR
Windows process RAM 45.77 GiB 30.19 GiB
Windows peak GPU allocation 11.27 GiB 11.27 GiB
Linux process RAM 15.16 GiB 15.16 GiB

All six paired images are pixel-identical. Warm generation time is effectively unchanged. Load timing is not comparable because the patched Windows case downloads the newly accessible encoder artifact.

98 focused tests pass, including a real-writer FP8/bias/root-buffer round trip through both readers with torchao disabled for the plain reader. Earlier broader related coverage: 731 pass, one fails on an absent local ./temp/qwen_image_21 fixture; the same test fails with the production files restored to main. Formatting and diff checks pass.

Live A/B run, both OS jobs passed

Scope

This fixes unnecessary dense-encoder loading, not the Auto placement policy or AMD attention performance. The hardware probes in the run artifacts report shared-memory GPUs and 124.95 GiB of host RAM on Linux / 127.15 GiB on Windows; RX 7900 XT behavior and discrete-GPU transfer costs remain untested. Other callers of the shared encoder loader have unit coverage but were not exercised live.

@oobabooga

Copy link
Copy Markdown
Member Author

Reached Codex review convergence at oobabooga#319.

@danielhanchen

danielhanchen commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Review record for #12333, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#256.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror 8d1d64f117 (this PR's 2a8b2bdca)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 8d1d64f117

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror 8d1d64f117 (this PR's 2a8b2bdca).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants