Llama-4-Scout-3.5B-A2.7B-small

This is a small version of meta-llama/Llama-4-Scout-17B-16E-Instruct created for testing and development. It keeps all hyperparameters of the base model identical and only reduces layer counts and expert counts, so it loads in vLLM with the same characteristics as the base.

Model Details

  • Base Model: meta-llama/Llama-4-Scout-17B-16E-Instruct (109B total / 17B activated)
  • Architecture: llama4 / Llama4ForConditionalGeneration (multimodal VLM, iRoPE)
  • Total Parameters: 3.56B (3,563,238,912)
  • Activated Parameters: 2.70B (2,698,191,680; text path per token: embeddings + lm_head + attention + shared expert + 1 routed expert per layer, topk 1)

Configuration Changes

The following parameters were reduced from the original model:

Parameter Base Small
text_config.num_hidden_layers 48 2
text_config.layer_types 3x chunked_attention : 1x full_attention, 12 periods 1x chunked_attention + 1x full_attention
text_config.no_rope_layers 48-entry list, every 4th layer NoPE (global) [1, 0] (layer 0 RoPE/local, layer 1 NoPE/global)
text_config.moe_layers all 48 layers [0, 1] (all layers MoE, as in base)
text_config.num_local_experts 16 4
vision_config.num_hidden_layers 34 2

All other hyperparameters are identical to the base: hidden 5120, 40 attention heads / 8 KV heads (head_dim 128), use_qk_norm, attention_chunk_size 8192 (chunked attention), attn_temperature_tuning (floor 8192, scale 0.1), llama3 rope (factor 16, theta 500000), MoE intermediate 8192 with fused gate_up (grouped 3D expert tensors), 1 shared expert per layer (intermediate 8192), num_experts_per_tok 1 (topk unchanged), intermediate_size_mlp 16384, vocab 202048, untied embeddings, vision tower hidden 1408 / patch 14 / pixel_shuffle 0.5 / projector 4096.

The minimal covering set of 2 text layers (one chunked/local + one full/global NoPE layer, iRoPE interleave preserved with the RoPE layer first as in the base pattern) was used because fixed dimensions force a larger model: untied 2x(202048x5120) embeddings alone are 2.07B and each MoE layer costs 62.9M attention + 125.8M shared expert + 125.8M per routed expert. The briefed 4-layer full 3:1 period with 4 experts would be ~4.9B total.

Checkpoint Structure

Single model.safetensors file with 69 tensors, using the original base checkpoint naming (language_model.model.*, language_model.lm_head.weight, vision_model.*, multi_modal_projector.linear_1.weight) including the grouped 3D routed-expert tensors feed_forward.experts.gate_up_proj [4, 5120, 16384] and feed_forward.experts.down_proj [4, 8192, 5120] and the per-layer feed_forward.shared_expert.* / feed_forward.router.weight. Verified against the base checkpoint headers fetched over HTTP: 0 missing and 0 extra tensor-name patterns; the text layer-0 key set is identical to a base chunked-attention layer and the layer-1 key set is identical to a base full-attention (NoPE) layer (base layer 3), with identical shapes modulo the 16 -> 4 expert count; vision layer keys/shapes and all fixed tensors (embeddings, lm_head, patch embedding, positional embedding, vision adapter, projector) match the base exactly.

Usage

from transformers import Llama4ForConditionalGeneration, AutoProcessor

model = Llama4ForConditionalGeneration.from_pretrained("inference-optimization/Llama-4-Scout-3.5B-A2.7B-small", device_map="auto")
processor = AutoProcessor.from_pretrained("inference-optimization/Llama-4-Scout-3.5B-A2.7B-small")

input_ids = processor.tokenizer("According to all known laws", return_tensors="pt").input_ids.to(model.device)
output = model.generate(input_ids, max_new_tokens=20)
print(processor.tokenizer.decode(output[0]))

Note: when calling the processor with images, pass truncation=False (or a large max_length) โ€” the tokenizer's default 512-token max_length truncates expanded multimodal prompts.

Creation Process

This model was created using the llm-compressor create-tiny-model skill.

  1. Loaded the base config and applied only the allowed changes (text layers 48 -> 2 with layer_types/no_rope_layers/moe_layers trimmed consistently, experts 16 -> 4, vision layers 34 -> 2).
  2. Built the model with random init (no base weights downloaded) and fixed non-finite initializations; model._weight_conversions = [] (no conversion registry entry for llama4 โ€” module names match the base checkpoint directly, as a real base load records).
  3. Fine-tuned on the skill's toy copypasta dataset (text-only) with bf16 until convergence (train loss ~0.06).
  4. Validated the checkpoint structure against the base and the fine-tuned model's perplexity/generation/multimodal forward.

Notes

  • No MTP: this family has no num_nextn_predict_layers in its config; the checkpoint is the full model.
  • No quantization_config in the base (bf16), so none was stripped.
  • Validation: perplexity 1.0449 on the validation text (target <= 10), greedy generation reproduces the fine-tuning text, and an image+text multimodal forward through the processor produces finite logits (1032 tokens: 7 tiles x 144 patches + 1 global patch group + text, aspect ratio 2:3).
  • Fine-tuned weights are uploaded (not the raw random init).

Validation Output

Perplexity: 1.0448508262634277 (target <= 10.0)
Success

Generating sample text:
According to all known laws of aviation, there is no way a bee should be able to fly

Multimodal forward OK: logits shape (1, 1032, 202048), finite=True
Downloads last month
31
Safetensors
Model size
4B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for inference-optimization/Llama-4-Scout-3.5B-A2.7B-small

Collection including inference-optimization/Llama-4-Scout-3.5B-A2.7B-small