Skip to content

[ROCm] Use ASSERT_NEAR for final LSTM states in BidirectionalLSTMReverseForward - #199922

Closed
pablo-garay wants to merge 1 commit into
pytorch:mainfrom
pablo-garay:fix-rocm-bidirectional-lstm-reverse-test
Closed

pablo-garay wants to merge 1 commit into
pytorch:mainfrom
pablo-garay:fix-rocm-bidirectional-lstm-reverse-test

Conversation

@pablo-garay

@pablo-garay pablo-garay commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RNNTest.BidirectionalLSTMReverseForward_CUDA in cpp/test_api fails consistently on ROCm MI210 (linux-jammy-rocm-py3.11-mi200, original run plus 2 reruns), e.g. https://github.com/pytorch/pytorch/actions/runs/37407982276/job/112113883767:

test/cpp/api/rnn.cpp:544: Failure
Expected equality of these values:
  std::get<0>(std::get<1>(bi_output))[1][0][0].item<float>()
    Which is: -0.240088522
  std::get<0>(std::get<1>(reverse_output))[0][0][0].item<float>()
    Which is: -0.240088537

Root cause: the ROCm 6.3 upgrade (#142152) switched the per-timestep output comparison in this test to ASSERT_NEAR with tolerance = 1e-5, but left the final hidden/cell state (h_n/c_n) checks as exact ASSERT_EQ. Those checks never actually ran on ROCm because test_api collected 0 tests there until #199440 ("Fix C++ tests silently not running on ROCm CI") landed. Now that it runs, h_n differs by ~1.5e-8 (float32 rounding). The reverse-direction h_n is the same value as the last reverse output the loop already compares with tolerance, so the exact check is inconsistent within the test itself.

Fix: use ASSERT_NEAR with the test's existing tolerance for the h_n and c_n checks. No new tolerance is introduced; CPU and CUDA behavior is unaffected beyond allowing the same 1e-5 slack already used for outputs.

Testing: the observed difference (1.5e-8) is well within the existing 1e-5 tolerance; relying on ROCm CI for the C++ test run.

This PR was authored with the help of an AI assistant.

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

…rseForward

The per-timestep output comparison already uses ASSERT_NEAR with a 1e-5 tolerance since the ROCm 6.3 upgrade, but the final hidden and cell state checks still used exact ASSERT_EQ. Now that C++ tests actually run on ROCm CI, the h_n check fails on MI210 by about 1.5e-8. Apply the same tolerance to h_n and c_n.

Signed-off-by: pablo-garay <[email protected]>
@pytorch-bot

pytorch-bot Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/199922

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 303d291 with merge base 3374f39 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pablo-garay

Copy link
Copy Markdown
Contributor Author

@pytorchbot label ciflow/rocm-mi200

@pytorch-bot

pytorch-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

The ciflow label(s) ciflow/rocm-mi200 will be added, but CI won't be triggered until the workflows are approved (scroll to the bottom of this page).

Please ping one of the reviewers if you do not have access to approve and run workflows.

@pytorch-bot pytorch-bot Bot added the ciflow/rocm-mi200 Trigger "default" config CI on ROCm MI200 label Oct 6, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@jeffdaily jeffdaily 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.

LGTM. The per-step outputs already use ASSERT_NEAR with this tolerance, so the final h_n/c_n checks now match; the observed ~1.5e-8 difference is float32 rounding, which this test only started seeing on ROCm once test_api actually ran there (#199440).

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 7, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

cyyever pushed a commit to BakeLab/pytorch that referenced this pull request Oct 11, 2026
…rseForward (pytorch#199922)

`RNNTest.BidirectionalLSTMReverseForward_CUDA` in `cpp/test_api` fails consistently on ROCm MI210 (`linux-jammy-rocm-py3.11-mi200`, original run plus 2 reruns), e.g. https://github.com/pytorch/pytorch/actions/runs/37407982276/job/112113883767:

```
test/cpp/api/rnn.cpp:544: Failure
Expected equality of these values:
  std::get<0>(std::get<1>(bi_output))[1][0][0].item<float>()
    Which is: -0.240088522
  std::get<0>(std::get<1>(reverse_output))[0][0][0].item<float>()
    Which is: -0.240088537
```

**Root cause:** the ROCm 6.3 upgrade (pytorch#142152) switched the per-timestep output comparison in this test to `ASSERT_NEAR` with `tolerance = 1e-5`, but left the final hidden/cell state (`h_n`/`c_n`) checks as exact `ASSERT_EQ`. Those checks never actually ran on ROCm because `test_api` collected 0 tests there until pytorch#199440 ("Fix C++ tests silently not running on ROCm CI") landed. Now that it runs, `h_n` differs by ~1.5e-8 (float32 rounding). The reverse-direction `h_n` is the same value as the last reverse output the loop already compares with tolerance, so the exact check is inconsistent within the test itself.

**Fix:** use `ASSERT_NEAR` with the test's existing `tolerance` for the `h_n` and `c_n` checks. No new tolerance is introduced; CPU and CUDA behavior is unaffected beyond allowing the same 1e-5 slack already used for outputs.

**Testing:** the observed difference (1.5e-8) is well within the existing 1e-5 tolerance; relying on ROCm CI for the C++ test run.

This PR was authored with the help of an AI assistant.

Pull Request resolved: pytorch#199922
Approved by: https://github.com/jeffdaily

This branch was previously deployed

1 inactive deployment
bedrock — 303d291b Deployed Oct 6, 2026 by pytorchbot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triage-error ciflow/rocm-mi200 Trigger "default" config CI on ROCm MI200 ciflow/trunk Trigger trunk jobs on your pull request Merged module: rocm AMD GPU support for Pytorch open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants