Skip to content

Commit 774dfd7

Browse files
committed
Llama4 vision layers NNX migration
minor fix rngs fix
1 parent 903a097 commit 774dfd7

4 files changed

Lines changed: 195 additions & 232 deletions

File tree

src/MaxText/configs/models/llama4-17b-128e.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,13 @@ temperature_tuning: True
4141
# Chunk attention is used on all RoPE layers
4242
# otherwise, on NoPE layers, use global attention
4343
chunk_attn_window_size: 8192
44-
image_size_for_vit: 336
44+
45+
# Multimodal flags (need to set use_multimodal=true)
46+
image_size_for_vit: 336
47+
num_channels_for_vit: 3
48+
patch_size_for_vit: 14
49+
hidden_size_for_vit: 1408
50+
intermediate_size_for_vit: 5632
51+
num_hidden_layers_for_vit: 34
52+
num_attention_heads_for_vit: 16
53+
image_placeholder: "<|image|>"

src/MaxText/configs/models/llama4-17b-16e.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,13 @@ temperature_tuning: True
4141
# Chunk attention is used on all RoPE layers
4242
# otherwise, on NoPE layers, use global attention
4343
chunk_attn_window_size: 8192
44-
image_size_for_vit: 336
44+
45+
# Multimodal flags (need to set use_multimodal=true)
46+
image_size_for_vit: 336
47+
num_channels_for_vit: 3
48+
patch_size_for_vit: 14
49+
hidden_size_for_vit: 1408
50+
intermediate_size_for_vit: 5632
51+
num_hidden_layers_for_vit: 34
52+
num_attention_heads_for_vit: 16
53+
image_placeholder: "<|image|>"

src/MaxText/layers/encoders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def get_vision_encoder_layers(self):
4343
elif self.config.model_name in ["llama4-17b-16e", "llama4-17b-128e"]:
4444
from MaxText.layers import llama4 # pylint: disable=import-outside-toplevel
4545

46-
return [llama4.Llama4VisionModel, llama4.Llama4MultiModalProjector]
46+
return [llama4.llama4visionmodel_as_linen, llama4.llama4multimodalprojector_as_linen]
4747
else:
4848
raise ValueError(f"No VisionEncoder implemented for {self.config.model_name} yet")
4949

0 commit comments

Comments
 (0)