Skip to content

[CI] [AMD] diffusion/flux3: Make exact-quality VAE convolutions deterministic on ROCm - #46947

Merged
michaelzhang-ai merged 2 commits into
sgl-project:mainfrom
michaelzhang-ai:ci-fix/flux3-exact-vae-rocm-determinism
Nov 3, 2026
Merged

michaelzhang-ai merged 2 commits into
sgl-project:mainfrom
michaelzhang-ai:ci-fix/flux3-exact-vae-rocm-determinism

Conversation

@michaelzhang-ai

@michaelzhang-ai michaelzhang-ai commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

What

On ROCm, run the FLUX.3 VAE encode and decode with torch.backends.cudnn.deterministic = True for quality="exact" requests. The flag is set only for the duration of the VAE call and restored afterwards. Other platforms and non-exact tiers are unchanged.

Why

TestDisaggFlux3Image::test_t2i_and_edit_match_monolithic has failed on every scheduled PR Test (AMD) rocm10 run since #45309 landed, e.g. this job: text-to-image matches exactly, but the edit differs in ~57% of pixels (max 22).

The disaggregated path isn't the problem. A monolithic server gives a different edit each time the same request is sent (diagnostic run). Text embeddings, noise and the prepared reference are bit-identical between runs. The reference's VAE latents are not: 5-9 of 30720 values differ by one bf16 ulp, and the denoiser amplifies that across the image.

Per-module hooks on the VAE alone (run) show the first divergence at fp32 Conv2d layers whose inputs are identical between runs (encoder.down.3.block.0.conv1, decoder.mid.block_1.conv1). MIOpen picks a non-deterministic kernel for those shapes. GroupNorm and the attention block are deterministic. Eight repeated calls on MI300X:

setting encode distinct outputs encode time decode distinct outputs decode time
default 8/8 6.6 ms 8/8 13.0 ms
cudnn.deterministic 1/8 7.1 ms 1/8 13.4 ms

Test plan

  • PR Test (AMD) multimodal-gen-test-2-gpu-amd, rocm10, dispatched on 177e8f7: both shards pass, including TestDisaggFlux3Image (run, shard 0 job).
  • This PR's own PR Test (AMD) run on 177e8f7: both rocm10 multimodal-gen-test-2-gpu-amd shards pass. TestDisaggFlux3Image::test_t2i_and_edit_match_monolithic is PASSED in shard 0, along with the other 3 tests in test_disagg_server.py (job). The run is red only because of test_ming_image.py::test_ming_norm_fusion_replay_and_native_fallback in 1-GPU shard 3, which this change doesn't touch and which passes on main now.
  • New unit tests in test_flux3_image_stages.py pass in the rocm10 image (10 passed).

CI States

Latest PR Test (Base): ✅ Run #40814696873
Latest PR Test (Extra): ❌ Run #40814696951
Latest PR Test (AMD ROCm 10): ❌ Run #40814696838

…ministic on ROCm

MIOpen's default fp32 convolution kernels are not run-to-run deterministic
for some FLUX.3 VAE shapes, so an image edit with quality="exact" encodes
the same reference to slightly different latents on each request and the
denoiser amplifies that into a visibly different image. This breaks
TestDisaggFlux3Image.test_t2i_and_edit_match_monolithic on ROCm.

Set torch.backends.cudnn.deterministic around the FLUX.3 VAE encode and
decode for exact requests on ROCm only. Other platforms are unchanged.
…act VAE calls

With SGLANG_USE_ROCM_CUDNN_BENCHMARK set, cudnn.benchmark picks the
convolution kernel by timing, which can undo the deterministic choice.
Turn it off for the exact-quality VAE call and restore both flags after,
matching the existing Sana and MiniMax-H3 deterministic helpers. Add unit
tests for the flag handling on ROCm and on other platforms.
@michaelzhang-ai

Copy link
Copy Markdown
Collaborator Author

@mickqian could you take a look? TestDisaggFlux3Image::test_t2i_and_edit_match_monolithic from #45309 has failed on every AMD rocm10 run since it merged. The cause is that MIOpen picks non-deterministic fp32 conv kernels for the FLUX.3 VAE, so the same edit reference encodes to slightly different latents on each request. This PR pins deterministic kernels for quality="exact" VAE calls on ROCm only; details and diagnostic runs are in the description.

QwenApp pushed a commit to QwenApp/sglang that referenced this pull request Nov 2, 2026
…atibility

Install ml-dtypes explicitly for the legacy MUSA vendor bundle, whose
tilelang-musa wheel is installed without dependency resolution.

Backport the exact ROCm VAE convolution context and regression tests from
sgl-project#46947. Preserve the exact image assertions and restore backend flags after
normal completion or exceptions.

Backport the paired fork-worker preload API from merged sgl-project#47592 so the
current CI caller is compatible with the package installed from this branch.

Validated the production VAE context and all three call sites on CPU,
the real runner subprocess/fork paths, nine MUSA helper tests, and the
actual installer command with isolated offline wheel metadata fixtures.
Normal pre-commit checks pass. These local checks do not establish GPU/NPU
CI acceptance or resolve the outstanding PP transport and NPU host allocator
failures.
@michaelzhang-ai
michaelzhang-ai dismissed HaiShaw’s stale review November 3, 2026 05:34

code updated, check comment

@michaelzhang-ai
michaelzhang-ai enabled auto-merge (squash) November 3, 2026 05:34

@yichiche yichiche left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guard with is_hip, LGTM.

@michaelzhang-ai
michaelzhang-ai merged commit 11d6878 into sgl-project:main Nov 3, 2026
170 of 177 checks passed
@michaelzhang-ai
michaelzhang-ai deleted the ci-fix/flux3-exact-vae-rocm-determinism branch November 3, 2026 07:14
Yuxingwang-intel pushed a commit to Yuxingwang-intel/sglang that referenced this pull request Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diffusion SGLang Diffusion run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants