Skip to content

Optimize bf16 atomicCAS - #6294

Open
yvonne-lab wants to merge 1 commit into
pytorch:mainfrom
yvonne-lab:export-D119529321
Open

Optimize bf16 atomicCAS#6294
yvonne-lab wants to merge 1 commit into
pytorch:mainfrom
yvonne-lab:export-D119529321

Conversation

@yvonne-lab

Copy link
Copy Markdown
Contributor

Summary:
Accumulate into FP32, then cast to BF16

Read BF16 gradients. Scatter-add into an FP32 temporary using hardware unsafeAtomicAdd.
Convert the completed FP32 gradients back to BF16.
This is essentially the strategy already used by the eligible path in D118739790.

This is the safest option. It removes scalar BF16 CAS, improves numerical accuracy, and works on ROCm architectures without relying on packed BF16 atomic support. Its cost is an additional FP32 gradient buffer and final conversion.

Differential Revision: D119529321

Summary:
Accumulate into FP32, then cast to BF16

Read BF16 gradients. Scatter-add into an FP32 temporary using hardware unsafeAtomicAdd.
Convert the completed FP32 gradients back to BF16.
This is essentially the strategy already used by the eligible path in D118739790.

This is the safest option. It removes scalar BF16 CAS, improves numerical accuracy, and works on ROCm architectures without relying on packed BF16 atomic support. Its cost is an additional FP32 gradient buffer and final conversion.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant