Skip to content

Add ops for HF transformers #2217

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
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Add ops for HF transformers #2217

wants to merge 13 commits into from

Conversation

kiya00
Copy link
Collaborator

@kiya00 kiya00 commented Jun 11, 2025

As identified in the split reasons investigated in #2169 (https://docs.google.com/spreadsheets/d/1BKK-1T4UqZHaE8x39gIRFpoCuDmMFC3Z3rn_mBWUStA/edit?usp=sharing), this PR addresses several of them to help reduce the number of segments:

  1. Adds support for torch._C._nn.pad, which is functionally equivalent to torch.nn.functional.pad.
    (Reference: PyTorch source),

  2. Registers some operators that are aliases of already-registered ones.

  3. Introduces checks for einops operators in the splitter.
    (These operators are registered here)

Fixes #2169.

@kiya00 kiya00 marked this pull request as ready for review June 12, 2025 14:19
@kiya00 kiya00 requested review from mruberry, lantiga and t-vi as code owners June 12, 2025 14:19
@kiya00 kiya00 changed the title Add ops for HF transformers Add ops for HF diffusers Jun 24, 2025
@kiya00 kiya00 changed the title Add ops for HF diffusers Add ops for HF transformers Jun 26, 2025
@kiya00
Copy link
Collaborator Author

kiya00 commented Jun 26, 2025

Hi @kshitij12345 , @IvanYashchuk could you take a look of the PR

Copy link
Collaborator

@kshitij12345 kshitij12345 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @kiya00.

@kiya00
Copy link
Collaborator Author

kiya00 commented Jul 2, 2025

Hi @IvanYashchuk @mruberry , could you take a look at the PR

Co-authored-by: Masaki Kozuki <[email protected]>
Copy link
Collaborator

@IvanYashchuk IvanYashchuk left a comment

Choose a reason for hiding this comment

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

@t-vi, could you please merge this PR?

@@ -1177,7 +1179,7 @@ def movedim(a: TensorLike, /, source: int | Sequence[int], destination: int | Se
return clang.movedim(a, source, destination)


@torchsymbol(torch.nn.functional.pad)
@torchsymbol(torch.nn.functional.pad, torch._C._nn.pad, id="torch.nn.functional.pad", is_method=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we calling torch._C._nn.pad directly?
Isn't is_method=False the default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is for ThunderFx path, it appears in the dynamo graph as torch._C._nn.pad

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can remove the is_method=False, keep it here explicit just because I saw a lot of other ops do the same

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.

Explore split reasons and operator coverage for transformers
5 participants