Changes to get transformers Gemma working, as well as bug fixes#25
Merged
Conversation
Owner
|
hi @adconner, thanks for submitting this! it would be super cool to get gemma working. there's some existing, in-flight PRs to be aware of for some of these issues:
i propose that we get those merged first since there already in the works and then rebase from there |
Owner
|
also would be cool to add this to the readme or some kind of examples docs somewhere once it's all working! |
mavenlin
reviewed
Aug 15, 2025
adconner
force-pushed
the
push-lqozvsrpzprx
branch
from
August 15, 2025 13:08
4da45a4 to
d40bfe2
Compare
Owner
adconner
force-pushed
the
push-lqozvsrpzprx
branch
from
August 26, 2025 00:08
d40bfe2 to
cfcfc6e
Compare
Contributor
Author
|
I've rebased @samuela |
samuela
reviewed
Aug 30, 2025
Owner
|
just ooc gemma is already implemented in jax, no? https://github.com/google-deepmind/gemma just out of curiosity what's your use case look like? |
Contributor
Author
|
My use case involves possibly collaborating with torch users in the future, and potentially wanting to run experiments with other models aside from gemma. |
adconner
force-pushed
the
push-lqozvsrpzprx
branch
from
August 30, 2025 22:58
cfcfc6e to
243712a
Compare
adconner
force-pushed
the
push-lqozvsrpzprx
branch
from
August 31, 2025 22:28
243712a to
4bd55cf
Compare
samuela
approved these changes
Sep 2, 2025
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.
Some additions to get Gemma-2b working, as implemented by transformers, as well as some bug fixes in the in-place versions of sum, mean, etc.
One divergence with torch semantics with this change is I make no attempt to support the
torch.no_gradcontext (arising as the implementation oftorch._C._set_grad_enabled). In the context of Gemma it was used for pure efficiency reasons to mark tensors independent of the input; this optimization is unneeded in the jax autograd context. I am supposing the heuristic that such efficiency is the typical reason for this context, and torch tensors will usually be explicitlydetached when this is required for the correctness of the model (already supported by torch2jax). If we wish to support theno_gradcontext, it can be done by tracking this state ourselves and wrapping the result of all operators instop_gradientif on.