Skip to content

Allow for registered experts from kernels hub#45577

Merged
IlyasMoutawwakil merged 12 commits intohuggingface:mainfrom
winglian:experts-impl
Apr 23, 2026
Merged

Allow for registered experts from kernels hub#45577
IlyasMoutawwakil merged 12 commits intohuggingface:mainfrom
winglian:experts-impl

Conversation

@winglian
Copy link
Copy Markdown
Collaborator

What does this PR do?

When loading custom expert kernels from HF Hub, there is still a check that prevents them from being used. This grabs the list of registered expert fns instead of hardcoding.

Fixes # (issue) N/A

Code Agent Policy

AI was used just to write the unit tests.

  • I confirm that this is not a pure code agent PR.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@ArthurZucker @SunMarc

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Copy Markdown
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

Comment thread src/transformers/modeling_utils.py Outdated
def get_correct_experts_implementation(self, requested_experts: str | None) -> str:
applicable_experts = "grouped_mm" if requested_experts is None else requested_experts
if applicable_experts not in ["eager", "grouped_mm", "batched_mm", "deepgemm"]:
base_experts_fns = ["eager", "deepgemm"] + list(ALL_EXPERTS_FUNCTIONS.keys())
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.

we can remove deepgemm in the base_experts_fns. it will be present in ALL_EXPERTS_FUNCTIONS if fp8 is used.

Suggested change
base_experts_fns = ["eager", "deepgemm"] + list(ALL_EXPERTS_FUNCTIONS.keys())
base_experts_fns = ["eager"] + list(ALL_EXPERTS_FUNCTIONS.keys())

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.

actually fp8 has its own different registry, maybe we can add both registeries

@SunMarc
Copy link
Copy Markdown
Member

SunMarc commented Apr 22, 2026

@bot /style

@SunMarc
Copy link
Copy Markdown
Member

SunMarc commented Apr 22, 2026

@bot /style

Comment thread src/transformers/modeling_utils.py
Comment thread src/transformers/modeling_utils.py Outdated
@IlyasMoutawwakil
Copy link
Copy Markdown
Member

thanks for catching this, i left a small suggestion to allow fp8 implementations as well.

@IlyasMoutawwakil IlyasMoutawwakil mentioned this pull request Apr 23, 2026
6 tasks
@IlyasMoutawwakil
Copy link
Copy Markdown
Member

@bot /style

Comment thread src/transformers/modeling_utils.py Outdated
@IlyasMoutawwakil
Copy link
Copy Markdown
Member

@bot /style

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

Style fix bot fixed some files and pushed the changes.

@IlyasMoutawwakil
Copy link
Copy Markdown
Member

😭

@IlyasMoutawwakil IlyasMoutawwakil added this pull request to the merge queue Apr 23, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Apr 23, 2026
@IlyasMoutawwakil IlyasMoutawwakil added this pull request to the merge queue Apr 23, 2026
Merged via the queue into huggingface:main with commit 706acf5 Apr 23, 2026
28 checks passed
tarekziade pushed a commit that referenced this pull request Apr 23, 2026
* Allow for registered experts from kernels hub

* remove deepgemm as that is also dynamic

* Apply repo consistency fixes

* Update src/transformers/modeling_utils.py

* Update src/transformers/modeling_utils.py

* Apply repo consistency fixes

* Apply suggestion from @IlyasMoutawwakil

* Apply repo consistency fixes

* get rid of triton dependency

* keep eager first

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Marc Sun <57196510+SunMarc@users.noreply.github.com>
Co-authored-by: Ilyas Moutawwakil <57442720+IlyasMoutawwakil@users.noreply.github.com>
Co-authored-by: IlyasMoutawwakil <moutawwakil.ilyas.tsi@gmail.com>
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