Skip to content

[Gemma] Modular-friendly buffers#44635

Open
RyanMullins wants to merge 2 commits intohuggingface:mainfrom
RyanMullins:gemma-buffers
Open

[Gemma] Modular-friendly buffers#44635
RyanMullins wants to merge 2 commits intohuggingface:mainfrom
RyanMullins:gemma-buffers

Conversation

@RyanMullins
Copy link
Copy Markdown
Contributor

What does this PR do?

Per a conversion with @Cyrilvallez on Slack on how to make Gemma models more compatible with modular inheritance, this PR:

  • Updates Gemma models to use nn.parameter.Buffer instead of a self.register_buffer() for static attributes
  • Updates _init_weights functions as appropriate to populate non-persistent buffers correctly

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?

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.

@ArthurZucker @Cyrilvallez

@github-actions
Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: cwm, dots1, exaone4, exaone_moe, gemma, gemma2, gemma3, gemma3n, gpt_oss, granitemoehybrid, lfm2, lfm2_moe, minimax, ministral, olmo3, olmo_hybrid

@RyanMullins RyanMullins changed the title [Gemma] Modular-friendly bbuffers [Gemma] Modular-friendly buffers Mar 12, 2026
Copy link
Copy Markdown
Member

@Cyrilvallez Cyrilvallez left a comment

Choose a reason for hiding this comment

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

Arf sorry, maybe I wasn't clear enough offline 🥲 Unfortunately, nn.parameter.Buffer was only added in torch 2.5, and we still support 2.4... So we need to hold off at least a bit for this PR! Let me see internally if we can bump the dependency so we can use this!

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.

2 participants