Model Overview
- Model Architecture: LagunaForCausalLM
- Source Model: Laguna-XS-2.1
- Supported Hardware: AMD EPYC (CPU inference)
- Preferred Operating System: Linux
- Inference Engine: vLLM v0.34.0
- Compression Framework: LLM Compressor v0.14.0
- Compression Method: REAP 50% expert pruning (weights remain BF16)
- Compatible Stack:
- ZenDNN (main)
- ZenTorch (main)
- PyTorch v2.14.0+cpu
- Transformers v5.20.2
- LLM Compressor v0.14.0
- vLLM v0.34.0
- Python 3.12.16
This is a pruned version of Laguna-XS-2.1 created by AMD using LLM Compressor (compressed-tensors) for ZenDNN-optimized CPU inference.
Compression
The model was pruned from Laguna-XS-2.1 using LLM Compressor via REAP (Router-weighted Expert Activation Pruning). This reduces the model weights from 62.3 GiB to 33.0 GiB on disk (~47% reduction).
- Method: REAP 50% expert pruning
- Config:
REAPPruningModifier, sparsity=0.50
- Sparsity: 50% of the experts in every MoE layer —
num_experts drops from 256 to 128 in each of the 39 MoE layers
- Precision: BF16 throughout — this is a structural pruning pass, not a quantization pass, so every tensor stays BF16 and the checkpoint carries no
quantization_config
- Pruned: the routed experts (
mlp.experts.*.{gate,up,down}_proj), the router rows (mlp.gate.weight), and the router's per-expert bias (mlp.experts.e_score_correction_bias)
- Left intact: the dense MLP in layer 0, the shared expert in every MoE layer (
mlp.shared_expert.{gate,up,down}_proj), self_attn.{q,k,v,o,g}_proj with their q/k norms, lm_head, embed_tokens, and the layer norms
- Calibration: 128 samples from allenai/tulu-3-sft-personas-math, rendered through the model's chat template at a max sequence length of 2048, one sequence per batch
REAP scores each expert by how much it actually contributes to its layer's output, weighting the expert's activation magnitude by the router probability it receives, then drops the lowest-scoring half. The router's top-8 selection is unchanged; it simply chooses from the 128 experts that remain in each layer, and both the router projection ([128, 2048]) and its e_score_correction_bias ([128]) are sliced down to match — leaving the bias at its original width would bias the surviving experts' logits. Because the score depends on the router's real activations, the pass needs calibration data and moe_calibrate_all_experts=False so that each expert is only measured on the tokens actually routed to it.
Laguna is a hybrid of dense and MoE blocks: layer 0 is a plain dense MLP and the remaining 39 of the 40 decoder layers are MoE, each pairing 256 routed experts with an always-on shared expert. Only the routed experts in those 39 layers are pruned; the dense layer and every shared expert are left exactly as they were. On disk the routed experts stay as one 2D tensor per expert (mlp.experts.N.{gate,up,down}_proj.weight), matching the source layout, so the result loads as a stock Laguna checkpoint with num_experts set to 128. The surviving expert indices are written to retained_experts.json in the output directory, one list of 128 indices per MoE layer.
import torchimport transformersfrom transformers import AutoConfig, AutoProcessor from llmcompressor import oneshotfrom llmcompressor.modifiers.pruning import REAPPruningModifierfrom llmcompressor.modeling.moe.linearize import repack_moefrom llmcompressor.utils import load_context model_id = "poolside/Laguna-XS-2.1"output_dir = "./Laguna-XS-2.1-REAP-50" # Step 1: Load the BF16 model. load_context() exposes the experts as per-expert# linears so each expert's output can be hooked. Layer 0 is a dense MLP, so 39 of# the 40 layers are pruned. The router's e_score_correction_bias is sliced together# with the router weight; the routed experts keep one 2D tensor per expert on disk,# same as the source.model_cls = getattr(transformers, AutoConfig.from_pretrained(model_id).architectures[0])with load_context(model_cls): model = model_cls.from_pretrained(model_id, dtype=torch.bfloat16)processor = AutoProcessor.from_pretrained(model_id) # Step 2: Calibration set. 128 samples from allenai/tulu-3-sft-personas-math, rendered# through the model's chat template (see reap_moe.py, section 6), named `dataset` below. # Step 3: REAP recipe. Drop 50% of the experts in every MoE layer (256 -> 128).recipe = REAPPruningModifier(sparsity=0.5, report_path=f"{output_dir}/retained_experts.json") # Step 4: One-shot prune, one decoder layer at a time. batch_size=1 keeps every# calibration token. All experts are not force-calibrated, since REAP needs the# router's real activations. max_seq_length was not recorded for this run; set it# to match reap_moe.py (default 2048).oneshot( model=model, processor=processor, dataset=dataset, recipe=recipe, num_calibration_samples=128, batch_size=1, sequential_targets=["LagunaDecoderLayer"], moe_calibrate_all_experts=False,) # Step 5: Pack the per-expert linears back, then save.repack_moe(model)model.save_pretrained(output_dir, save_compressed=True)processor.save_pretrained(output_dir)
Quick Start
Use with vLLM
from vllm import LLM, SamplingParams model = LLM( model="amd/Laguna-XS-2.1-reap-50-llmcompressor", dtype="bfloat16", trust_remote_code=True,) sampling_params = SamplingParams(temperature=0.7, max_tokens=256)outputs = model.generate(["Hello, how are you?"], sampling_params)print(outputs[0].outputs[0].text)
Note: Laguna ships its own modeling code (configuration_laguna.py, modeling_laguna.py), so trust_remote_code=True is required.
Requirements
torch==2.14.0+cputransformers==5.20.2vllm==0.34.0llmcompressor==0.14.0zentorch # main
Built and validated on Python 3.12.16 with ZenDNN built from main.
OpenMP Setup
For optimal performance, set LD_PRELOAD with libomp.so (LLVM OpenMP) or libiomp5.so (Intel OpenMP):
# Using LLVM OpenMP (llvmopenmp)export LD_PRELOAD=$(find /path/to/env -name "libomp.so" | head -1) # Or using Intel OpenMP (libiomp)export LD_PRELOAD=$(find /path/to/env -name "libiomp5.so" | head -1)
Note: Set LD_PRELOAD before launching vLLM or any inference script.
Evaluation
The model was evaluated against the BF16 (unpruned) baseline on standard benchmarks using lm-evaluation-harness with the vLLM engine.
Table with columns: Benchmark, BF16 Baseline, REAP-50 (this model), Recovery| Benchmark | BF16 Baseline | REAP-50 (this model) | Recovery |
|---|
| GSM8K (5-shot) | 0.9128 | 0.8976 | 98.33% |
Evaluation Command
lm_eval \ --model vllm \ --model_args pretrained=amd/Laguna-XS-2.1-reap-50-llmcompressor,dtype=bfloat16,max_model_len=4096 \ --tasks gsm8k \ --batch_size auto \ --trust_remote_code \ --num_fewshot 5 \ --apply_chat_template \ --log_samples \ --gen_kwargs "max_gen_toks=2048" \ --output_path .
Limitations
- Version Lock: This model is validated against ZenDNN
main / ZenTorch main / PyTorch v2.14.0+cpu / Transformers v5.20.2. It may not load correctly on other versions.
- CPU Only: This model is optimized for AMD EPYC CPU inference via ZenDNN. It is not intended for GPU inference.
- Custom Modeling Code: Loading requires
trust_remote_code=True, since Laguna is not a built-in Transformers architecture.
- Accuracy Trade-off: Removing half of every layer's experts permanently removes capacity rather than approximating it, so the loss is not recoverable at inference time the way a quantization error partly is. On GSM8K this costs about 1.5 points (98.33% recovery).
- Calibration Bias: The experts that survive were selected using a math instruction-tuning set, so the GSM8K recovery above is measured on the kind of data the pruning was fitted to. Code generation, which this model family targets, is not represented in the calibration set and may degrade more than this number suggests.
License
This model is distributed under the same license as the source model. See the LICENSE file for details.
Modifications copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.