Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fe6b700
feat(llama32): implement llama3.2 model architecture
Moriyuki-S Jan 22, 2026
4c7a5c2
docs(llama32): add README
Moriyuki-S Jan 22, 2026
76e5106
test(llama32): add tests for Llama-3.2 model output and padding behavior
Moriyuki-S Jan 22, 2026
f52f7f5
test(llama32): add unit tests for sharding behavior in Llama model
Moriyuki-S Jan 22, 2026
126f82f
ruff format
jenriver Jan 23, 2026
bfbe0e0
chore(llama3.2): rename llama32 directory to llama3_2
Moriyuki-S Jan 23, 2026
313fda9
refactor(llama3.2): replace deprecated flax.nnx.State with nnx.to_pur…
Moriyuki-S Jan 23, 2026
618b339
test(llama32): update tolerance values in output tests for improved p…
Moriyuki-S Jan 23, 2026
c5603bd
docs(llama3.2): update Flax NNX API link to stable version
Moriyuki-S Jan 30, 2026
1dc2afc
Merge branch 'main' into feat/implement-llama
jenriver Jan 30, 2026
b4cf559
fix(llama3.2): correct sharding axes for GQA and fix explicit mesh er…
Moriyuki-S Feb 1, 2026
a678b01
docs(llama3.2): enhance docstring for compute_positions_from_segment_…
Moriyuki-S Feb 1, 2026
ee9e595
test(llama3.2): consolidate test configs
Moriyuki-S Feb 1, 2026
4c8ba67
test(llama3.2): refactor padding tests
Moriyuki-S Feb 1, 2026
7407439
test(llama3.2): add attention mask tests for padding and future tokens
Moriyuki-S Feb 1, 2026
fee4a82
refactor(llama3.2): enhance run_model script with argument parsing an…
Moriyuki-S Feb 1, 2026
f2d3a8d
Merge branch 'feat/implement-llama' of https://github.com/Moriyuki-S/…
Moriyuki-S Feb 1, 2026
c047b0b
refactor(llama3.2): add no mesh support
Moriyuki-S Feb 2, 2026
a32f929
style(llama3.2): clean up code formatting
Moriyuki-S Feb 2, 2026
c8404a0
style(llama3.2): rename test classes
Moriyuki-S Feb 2, 2026
d6a9d40
Merge branch 'main' into feat/implement-llama
jenriver Feb 3, 2026
6c13f56
Merge branch 'main' into feat/implement-llama
Moriyuki-S Feb 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions bonsai/models/llama3_2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Llama 3.2 in JAX

This directory contains a pure JAX implementation of the
[Llama 3.2 language model](https://huggingface.co/meta-llama),
using the [Flax NNX](https://flax.readthedocs.io/en/stable/index.html) API.

Note: You need a Hugging Face access token to download model weights.
Set an environment variable `HF_TOKEN` before running any scripts that fetch checkpoints.

```sh
export HF_TOKEN="your_hf_access_token"
```

Some Llama models are gated. Make sure you have accepted the license in the
Hugging Face UI for the specific model you want to use.

## Model Configuration Support Status

| Model Name | Config Support Status |
| :--- | :--- |
| [Llama-3.2-1B](https://huggingface.co/meta-llama/Llama-3.2-1B) | **✅ Supported** |
| [Llama-3.2-1B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct) | **✅ Supported** |
| [Llama-3.2-3B](https://huggingface.co/meta-llama/Llama-3.2-3B) | **✅ Supported** |
| [Llama-3.2-3B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct) | **✅ Supported** |

## Running this model

```sh
# Instruct model (default: 1B)
python3 -m bonsai.models.llama3_2.tests.run_model

# Base model (1B)
python3 -m bonsai.models.llama3_2.tests.run_model --base

# Base model (3B)
python3 -m bonsai.models.llama3_2.tests.run_model --size 3B --base

# Instruct model (3B)
python3 -m bonsai.models.llama3_2.tests.run_model --size 3B
```

## Output parity tests

These tests compare JAX outputs against Hugging Face PyTorch outputs and require `HF_TOKEN`.

```sh
python3 -m bonsai.models.llama3_2.tests.test_outputs_llama3_2
```

## References

* Paper: [The Llama 3 Herd of Models](https://arxiv.org/abs/2407.21783)
* Model code: [Hugging Face Transformers (LlamaModel)](https://github.com/huggingface/transformers/tree/main/src/transformers/models/llama)

## How to contribute to this model

We welcome contributions! You can contribute via the following:

* Add a model config variant to `ModelConfig` in [modeling.py](modeling.py).
* Run [run_model.py](tests/run_model.py) and report whether the variant runs on your hardware.
Loading