Repository navigation
Studio SDXL LoRA training: route the VAE's attention on ROCm before encoding latents - #18560
Merged
Merged
Conversation
Member
Author
|
@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. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 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.
#17953 fixed wrong training latents on Windows ROCm: the VAE's single-head attention (head dim 512) went through fused SDPA kernels that return garbage at that width. The fix routed the VAE's attention through the exact path inference uses (
diffusion_vae_attn_chunked.install), but only in the DiT trainer. The SDXL LoRA trainer runs in its own training process, never installs the wide-head guard, and encodes every training latent throughpipe.vae, so SDXL LoRA training on Windows ROCm still encoded its latents through the broken kernels.Change
The SDXL trainer calls the same
install(vae)right after the VAE moves to its card, before any latent is encoded.installacts only on ROCm torch (CUDA, MPS and CPU builds return without patching), so nothing changes off ROCm. On ROCm Linux, the VAE takes the same routed path the DiT trainers and inference already use.Tests
test_the_sdxl_trainer_routes_its_vae_attention_before_encoding_latentsruns a real 1-step SDXL LoRA training on the tiny SDXL pipeline with a ROCm torch reported. It checks that the pipeline's AutoencoderKL is patched and that every encoder forward runs after the patch. It fails on main (nothing patched) and passes here.tests/test_diffusion_lora_trainer.pyand the SDXL cases intests/test_diffusion_gc_budget_trainers.py: 62 passed.On Windows gfx1151 (Strix Halo, torch 2.11.0+rocm7.14.0)
The SDXL trainer itself (1 step, tiny SDXL pipeline with the real SDXL VAE swapped in, 256 px): the first training latents it encodes, against a CPU fp32 encode of the same pixels.
On Linux gfx1151 (torch 2.11.0+rocm7.13.0), where the fused kernels are correct at this width, main and this PR give the same latents (relative L2 6.7e-6 against the CPU encode on both, the routed path on this PR).