Add Gemma 3n support (E2B, macOS) - #198
Open
stikves wants to merge 1 commit into
Open
Conversation
stikves
force-pushed
the
sukru/gemma3n
branch
3 times, most recently
from
August 26, 2026 01:54
c36cf23 to
e389279
Compare
Add Google Gemma 3n E2B — a novel on-device architecture with 7 features not found in other supported models: - AltUp: 4-copy hidden state with learned predict/correct routing - LAUREL: low-rank residual branch (rank 64) per layer - Per-layer input embeddings with gated injection - KV cache sharing: last 10/30 layers reuse K/V (33% cache savings) - Gaussian TopK: 95% activation sparsity in first 10 MLP layers - Dual RoPE: local (theta=10K, window 512) + global (theta=1M) - QKV norms: RMSNorm on Q/K (with scale), V (without scale) Evaluation: WikiText PPL 61.53 (float16), tinyMMLU 58.75%. High wikitext PPL is expected for instruction-tuned models; tinyMMLU accuracy is the appropriate quality metric.
tjia1818
reviewed
Aug 26, 2026
| @@ -0,0 +1,49 @@ | |||
| # Gemma 3n | |||
|
|
|||
| Google's Gemma 3n for on-device inference via Core AI. Apache 2.0 license. | |||
Contributor
There was a problem hiding this comment.
No need to describe license type here (also it's not Apache, but Gemma license)
tjia1818
reviewed
Aug 26, 2026
| | --------------- | ------------------ | ------- | ----- | --- | | ||
| | gemma-3n-E2B-it | ~5B (E2B effective) | 32768 | Yes | No | | ||
|
|
||
| - **AltUp**: 4-copy hidden state with learned predict/correct routing per layer. |
tjia1818
reviewed
Aug 26, 2026
|
|
||
| ## Evaluation | ||
|
|
||
| Perplexity on WikiText-2 and accuracy on tinyMMLU, computed with the Core AI PyTorch models (4K context). |
Contributor
There was a problem hiding this comment.
Align with other models on the Evaluation section.
tjia1818
reviewed
Aug 26, 2026
| - **QKV norms**: RMSNorm on Q, K (with scale) and V (without scale). | ||
| - **Logit softcapping**: `tanh(logits/30) * 30`. | ||
|
|
||
| ## Evaluation |
Contributor
There was a problem hiding this comment.
This section should go to the bottom
tjia1818
reviewed
Aug 26, 2026
| uv run coreai.llm.export google/gemma-3n-E2B-it | ||
| ``` | ||
|
|
||
| ## Run |
Contributor
There was a problem hiding this comment.
align with other LLMs in terms of README structure.
tjia1818
reviewed
Aug 26, 2026
| "float16", | ||
| 131072, | ||
| ), | ||
| ModelPreset( |
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.
Summary
Evaluation
High WikiText PPL is expected for instruction-tuned models — tinyMMLU accuracy is the appropriate quality metric.
Test plan
uv run coreai.llm.export google/gemma-3n-E2B-it