[Modular] Add no_inherit_decorators and fixup wrong RoPE related inheritances #46440
Merged
vasqu merged 8 commits intoJun 5, 2026
Merged
Conversation
no_inherit_decorators sentinel to prevent incorrect kernel decorator inheritanceno_inherit_decorators and fixup wrong RoPE related inheritances
Contributor
|
Thanks @Bissmella, this is a bit more important so I went ahead and took a bit over to also allow the same for functions |
6 tasks
ArthurZucker
approved these changes
Jun 5, 2026
ArthurZucker
left a comment
Collaborator
There was a problem hiding this comment.
Make sur the tests is a mixin test its a good catch! 🤗
| 2. Take the decorators attached in the modular file. | ||
| 3. Inherit all existing decorators of the parent/original node, if any. | ||
| """ | ||
| decorator_names = [mapper.python_module.code_for_node(dec.decorator) for dec in modular_node.decorators] |
Collaborator
There was a problem hiding this comment.
there's probably a faster way to do this but no worries!
Contributor
|
CI Dashboard: View test results in Grafana |
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: bamba, cohere, cohere2, cohere2_moe, ernie4_5, ernie4_5_moe, ernie4_5_vl_moe, flex_olmo, gemma4, glm, glm4, glm4_moe, glm4v_moe, glm_image, glmasr, helium |
|
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. |
4 tasks
Closed
5 tasks
khushali9
pushed a commit
to khushali9/transformers
that referenced
this pull request
Jun 8, 2026
…heritances (huggingface#46440) * feat: add no_inherit_decorator sentinel to fix kernel decorator propagation in modular converter * formatting * fixup the decorator * better typing and proper propogation to use more explicit cases * fix * refactor to fn and allow for class and fn * add regression test * fix all models --------- Co-authored-by: vasqu <antonprogamer@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #46399
What does this PR do?
Several attention classes inherit
@use_kernelized_func(apply_rotary_pos_emb)from their parentbut override
apply_rotary_pos_embwith a version that has no@use_kernel_func_from_hubdecoration.When
use_kernels=Trueis set,kernelize()tries to register the raw function in_hidden_kernelsas an
nn.Moduleand crashes with aValueError.The root cause is in
replace_class_node()inmodular_model_converter.py, when a modular classdefines no decorators of its own, the converter falls back to the parent class decorators, blindly
propagating
@use_kernelized_funceven when the underlying function has no kernel backing.Affected models:
qwen3_next,qwen3_5,glm4_moe,glm4v_moe,moonshine,lagunaThis PR introduces a general-purpose
@no_inherit_decoratorssentinel inutils/generic.py.When placed on a class in a modular file, it signals the converter to drop all parent class
decorators for that class. The dummy decorator itself is stripped from the generated output and doesn't
appears in the final
modeling_*.pyfiles.The fix is intentionally general, this decorator propagation problem is not limited to kernels
and could affect other decorators in the future.
Code Agent Policy
The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. We are currently bottlenecked by our ability to review and respond to them. As a result,
we ask that new users do not submit pure code agent PRs at this time.
You may use code agents in drafting or to help you diagnose issues. We'd also ask autonomous "OpenClaw"-like agents
not to open any PRs or issues for the moment.
PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this
repeatedly or maliciously.
This is a rapidly-evolving situation that's causing significant shockwaves in the open-source community. As a result,
this policy is likely to be updated regularly in the near future. For more information, please read
CONTRIBUTING.md.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@vasqu, @drbh, @Cyrilvallez