Skip to content

[ROCm] Fix GPU memory fault in batched_unary_embeddings backward - #164

Open
avbokovoy wants to merge 1 commit into
mainfrom
abokovoi/fix-batched-unary-embeddings-backward-test
Open

[ROCm] Fix GPU memory fault in batched_unary_embeddings backward#164
avbokovoy wants to merge 1 commit into
mainfrom
abokovoi/fix-batched-unary-embeddings-backward-test

Conversation

@avbokovoy

Copy link
Copy Markdown

Problem

batched_unary_embeddings_test.py::test_gpu crashed with a GPU memory access fault on ROCm. The permute sub-test passed
offsets of length 8 (7 segments) for a T=2 module, violating the op's offsets.numel() == T*B+1 contract. Forward silently truncated
B=3 and dropped the trailing segment; backward walked all 7 segments, deriving an out-of-range table id t=2 that indexed
grad_weight out of bounds.

Fix

  • Correct the test offsets to [0..8] (9 entries -> T*B+1 for B=4).
  • Add host-side TORCH_CHECK guards on the offsets length in forward (CPU/CUDA/HIP) and backward (CUDA/HIP), so malformed input fails loudly instead of faulting/corrupting grads.

@avbokovoy avbokovoy self-assigned this Aug 18, 2026

@aryaman-gupta aryaman-gupta left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants