Model Overview
- Model Architecture: GptOssForCausalLM
- Source Model: gpt-oss-120b-BF16
- 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 gpt-oss-120b-BF16 created by AMD using LLM Compressor (compressed-tensors) for ZenDNN-optimized CPU inference.
Compression
The model was pruned from gpt-oss-120b-BF16 using LLM Compressor via REAP (Router-weighted Expert Activation Pruning). This reduces the model weights from 217.6 GiB to 110.8 GiB on disk (~49% reduction).
- Method: REAP 50% expert pruning
- Config:
REAPPruningModifier, sparsity=0.50
- Sparsity: 50% of the experts in every MoE layer —
num_local_experts drops from 128 to 64 in each of the 36 decoder 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 with their biases (
mlp.experts.{gate_up_proj,down_proj} and *_bias) and the matching router rows (mlp.router.weight and mlp.router.bias)
- Left intact:
self_attn.{q,k,v,o}_proj with their biases, the attention sinks (self_attn.sinks), 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 and truncated to 1024 tokens, 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-4 selection is unchanged; it simply chooses from the 64 experts that remain in each layer, and both the router projection ([64, 2880]) and its bias ([64]) are sliced down to match. 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.
gpt-oss is almost entirely experts, which is why the disk saving here is close to the full 50% rather than the ~44% typical of models that also carry a large dense or shared path. Every layer is MoE, with no shared expert and no dense MLP to preserve.
gpt-oss stores each layer's experts as fused 3D tensors, which the pruning hooks cannot address individually. load_context() splits them into per-expert linears for the duration of the pass, and repack_moe() fuses the survivors back into 3D tensors before saving, so the result loads as a stock gpt-oss checkpoint with a smaller expert dimension — mlp.experts.gate_up_proj becomes [64, 2880, 5760] and mlp.experts.down_proj becomes [64, 2880, 2880], with their biases sliced to match. The surviving expert indices are written to retained_experts.json in the output directory, one list of 64 indices per 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 = "unsloth/gpt-oss-120b-BF16"output_dir = "./gpt-oss-120b-BF16-REAP-50" # Step 1: Load the BF16 model. load_context() splits the fused 3D expert tensors# (experts.gate_up_proj / down_proj and their biases) into per-expert linears so# each expert's output can be hooked.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 and truncated to 1024 tokens (see reap_moe.py,# section 6), named `dataset` below. # Step 3: REAP recipe. Drop 50% of the experts in every MoE layer (128 -> 64).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.oneshot( model=model, processor=processor, dataset=dataset, recipe=recipe, max_seq_length=1024, num_calibration_samples=128, batch_size=1, sequential_targets=["GptOssDecoderLayer"], moe_calibrate_all_experts=False,) # Step 5: Pack the per-expert linears back into fused 3D tensors, 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/gpt-oss-120b-BF16-reap-50-llmcompressor", dtype="bfloat16",) sampling_params = SamplingParams(temperature=0.7, max_tokens=256)outputs = model.generate(["Hello, how are you?"], sampling_params)print(outputs[0].outputs[0].text)
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, flexible-extract) | 0.9014 ± 0.0082 | 0.9014 ± 0.0082 | 100.00% |
Use the flexible-extract row to judge accuracy. gpt-oss replies in its own reasoning format, which rarely ends in the literal #### <answer> pattern that strict-match requires, so both the baseline and the pruned model score far below their real solve rate on that row. The difference between the two strict-match numbers reflects how often each model's output happened to match that pattern, not a difference in how many problems were solved.
Evaluation Command
lm_eval \ --model vllm \ --model_args pretrained=amd/gpt-oss-120b-BF16-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.
- Accuracy Trade-off: Removing half of every layer's experts permanently removes capacity rather than approximating it. On GSM8K flexible-extract this model matches its BF16 baseline exactly, but a single benchmark at 100% recovery should not be read as "lossless" — with 128 experts per layer and only top-4 routing, gpt-oss-120b carries more expert redundancy than the other models in this series, and GSM8K is close to the math data the pruning was calibrated on.
- Calibration Bias: The experts that survive were selected using a math instruction-tuning set truncated to 1024 tokens. Coding, multilingual, long-context, and agentic behavior is not represented in the calibration set and may degrade noticeably more than the GSM8K 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.