Skip to content

Fix AMD 8-GPU-feature CI#3896

Open
yuankaichen-amd wants to merge 3 commits into
pytorch:mainfrom
yuankaichen-amd:rocm-flex-eager-determinism
Open

Fix AMD 8-GPU-feature CI#3896
yuankaichen-amd wants to merge 3 commits into
pytorch:mainfrom
yuankaichen-amd:rocm-flex-eager-determinism

Conversation

@yuankaichen-amd

Copy link
Copy Markdown
Contributor

Compiled ROCm flex attention (torch.compile(flex_attention)) on gfx950 is run-to-run unstable without explicit kernel_options and amplifies tiny (~1e-6) bf16 activation drift between FSDP8 all-gather and HSDP(4,2) replicate paths, causing step-1 loss mismatches that fail the exact --assert-equal parity check. Run flex attention eagerly (uncompiled) in --debug.deterministic mode on ROCm, which matches varlen FA parity exactly. CUDA keeps the compiled (max_autotune disabled) path unchanged.

Refresh the ROCm llama3 reference loss file to match the eager-flex curve.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 10, 2026
@pytorch-bot

pytorch-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/8gpu

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

chunfangamd and others added 2 commits July 10, 2026 08:14
Compiled ROCm flex attention (torch.compile(flex_attention)) on gfx950 is
run-to-run unstable without explicit kernel_options and amplifies tiny
(~1e-6) bf16 activation drift between FSDP8 all-gather and HSDP(4,2)
replicate paths, causing step-1 loss mismatches that fail the exact
--assert-equal parity check. Run flex attention eagerly (uncompiled) in
--debug.deterministic mode on ROCm, which matches varlen FA parity exactly.
CUDA keeps the compiled (max_autotune disabled) path unchanged.

Refresh the ROCm llama3 reference loss file to match the eager-flex curve.

Co-authored-by: Cursor <cursoragent@cursor.com>
The previous reference was generated while another job contended for the
GPUs, introducing ~1e-6 run-to-run numerical drift. Regenerated from a
fresh FSDP8 eager-flex run on an uncontended node; two back-to-back runs
now produce bitwise-identical losses, so the exact --assert-equal
reference check reproduces reliably.

Co-authored-by: Cursor <cursoragent@cursor.com>
@tianyu-l tianyu-l requested a review from drisspg July 10, 2026 20:17
@drisspg

drisspg commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

@yuankaichen-amd can you explain why you rocm is not deterministic

@yuankaichen-amd

Copy link
Copy Markdown
Contributor Author

@drisspg we find that the computation of dq and dk in the backward kernel in compiled mode is non-deterministic due to the numerical difference caused by dynamic reduction order.

I don't know how CUDA passes it. But the compiled mode uses FlashAttention which algorithmically does not guarantee determinism. The eager mode is the dense attention implementation which is algorithmically deterministic.

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

Labels

ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot. module: rocm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants