Repository navigation
Conversation
Summary: Adopt the GammaBetaBackwardCUDAKernelTemplate tiled kernel introduced in D72575858 for ROCm, replacing the legacy two-pass cuComputePartGradGammaBeta and cuComputeGradGammaBeta approach. This brings AMD towards Nvidia parity.
Test Plan:
Results:
- Local Benchmark:
- Higher performance across 39 shapes: 1.02x speedup on mi350 (1 pass vs 2 pass implementation)
- Higher numerical accuracy on mi350 vs h100
- Avg rel error vs CPU fp32 (mi350): dgamma=3.040359e-06 dbeta=1.750184e-06
- Avg rel error vs CPU fp32 (h100): dgamma=3.506308e-06 dbeta=1.792510e-06
- E2E Test
- 1.02x speedup in qps
- baseline: 765k
- with diff: 782k
```
Benchmarks:
buck2 run //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \
--correctness --label h100
HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \
//scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \
--correctness --label mi350 --compare h100
HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \
//scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \
--performance --label mi350x_2pass
HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \
//scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \
--performance --label mi350x_1pass --compare mi350x_2pass
```
E2E tests:
Baseline: 765k qps
https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_131047-d9f3209936?job_attempt=0&version=0&tab=tb_legacy
With diff: 782k qps
https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_141250-d9120ce4bb?job_attempt=1&version=0&tab=tb_legacy
Reviewed By: jhadidjojo
Differential Revision: D98176771
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/179019
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 1a6fa9c with merge base a8e6433 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@echen4096 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D98176771. |
| @@ -1010,7 +1014,13 @@ void LaunchGammaBetaBackwardCUDAKernel( | |||
| } else if (M < 256) { | |||
| ConfigureAndLaunchGammaBetaBackwardKernel<T, T_ACC, block_dim_x, 16, 128, rms_norm>(dY_data, X_data, mean_data, rstd_data, M, N, dgamma, dbeta, cuda_stream); | |||
There was a problem hiding this comment.
Should we apply specific changes for ROCm here as well or is this universally perfect?
There was a problem hiding this comment.
The intermediate branches are safe for ROCm as-is since all thread counts stay within GPU limits. That said, there may be tuning opportunities for ROCm - may be worth revisiting in a future PR
There was a problem hiding this comment.
Hello, @echen4096. @benediktjohannes. Could you please help me with Local Benchmark and E2E tests since they behind wall. I think this is time for tuning opportunities for ROCm since this pr causing some perf drops in huggingface models:

|
@pytorchbot merge -i (Initiating merge automatically since Phabricator Diff has merged, merging with -i because oss signals were bypassed internally) |
Merge startedYour change will be merged while ignoring the following 0 checks: Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…179019) Summary: Adopt the GammaBetaBackwardCUDAKernelTemplate tiled kernel introduced in D72575858 for ROCm, replacing the legacy two-pass cuComputePartGradGammaBeta and cuComputeGradGammaBeta approach. This brings AMD towards Nvidia parity. Test Plan: Results: - Local Benchmark: - Higher performance across 39 shapes: 1.02x speedup on mi350 (1 pass vs 2 pass implementation) - Higher numerical accuracy on mi350 vs h100 - Avg rel error vs CPU fp32 (mi350): dgamma=3.040359e-06 dbeta=1.750184e-06 - Avg rel error vs CPU fp32 (h100): dgamma=3.506308e-06 dbeta=1.792510e-06 - E2E Test - 1.02x speedup in qps - baseline: 765k - with diff: 782k ``` Benchmarks: buck2 run //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --correctness --label h100 HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --correctness --label mi350 --compare h100 HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --performance --label mi350x_2pass HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --performance --label mi350x_1pass --compare mi350x_2pass ``` E2E tests: Baseline: 765k qps https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_131047-d9f3209936?job_attempt=0&version=0&tab=tb_legacy With diff: 782k qps https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_141250-d9120ce4bb?job_attempt=1&version=0&tab=tb_legacy Reviewed By: jhadidjojo Differential Revision: D98176771 Pull Request resolved: #179019 Approved by: https://github.com/haoyuz
…ytorch#179019) Summary: Adopt the GammaBetaBackwardCUDAKernelTemplate tiled kernel introduced in D72575858 for ROCm, replacing the legacy two-pass cuComputePartGradGammaBeta and cuComputeGradGammaBeta approach. This brings AMD towards Nvidia parity. Test Plan: Results: - Local Benchmark: - Higher performance across 39 shapes: 1.02x speedup on mi350 (1 pass vs 2 pass implementation) - Higher numerical accuracy on mi350 vs h100 - Avg rel error vs CPU fp32 (mi350): dgamma=3.040359e-06 dbeta=1.750184e-06 - Avg rel error vs CPU fp32 (h100): dgamma=3.506308e-06 dbeta=1.792510e-06 - E2E Test - 1.02x speedup in qps - baseline: 765k - with diff: 782k ``` Benchmarks: buck2 run //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --correctness --label h100 HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --correctness --label mi350 --compare h100 HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --performance --label mi350x_2pass HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --performance --label mi350x_1pass --compare mi350x_2pass ``` E2E tests: Baseline: 765k qps https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_131047-d9f3209936?job_attempt=0&version=0&tab=tb_legacy With diff: 782k qps https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_141250-d9120ce4bb?job_attempt=1&version=0&tab=tb_legacy Reviewed By: jhadidjojo Differential Revision: D98176771 Pull Request resolved: pytorch#179019 Approved by: https://github.com/haoyuz
…179019) Summary: Adopt the GammaBetaBackwardCUDAKernelTemplate tiled kernel introduced in D72575858 for ROCm, replacing the legacy two-pass cuComputePartGradGammaBeta and cuComputeGradGammaBeta approach. This brings AMD towards Nvidia parity. Test Plan: Results: - Local Benchmark: - Higher performance across 39 shapes: 1.02x speedup on mi350 (1 pass vs 2 pass implementation) - Higher numerical accuracy on mi350 vs h100 - Avg rel error vs CPU fp32 (mi350): dgamma=3.040359e-06 dbeta=1.750184e-06 - Avg rel error vs CPU fp32 (h100): dgamma=3.506308e-06 dbeta=1.792510e-06 - E2E Test - 1.02x speedup in qps - baseline: 765k - with diff: 782k ``` Benchmarks: buck2 run //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --correctness --label h100 HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --correctness --label mi350 --compare h100 HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --performance --label mi350x_2pass HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --performance --label mi350x_1pass --compare mi350x_2pass ``` E2E tests: Baseline: 765k qps https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_131047-d9f3209936?job_attempt=0&version=0&tab=tb_legacy With diff: 782k qps https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_141250-d9120ce4bb?job_attempt=1&version=0&tab=tb_legacy Reviewed By: jhadidjojo Differential Revision: D98176771 Pull Request resolved: #179019 Approved by: https://github.com/haoyuz
…ytorch#179019) Summary: Adopt the GammaBetaBackwardCUDAKernelTemplate tiled kernel introduced in D72575858 for ROCm, replacing the legacy two-pass cuComputePartGradGammaBeta and cuComputeGradGammaBeta approach. This brings AMD towards Nvidia parity. Test Plan: Results: - Local Benchmark: - Higher performance across 39 shapes: 1.02x speedup on mi350 (1 pass vs 2 pass implementation) - Higher numerical accuracy on mi350 vs h100 - Avg rel error vs CPU fp32 (mi350): dgamma=3.040359e-06 dbeta=1.750184e-06 - Avg rel error vs CPU fp32 (h100): dgamma=3.506308e-06 dbeta=1.792510e-06 - E2E Test - 1.02x speedup in qps - baseline: 765k - with diff: 782k ``` Benchmarks: buck2 run //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --correctness --label h100 HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --correctness --label mi350 --compare h100 HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --performance --label mi350x_2pass HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --performance --label mi350x_1pass --compare mi350x_2pass ``` E2E tests: Baseline: 765k qps https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_131047-d9f3209936?job_attempt=0&version=0&tab=tb_legacy With diff: 782k qps https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_141250-d9120ce4bb?job_attempt=1&version=0&tab=tb_legacy Reviewed By: jhadidjojo Differential Revision: D98176771 Pull Request resolved: pytorch#179019 Approved by: https://github.com/haoyuz
…ytorch#179019) Summary: Adopt the GammaBetaBackwardCUDAKernelTemplate tiled kernel introduced in D72575858 for ROCm, replacing the legacy two-pass cuComputePartGradGammaBeta and cuComputeGradGammaBeta approach. This brings AMD towards Nvidia parity. Test Plan: Results: - Local Benchmark: - Higher performance across 39 shapes: 1.02x speedup on mi350 (1 pass vs 2 pass implementation) - Higher numerical accuracy on mi350 vs h100 - Avg rel error vs CPU fp32 (mi350): dgamma=3.040359e-06 dbeta=1.750184e-06 - Avg rel error vs CPU fp32 (h100): dgamma=3.506308e-06 dbeta=1.792510e-06 - E2E Test - 1.02x speedup in qps - baseline: 765k - with diff: 782k ``` Benchmarks: buck2 run //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --correctness --label h100 HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --correctness --label mi350 --compare h100 HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --performance --label mi350x_2pass HIP_VISIBLE_DEVICES=2 buck2 run @//mode/opt-amd-gpu -m rocm70 -m ovr_config//triton:beta -m rccl_dev -m fbcode//triton/cc:force_noop -c fbcode.split-dwarf=True \ //scripts/echen40/amd/benchmark/layer_norm:layer_norm_backward_benchmark -- \ --performance --label mi350x_1pass --compare mi350x_2pass ``` E2E tests: Baseline: 765k qps https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_131047-d9f3209936?job_attempt=0&version=0&tab=tb_legacy With diff: 782k qps https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_141250-d9120ce4bb?job_attempt=1&version=0&tab=tb_legacy Reviewed By: jhadidjojo Differential Revision: D98176771 Pull Request resolved: pytorch#179019 Approved by: https://github.com/haoyuz
Summary: Adopt the GammaBetaBackwardCUDAKernelTemplate tiled kernel introduced in D72575858 for ROCm, replacing the legacy two-pass cuComputePartGradGammaBeta and cuComputeGradGammaBeta approach. This brings AMD towards Nvidia parity.
Test Plan:
Results:
E2E tests:
Baseline: 765k qps
https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_131047-d9f3209936?job_attempt=0&version=0&tab=tb_legacy
With diff: 782k qps
https://www.internalfb.com/mlhub/pipelines/runs/mast/aps-cmf_amd_echen40_20260320_141250-d9120ce4bb?job_attempt=1&version=0&tab=tb_legacy
Reviewed By: jhadidjojo
Differential Revision: D98176771