-
Notifications
You must be signed in to change notification settings - Fork 23
release v2.8 rocm #428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
VeeraRajasekhar
wants to merge
23
commits into
release_v2.8_rocm
Choose a base branch
from
veergopu/release_v2.8_rocm
base: release_v2.8_rocm
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
release v2.8 rocm #428
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
822d7ea
Changed VERSION to 2.8.0
ptrendx 9797673
[JAX] Remove import jax.extend.ffi (#2193)
phu0ngng ac51322
[PyTorch] Add sink attention support from cuDNN (#2148)
cyanguwa 307a993
[QA] Add pytest xml report for all tests in qa folder that use pytest…
shengfangd c70f1d9
[JAX] Local-Amax for Current-Scaling (#2183)
mingxu1067 3f02a2e
[JAX] Restore Shardy Rule with CompoundFactor (#2167)
phu0ngng ee58762
[JAX] Update JAX version requirement in pyproject.toml (#2197)
phu0ngng bd8e566
[PyTorch] Unpin version of onnxscript and onnxruntime (#2202)
pggPL 238a3fd
[JAX] Fix XML filename in the L0_jax_uniitest (#2205)
phu0ngng de13b8c
[JAX] CollectiveGemm (#2166)
phu0ngng ef38de4
[JAX] Add xml export for `test_multiprocessing_encoder` and `test_cge…
phu0ngng c464c85
[JAX] Address tolerance check for current scaling dact dbias (#2211)
jberchtold-nvidia 8a7b893
[Core][PyTorch] NVFP4 recipe (#2177)
ksivaman 51d046b
Fix the segfault in the nvfp4 quantization (#2214)
ptrendx 5a58f50
[PyTorch] Add FP8 attention with current scaling (#2012)
cyanguwa 88d541c
[JAX] Load modules during initialize for Norm and Act primitives (#2219)
jberchtold-nvidia 2b2f921
Fix the cuBLAS workspace alignment (#2223)
ptrendx 071589e
[PyTorch] Set usages for linear op quantizers before forward (#2222)
timmoon10 5339e97
Resolved conflicts
VeeraRajasekhar 4e9f03d
Addressed cpp and torch tests
VeeraRajasekhar c01ef70
Fixed test_attention.py
VeeraRajasekhar 2229f44
Fixed Jax build/test issues
VeeraRajasekhar 91acf1a
[CI][Pytorch] Add softmax_type support to fused attention backend sel…
VeeraRajasekhar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| # Copyright (c) 2022-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # | ||
| # See LICENSE for license information. | ||
|
|
||
| import argparse | ||
| import torch | ||
| import pandas as pd | ||
| import torch.utils.benchmark as benchmark | ||
|
|
||
| import transformer_engine.pytorch as te | ||
| import transformer_engine_torch as tex | ||
| import transformer_engine.pytorch.cpp_extensions as ext | ||
|
|
||
| from transformer_engine.pytorch.tensor.nvfp4_tensor import NVFP4Quantizer | ||
|
|
||
| scale_padding_to = 1 | ||
| permute_scale = False | ||
|
|
||
| TORCH_TO_TE_FLOAT_MAP = { | ||
| torch.bfloat16: tex.DType.kBFloat16, | ||
| } | ||
|
|
||
|
|
||
| def run_kernel(shape, stochastic_rounding: bool, input_dtype=torch.bfloat16): | ||
| # Generate random input data | ||
| M, K = shape | ||
| x = torch.randn([M, K], dtype=input_dtype, device="cuda") | ||
|
|
||
| assert shape[0] % 16 == 0, "Shape must be divisible by 16" | ||
| assert shape[1] % 16 == 0, "Shape must be divisible by 16" | ||
|
|
||
| # Quantize | ||
| nvfp4_quantizer = NVFP4Quantizer( | ||
| fp4_dtype=tex.DType.kFloat4E2M1, | ||
| rowwise=True, | ||
| columnwise=True, | ||
| with_amax_reduction=False, | ||
| amax_reduction_group=None, | ||
| with_rht=True, | ||
| with_post_rht_amax=True, | ||
| with_random_sign_mask=True, | ||
| stochastic_rounding=stochastic_rounding, | ||
| ) | ||
| x_nvfp4_sut = nvfp4_quantizer.make_empty( | ||
| (M, K), dtype=x.dtype, device=x.device, requires_grad=False | ||
| ) | ||
| x_nvfp4_sut = nvfp4_quantizer.update_quantized(x, x_nvfp4_sut) | ||
|
|
||
| with torch.no_grad(): | ||
| stmt = "kernel_func(input, output)" | ||
| globals_dict = { | ||
| "kernel_func": nvfp4_quantizer.update_quantized, | ||
| "input": x, | ||
| "output": x_nvfp4_sut, | ||
| } | ||
|
|
||
| timing = benchmark.Timer( | ||
| stmt=stmt, | ||
| globals=globals_dict, | ||
| num_threads=1, | ||
| ).blocked_autorange(min_run_time=5) | ||
| print(timing) | ||
| timing_us = timing.median * 1e6 | ||
|
|
||
| input_nbytes = shape[0] * shape[1] * 2 # bf16 | ||
| output_nbytes = shape[0] * shape[1] // 2 # //2 for fp4 | ||
| sf_nbytes = shape[0] * shape[1] // 16 # //16 for 1 byte per 16 elems | ||
|
|
||
| total_nbytes = ( | ||
| 0 | ||
| + input_nbytes | ||
| * 3 # Reading input for Amax(x)&Amax(RHT(x.T)), Reading input for Cast(x), Reaindg input for Cast(RHT(x.T)) | ||
| + 2 * 4 # Output 2 * float for scale & amax | ||
| + 2 * 4 # Input 2 * float | ||
| + output_nbytes * 2 # Output from Cast(x) and Cast(RHT(x.T)) | ||
| + sf_nbytes * 2 # Scale factor | ||
| ) | ||
|
|
||
| throughput_GBps = total_nbytes / (1024 * 1024 * 1024) / (timing_us / 1e6) | ||
|
|
||
| print( | ||
| f"Stochastic rounding: {stochastic_rounding}, Total: {total_nbytes} bytes, Throughput:" | ||
| f" {throughput_GBps} GB/s" | ||
| ) | ||
| return timing_us, throughput_GBps | ||
|
|
||
|
|
||
| # Nsight Compute Profiling Command: | ||
| # ncu -f -o block_scaled_1d_cast_transpose_kernel --set=full --kernel-name "block_scaled_1d_cast_transpose_kernel" -s 5 -c 5 python benchmark_cast_transpose_1d_block.py --profile | ||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument("--profile", action="store_true", help="Enable profiling mode") | ||
| args = parser.parse_args() | ||
|
|
||
| if args.profile: | ||
| print("Profiling is enabled.") | ||
| else: | ||
| print("Profiling is disabled.") | ||
|
|
||
| shapes = [ | ||
| (8192, 5120), | ||
| (8192, 10240), | ||
| (8192, 2560), | ||
| (8192, 11328), | ||
| (8192, 512), | ||
| (8192, 3584), | ||
| (5120, 8192), | ||
| (10240, 8192), | ||
| (2560, 8192), | ||
| (11328, 8192), | ||
| (512, 8192), | ||
| (3584, 8192), | ||
| (4096, 16384), | ||
| (14336, 16384), | ||
| ] | ||
|
|
||
| if args.profile: | ||
| shapes = [ | ||
| (16384, 6144), | ||
| ] | ||
|
|
||
| data = [] | ||
| for stochastic_rounding in [True]: # , False]: | ||
| for shape in shapes: | ||
| print( | ||
| f"Running benchmark_func with shape {shape} and stochastic_rounding" | ||
| f" {stochastic_rounding}" | ||
| ) | ||
| timing_us, throughput_GBps = run_kernel(shape, stochastic_rounding) | ||
| data.append( | ||
| [ | ||
| "benchmark_func", | ||
| shape, | ||
| stochastic_rounding, | ||
| timing_us, | ||
| throughput_GBps, | ||
| ] | ||
| ) | ||
|
|
||
| df = pd.DataFrame( | ||
| data=data, | ||
| columns=[ | ||
| "kernel", | ||
| "shape", | ||
| "stochastic_rounding", | ||
| "timing_us", | ||
| "throughput(GB/s)", | ||
| ], | ||
| ) | ||
| print(df) | ||
| df.to_csv("benchmark_cast_nvfp4.csv", index=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 2.8.0.dev0 | ||
| 2.8.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyright date