Skip to content

[JAX] Select cuDNN backend for normalization - #1946

Closed
phu0ngng wants to merge 5 commits into
NVIDIA:mainfrom
phu0ngng:jax_cudnn_norms
Closed

phu0ngng wants to merge 5 commits into
NVIDIA:mainfrom
phu0ngng:jax_cudnn_norms

Conversation

@phu0ngng

Copy link
Copy Markdown
Collaborator

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

@phu0ngng

Copy link
Copy Markdown
Collaborator Author

/te-ci JAX L1

@phu0ngng phu0ngng added the 2.6.0 label Jul 11, 2025

@timmoon10 timmoon10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about we change the default to NVTE_NORM_FWD_USE_CUDNN=1 (and similar for backward)? We can change:

bool& _cudnn_norm_fwd_flag() {
static bool flag = transformer_engine::getenv<bool>("NVTE_NORM_FWD_USE_CUDNN");
return flag;
}

Into:

 bool& _cudnn_norm_fwd_flag() { 
   static bool flag = transformer_engine::getenv<bool>("NVTE_NORM_FWD_USE_CUDNN", true); 
   return flag; 
 } 

This way JAX users can still disable cuDNN with NVTE_NORM_FWD_USE_CUDNN=0.

@phu0ngng

Copy link
Copy Markdown
Collaborator Author

How about we change the default to NVTE_NORM_FWD_USE_CUDNN=1 (and similar for backward)?

@timmoon10, I think the question here is whether we want to turn CuDNN backend on by default.

We know that cuDNN backend works faster for MLPerf cases, but we have not conducted a systematic benchmark for all the size configs and dtypes we have in the tuned kernel.

phu0ngng and others added 4 commits July 16, 2025 08:10
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
@phu0ngng
phu0ngng marked this pull request as ready for review July 16, 2025 15:12
@phu0ngng

Copy link
Copy Markdown
Collaborator Author

/te-ci L1

Comment on lines +39 to +40
// Enable norm with cuDNN instead of TE kernels
nvte_enable_cudnn_norm_fwd(true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a reason we are forcing the cuDNN backend? It seems like something that should be controlled with NVTE_NORM_FWD_USE_CUDNN. If cuDNN has better perf, it would be better to change the default to NVTE_NORM_FWD_USE_CUDNN=1 rather than hard-coding it only for JAX.

@phu0ngng phu0ngng removed the 2.6.0 label Jul 22, 2025
@phu0ngng

phu0ngng commented Aug 6, 2025

Copy link
Copy Markdown
Collaborator Author

Close as the change is no longer necessary.

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