Repository navigation
Studio image: read the hosted int8 ConvRot DiT as W8A8 on ROCm for an explicit int8 pick (FLUX.3 Klein, Qwen-Image-2.1) - #18951
Conversation
… explicit int8 pick On ROCm RDNA an explicit int8 pick for FLUX.3 Klein or Qwen-Image-2.1 fetched the dense bf16 transformer shards and quantised them at load into the native W8A8 ConvRot build, while the family's hosted int8 ConvRot file already holds exactly that build. The planner now seeds that file on ROCm for an explicit int8 pick on the compiled RDNA tier and the seed reads it as native W8A8 Linears. AUTO, CUDA and weight-only families keep their routes. Kill switch UNSLOTH_ROCM_IMAGE_HOSTED_INT8=0.
… does FLUX.3 Klein's hosted int8 ConvRot file stores norm_q / norm_k as float32, the modules Flux3Transformer2DModel keeps in float32 under a bf16 from_pretrained, so the reader refused it as a non-bf16 dense tensor. Allow float32 for the class's _keep_in_fp32_modules, as the pickle reader already does. LTX-2.5 has no keep list.
Hosted repo sources only, the ConvRot safetensors build only, the load re-asks the compiled RDNA int8 gates before it keeps the seed, and the float32 keep-list rule is an opt-in the image caller takes (the video callers keep the strict bf16 rule).
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 |
|
@codex review |
… base A fine-tune with the family's shapes loaded the official ConvRot codes strict=True when UNSLOTH_PREQUANT_HEADER_PROBE=0 skipped the planning header check. The native safetensors reader now requires a matching base_model_id whenever the caller names a base, as the pickle and torchao readers already do.
…n and load A mirror holding only the plain INT8 file let planning skip the dense shards for the ConvRot file while the loader's mirror-first resolver returned the plain file, refused it, and restored the dense shards. rocm_convrot_source narrows the source to its -ConvRot.safetensors names; the planner's header probe and the loader's resolver both use it. [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
…asured gfx1151
rocm_image_hosted_int8_reason now also needs the target card's own gfx arch,
read by its ordinal through rocm_bf16._device_gfx_arch, to be in
ROCM_IMAGE_HOSTED_INT8_ARCHS = {gfx1151}. The RDNA W8A8 kernels accept every
gfx11xx / gfx12xx card, but only gfx1151 was measured; gfx1100 / gfx1201 and
an unreadable arch keep quantising the dense shards at load. CUDA never asks
for an arch.
LTX-2.5's own base matches the base_model_id its official hosted int8 ConvRot file carries, so the base check the shared reader now applies to every read with a base leaves the video route unchanged; another base is refused. [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
[skip ci]
… hosted int8 read takes [skip ci]
|
@codex review |
|
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". |
Summary
On ROCm (gfx1151), an explicit int8 pick for FLUX.3 Klein or Qwen-Image-2.1 downloaded the dense bf16 transformer shards and quantised them at load into the native W8A8 ConvRot build. The family's hosted
*-INT8-ConvRot.safetensorsalready holds that build: the same 228 / 224 layers, the same g256 rotation, per-row int8 codes and float32 scales. This PR reads the hosted file as native W8A8 Linears for that pick, the same way #18903 does for LTX-2.5 video. Generation speed and VRAM do not change. Warm loads take about half as long, the DiT download is about half the size, and host RSS is lower.Root cause:
dense_transformer_supported), so ROCm never seeded a hosted denoiser and always kept the dense shards.denoiser_prequant_pipe_kwargs) only knew the torchao reader, which ROCm cannot use.load_native_from_hosted) refused FLUX.3's file, which storesnorm_q/norm_kas float32. A bf16from_pretrainedalso keeps those in float32 (_keep_in_fp32_modules).Changes
diffusion_rocm_hosted_int8.py(new):rocm_image_hosted_int8_reason()qualifies a load only when all of these hold:rdna_explicit_int8_reason);rdna_explicit_w8a8orrdna_auto_w8a8, orUNSLOTH_NATIVE_INT8_ACT=1). The hosted file is W8A8 only;rocm_bf16._device_gfx_arch, is a measured arch (ROCM_IMAGE_HOSTED_INT8_ARCHS = {"gfx1151"}). The RDNA W8A8 kernels accept every gfx11xx / gfx12xx card, but only gfx1151 has speed and quality numbers, so gfx1100 / gfx1101 / gfx1201 and an unreadable arch keep quantising the dense shards at load. CUDA never asks for an arch.load_rocm_hosted_transformer()accepts only the ConvRot safetensors file and reads it throughload_native_from_hosted. The planner's source probe, the download plan and the resolver share one ConvRot-only candidate list (rocm_convrot_source), so a mirror holding only the plain int8 file cannot make the plan pick one file and the load another.diffusion.py:_pipeline_planned_denoiser_schemenow asks_rocm_hosted_int8_seedinstead of returning None. That helper applies the same gates as the load's compiled RDNA int8 tier (pipeline, no forced offload, a compiling speed tier,compile_eligible), takes hosted repo sources only, and requires a resident plan.diffusion_denoiser_prequant.py: on such a host the seed goes through the native reader. A refusal returns{}, which already restores the dense shards and re-plans at bf16.diffusion_native_hosted.py:keep_fp32opt-in (image caller only) that allows float32 where the class keeps it, as the pickle reader already does. The video callers keep the strict bf16 rule.tagargument so the image log lines readdiffusion.rocm_hosted_int8:. The default output is unchanged.base, the reader now refuses a checkpoint whose headerbase_model_idis missing or names another base, even withUNSLOTH_PREQUANT_HEADER_PROBE=0. This also applies to the video reads (Studio video: read the hosted int8 ConvRot DiT as W8A8 on ROCm for an explicit int8 pick #18903 and Studio video: load explicit int8 LTX-2.5 on Windows ROCm from the hosted int8 DiT #18958 passbase = fam.base_repofor LTX-2.5). It does not change them for the official file, whose header carriesLightricks/LTX-2.5-Diffusers(a test checks LTX-2.5's own base against that value); a checkpoint baked for another base is now refused there too, which is the intended behaviour.Kill switch
UNSLOTH_ROCM_IMAGE_HOSTED_INT8=0(checked before any host query);UNSLOTH_NATIVE_INT8_ACT=0also keeps the old path.Z-Image is not turned on. Its explicit int8 on RDNA is weight-only, and the hosted file is W8A8. Measured W8A8 is 11% faster but further from bf16 (LPIPS 0.018 to 0.023, against 0.012 for weight-only), so it stays weight-only. With
UNSLOTH_NATIVE_INT8_ACT=1it reads the hosted file (measured below).MiniMax-H3-Image is untouched. Its family has no runtime ConvRot spec and
supports_torch_compile=False, so it never reaches the compiled RDNA int8 tier.Tests:
tests/test_diffusion_rocm_hosted_int8.py(new, 56 cases) covers the gates, the measured-arch gate (gfx1151 / gfx1100 / gfx1101 / gfx1201 / unknown, read by the target ordinal), kill switches, Auto, CUDA, weight-only and unsupported families, local overrides, non-ConvRot files, the planner and the seed.tests/test_video_native_hosted.pygets cases for the float32 opt-in, the base check and LTX-2.5's official header.CUDA is unchanged by construction. Every new branch sits behind
not dense_transformer_supported(target)plusrdna_explicit_int8_reason, which requires a ROCm device. The video callers of the shared reader keep their float32 rule; the only change for them is the base check above.Results (gfx1151, ROCm 7.13, torch 2.11, 1024x1024)
Base = merge base d480a0a, head = base + this patch, same runner and job, fresh process per cell, 4 cells per arm in ABBA order. FLUX.3 Klein ran 16 steps, Qwen-Image-2.1 12 steps, Z-Image Turbo 8 steps. LPIPS (alex) and PSNR are against the bf16 DiT image of the same run, scored on CPU.
UNSLOTH_NATIVE_INT8_ACT=1diffusion.rocm_hosted_int8: read 228 int8 ConvRot layers of transformer from the hosted checkpoint as native Linears in 7.2 s. FLUX.3 also logs228 native int8 Linears on the ROCm RDNA W8A8 kernels share one rotation + act quant per block, so the fused shared quant still engages. No head cell fell back.rdna_auto_w8a8) and would see the same quality gain from the hosted file. AUTO is left unchanged in this PR. One prompt per family was measured.Not covered
ROCM_IMAGE_HOSTED_INT8_ARCHSper arch once a card is measured.read 228 int8 ConvRot layers of transformer from the hosted checkpoint as native Linears in 8.4 s; Qwen-Image-2.1 logsread 224 ... in 6.8 s. No base cell reads the hosted file.Test plan
python -m pytest tests/test_diffusion_rocm_hosted_int8.py tests/test_video_native_hosted.py(56 + 15 passed)test_diffusion_pipeline_prequant.py,test_video_hosted_int8_offload.py,test_diffusion_backend.py,test_video_backend.pyand others): head and base fail the same test IDs (pre-existing), no new failures