Skip to content

Conversation

@Micky774
Copy link
Contributor

Description

Please include a brief summary of the changes, relevant motivation and context.

Fixes # (issue)

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • Change A
  • Change B

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@@ -0,0 +1,307 @@
# This file was modified for portability to AMDGPU
# Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is NVIDIA code this benchmark is based on?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's based on the JAX FA tests -- not sure how we handle the copyright in that case, since this is a new file.


// print kernel name on verbose mode
ck_tile::stream_config stream_config{stream, false, ck_fused_attn_log_config};
ck_tile::stream_config stream_config{stream, true, ck_fused_attn_log_config};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it OK to always enable kernels timing? Doesn't it have some performance penalty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes good catch, this is fixed in the newest commit

Copy link
Collaborator

@ipanfilo ipanfilo left a comment

Choose a reason for hiding this comment

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

Why ck_fused_attn_bwd needs modification if the PR is for fwd-pass only?

@Micky774 Micky774 changed the title JAX FA Benchmarking Script (fwd-pass only) JAX FA Benchmarking Script Oct 31, 2025
@Micky774
Copy link
Contributor Author

Note that I have added the BWD pass implementation as well to this PR.

@Micky774 Micky774 requested a review from ipanfilo November 5, 2025 20:48
@Micky774
Copy link
Contributor Author

Pinging @wangye805 @wenchenvincent in case either of you are interested in reviewing this PR as well, thanks!

## JAX Fused-Attention Benchmarking
The benchmarking process is split into two stages: *generating* the timing data, and *visualizing* the timing data. The following steps assume you are located in `TransformerEngine/benchmarks/attention` (i.e. where this README is located). First, ensure that you install requirements via `pip install -r requirements.txt`.

Note: Only forward timings are supported at this point.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

from transformer_engine.jax import fp8_autocast

# Needed in order to dump timings properly
os.environ["XLA_FLAGS"]="--xla_gpu_graph_level=0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this because you used dumping time function in ck fused attention?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

file << average_runtime << "\n";
}
void dump_bwd_timings(const char* dump_path, float average_runtime, hipStream_t stream){
std::ofstream file;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As an option - open file once and do not close it so no open/flush/close happen on every dump

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.

4 participants