Skip to content

esmfold2-trimul: support torch.compile, upload to biohub - #1214

Merged
github-actions[bot] merged 2 commits into
huggingface:mainfrom
Rocketknight1:esmfold2-trimul-torch-compile
Oct 13, 2026
Merged

github-actions[bot] merged 2 commits into
huggingface:mainfrom
Rocketknight1:esmfold2-trimul-torch-compile

Conversation

@Rocketknight1

@Rocketknight1 Rocketknight1 commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

torch.compile() fixes for the ESMFold2 kernels!

transformers is turning Hub kernels on by default and only maps kernels
that work under torch.compile (huggingface/transformers#47773). Make the
TriMul kernel compile-safe:

- Drop @torch._dynamo.disable from the entry point. It forced a graph
  break at every TriMul call, and an error under fullgraph=True.
- Declare can_torch_compile on the layer so it can be registered for
  Mode.TORCH_COMPILE.
- Pass STRIDE_B/N_COL as runtime args instead of tl.constexpr. Both scale
  with sequence length, so they recompiled the Triton kernel, and the
  compiled graph, for every new length.
- Use tl.cast instead of M.to in the LayerNorm kernels. M.to fails when M
  is a plain int (Triton's M == 1 specialization, and torch.compile's
  kernel mutation analysis). This also lifts the B == L == 1 restriction.

Also point the Hub repo-id at biohub/esmfold2-trimul, the repo
transformers loads this kernel from, so release builds are uploaded there
as a Hub PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

This PR changes source code for the following kernel(s): esmfold2-trimul.

If you have the kernel-bot build permissions, then trigger /kernel-bot build esmfold2-trimul yourself. Otherwise, a maintainer will review the PR and will take an appropriate action. Thanks for your patience.

@github-actions github-actions Bot added the chore Version bumps, releases, misc maintenance label Oct 9, 2026
@Rocketknight1

Copy link
Copy Markdown
Member Author

/kernel-bot build esmfold2-trimul

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Build request processed.

Command: /kernel-bot build esmfold2-trimul
Mode: build only
Target branch: pr-1214
PR head SHA: b81db959848ddea1b2c665dd7248277cf425e10e
Workflows: build.yaml, build-mac.yaml, build-windows.yaml

Dispatched (1):

@drbh drbh Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks good I think we just need to use the kernels library in the tests too

**prob something like the following (may need minor adjustments)

import kernels

esmfold2_trimul = kernels.get_kernel("kernels-community/esmfold2-trimul", version=1)

@Rocketknight1

Copy link
Copy Markdown
Member Author

@drbh one question, actually - I think I got a bit confused here, I'm not sure what the procedure is when a kernel is under an external trusted org (in this case, biohub). I made the PR to kernels-community to ensure it was built properly, but should I just be making a pure hub PR to their repo and not worrying about the signatures or anything?

@drbh

drbh commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

@Rocketknight1 good question, updating the build.toml to point to "biohub/esmfold2-trimul" should be sufficient, when we merge and upload the tooling should identify that the repo id is not in the kernels-community org and will open a pr on the hub in their repo.

**ps the kernel bot also supports build-and-stage like

/kernel-bot build-and-stage esmfold2-trimul

which will build and push to https://huggingface.co/kernels-staging/kernels and can be used to test the final build of a kernel which could be helpful for testing in the future.

also let us know if we should remove the https://huggingface.co/kernels/kernels-community/esmfold2-trimul repo in the case the kernel is always intended to be published under biohub

@Rocketknight1

Copy link
Copy Markdown
Member Author

/kernel-bot build-and-stage esmfold2-trimul

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Build request processed.

Command: /kernel-bot build-and-stage esmfold2-trimul
Mode: build and stage
Target branch: pr-1214
PR head SHA: b50bb45ed0f78ed661929dbf9ac41ca0843f4bc0
Workflows: build.yaml, build-mac.yaml, build-windows.yaml

Dispatched (1):

Hub uploads:

@Rocketknight1

Copy link
Copy Markdown
Member Author

@drbh done! And yes, this will live in biohub in future, so we can drop https://huggingface.co/kernels/kernels-community/esmfold2-trimul

@drbh

drbh commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

/kernel-bot merge-and-upload esmfold2-trimul

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Build request failed.

Command: /kernel-bot merge-and-upload esmfold2-trimul
Mode: merge, build and upload
Target branch: ``
PR head SHA: b50bb45ed0f78ed661929dbf9ac41ca0843f4bc0
Workflows: `build.yaml, build-mac.yaml, build-windows.yaml`

Failure: Failed to merge PR before build/upload. Check mergeability and required checks.

@drbh

drbh commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

/kernel-bot merge-and-upload esmfold2-trimul

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Build request processed.

Command: /kernel-bot merge-and-upload esmfold2-trimul
Mode: merge, build and upload
Target branch: ``
PR head SHA: b50bb45ed0f78ed661929dbf9ac41ca0843f4bc0
Workflows: `build.yaml, build-mac.yaml, build-windows.yaml`

Merge result: Pull Request successfully merged

Dispatched (1):

@github-actions
github-actions Bot merged commit cafe8d5 into huggingface:main Oct 13, 2026
9 checks passed
@drbh

drbh commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

/kernel-bot merge-and-upload esmfold2-trimul

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Build request processed.

Command: /kernel-bot merge-and-upload esmfold2-trimul
Mode: merge, build and upload
Target branch: ``
PR head SHA: b50bb45ed0f78ed661929dbf9ac41ca0843f4bc0
Workflows: `build.yaml, build-mac.yaml, build-windows.yaml`

Merge result: PR is already merged. Continuing with build/upload.

Dispatched (1):

Hub uploads:

@Rocketknight1

Copy link
Copy Markdown
Member Author

@drbh why did it emit 6 update PRs to the same kernel instead of a single one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Version bumps, releases, misc maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants