Skip to content

Conversation

@KaelanDt
Copy link
Collaborator

@KaelanDt KaelanDt commented Jun 2, 2025

Before submitting
  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

What does this PR do?

Fixes #2149. Also removes cudnn from the BaseRecipe, as it is not always there and is not a core component of thunder (less so than nvfuser).

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@t-vi
Copy link
Collaborator

t-vi commented Jun 10, 2025

@riccardofelluga do the updates make you happier about the PR?

Copy link
Collaborator

@t-vi t-vi left a comment

Choose a reason for hiding this comment

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

Looks good to me, let's give @riccardofelluga @vedaanta a chance to look at it before merging it Wed or Thu.

Copy link
Collaborator

@riccardofelluga riccardofelluga left a comment

Choose a reason for hiding this comment

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

Since we are modifying two files at this point wouldn't it be better to follow the same style as the other executors that are dependent on another library? Where we dedicate one file to be the gate for the symbols depending on the availability of the library(as in nvfuserex.py)

So something like cudnnex.py that takes care of the imports and checks and then cudnn_layernorm as is, and maybe creating cudnn_sdpa.py

@KaelanDt What do you think?

@KaelanDt
Copy link
Collaborator Author

KaelanDt commented Jun 10, 2025

Since we are modifying two files at this point wouldn't it be better to follow the same style as the other executors that are dependent on another library? Where we dedicate one file to be the gate for the symbols depending on the availability of the library(as in nvfuserex.py)

So something like cudnnex.py that takes care of the imports and checks and then cudnn_layernorm as is, and maybe creating cudnn_sdpa.py

@KaelanDt What do you think?

yes, i like that

@KaelanDt KaelanDt force-pushed the kaelan/cudnn-registering branch 2 times, most recently from 77b0340 to 67be58f Compare June 11, 2025 12:27
@KaelanDt
Copy link
Collaborator Author

@riccardofelluga I tried a few things by adding a cudnn_sdpa file, but it just ended up being messy and relying on a bunch of cudnn_available checks and was more confusing in my opinion.

Since the cudnn_sdpa operators are registered along with the main cudnn executor, i think it is fine to leave it as is, and to have cudnn_layernorm as a separate file (because it creates a new executor)

@vedaanta
Copy link
Collaborator

the change looks good to me.

@KaelanDt @t-vi I think we should not register cudnn layernorm at all.
It was being bought up a year ago, but there were cpu overheads which made it perform worse than triton/nvfuser.
(Since then cudnn has worked a lot on norms, but their e2e contribution for models I know of has been low enough to not warrant enabling in thunder again.)

@t-vi
Copy link
Collaborator

t-vi commented Jun 11, 2025

Thank you @vedaanta !

@t-vi t-vi enabled auto-merge (squash) June 11, 2025 17:02
@t-vi t-vi dismissed riccardofelluga’s stale review June 11, 2025 17:02

review addressed

@riccardofelluga
Copy link
Collaborator

riccardofelluga commented Jun 12, 2025

@riccardofelluga I tried a few things by adding a cudnn_sdpa file, but it just ended up being messy and relying on a bunch of cudnn_available checks and was more confusing in my opinion.

Since the cudnn_sdpa operators are registered along with the main cudnn executor, i think it is fine to leave it as is, and to have cudnn_layernorm as a separate file (because it creates a new executor)

@KaelanDt Let me come in help here, instead of modifying the cudnn executor and doing a conditional registration of the executor, wouldn't it be better to create a conditional import like in nvfuserex.py?

Would something like this in cudnnex.py work?

__all__ = ["cudnn_ex"]

cudnn_ex = None

if cudnn_available():
    import import thunder.executors.cudnn_spda as sdpa_impl
    cudnn_ex = sdpa_impl.cudnn_ex

else:
    warnings.warn("cudnn not available")

We can also make room for more complex import logic if needed (like say checking versions or disabling cudnn_linearnorm), all without modifying the cudnn executor registration.

@riccardofelluga riccardofelluga disabled auto-merge June 12, 2025 11:08
@KaelanDt KaelanDt force-pushed the kaelan/cudnn-registering branch from e07a942 to 07b2bfe Compare June 12, 2025 21:56
[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

typo

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

revert function import

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

spda --> sdpa

fix layernorm input

cudnnex

change the way cudnn is checked

fix import

bind functions

add function def as none

add accidentally deleted code

bind import

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
@KaelanDt KaelanDt force-pushed the kaelan/cudnn-registering branch from 95cb316 to 380cc84 Compare June 12, 2025 22:15
Copy link
Collaborator

@riccardofelluga riccardofelluga left a comment

Choose a reason for hiding this comment

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

Almost there!! Thanks for taking the time, I've added some suggestions. Please feel free to ping me if you need any help

@KaelanDt KaelanDt force-pushed the kaelan/cudnn-registering branch from 0b54698 to d92ddeb Compare June 13, 2025 10:03
add import to sdpa

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

import cudnn within sdpa

missing import

fix imports 2

fix import in layernorm module

assign torch_to_cudnn_dtype to none

fix test import

remove unused import
@KaelanDt KaelanDt force-pushed the kaelan/cudnn-registering branch from 98c9a1a to 23e76fc Compare June 13, 2025 10:41
@KaelanDt KaelanDt requested a review from riccardofelluga June 13, 2025 11:06
Copy link
Collaborator

@riccardofelluga riccardofelluga left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, there are some nits but it looks good already!

Well done!

@t-vi t-vi merged commit 12bbc16 into main Jun 13, 2025
49 checks passed
@t-vi t-vi deleted the kaelan/cudnn-registering branch June 13, 2025 13:33
@KaelanDt KaelanDt mentioned this pull request Jun 13, 2025
4 tasks
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.

don't register cudnn executor if cudnn is not available

5 participants