Downloads · 30 days
5
19% of all-time downloads
JonnyJF/laguna-xs2-coding-pruned-9pct
laguna-xs2-coding-pruned-9pct is a machine learning model from JonnyJF. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
LoRA adapter and mask spec that take poolside/Laguna-XS.2 down by ~8.9% of routed experts at preserved coding capability.
Downloads · 30 days
5
19% of all-time downloads
All-time downloads
26
Public
Repo size
19.4 MB
Likes
1
Public
Click a slice to open those files.
.safetensors19.2 MB · 72%
From the Hugging Face model README
LoRA adapter and mask spec that take poolside/Laguna-XS.2 down by ~8.9% of routed experts at preserved coding capability.
gate_proj / up_proj / down_proj at every sparse layer. Trained for 200
SFT steps on 120 MBPP completions generated by the unpruned full Laguna.Built for the Poolside × Prime Intellect hackathon on 30 May 2026.
| File | Purpose |
|---|---|
adapter_model.safetensors + adapter_config.json | peft LoRA adapter on the shared expert |
drops.json | {moe_block_idx (0..38): [expert_indices_to_mask]} — apply BEFORE loading the adapter |
prune.py | mask_experts() helper to apply the mask via router bias = -inf |
mask_snap.json | same as drops.json, saved by the training script as a sanity check |
import json, torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
from prune import mask_experts # included in this repo
REPO = "poolside-laguna-hackathon/<this-repo>"
tok = AutoTokenizer.from_pretrained("poolside/Laguna-XS.2", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
"poolside/Laguna-XS.2",
dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
# 1. Mask the cold-tail experts (sets router bias to -inf for dropped experts)
drops = {int(k): v for k, v in json.loads(open("drops.json").read()).items()}
mask_experts(model, drops)
# 2. Attach the LoRA adapter
model = PeftModel.from_pretrained(model, REPO)
model.eval()
LagunaTopKRouter (39 of them).
Accumulate per-(layer, expert) selection counts and renormalised
routing-weight mass over 30 HumanEval prompts × ~200 greedy-generated
tokens (~250k routing events).sigmoid(logits) + e_score_correction_bias for load balancing) counts get forced toward
uniform but mass still skews. Mass is the truth.mask_experts() sets e_score_correction_bias
to -inf for dropped experts. The router's top-k will never pick them,
the renormalisation across the surviving top-k handles the rest. Tensors
keep their shape — slicing is a separate ship step.Laguna's routed experts are stored as batched 3D parameter tensors
(gate_up_proj: (256, 1024, 2048), down_proj: (256, 2048, 512)) and used
via manual matmul, not nn.Linear. peft's LoRA can't target raw
parameter slices, so the adapter goes on the always-on shared expert
(shared_experts.{gate,up,down}_proj, which ARE nn.Linear). The shared
expert sees every token, so a LoRA delta there absorbs the lost routed-expert
contribution into the always-on path.
</assistant> chat
tokens that the original trim missed). The eval harness is fixed in
the source repo; numbers will be uploaded as a follow-up.Full hackathon repo (probe, prune, eval, distillation, model card): see the
Source code link in this repo's README.
Built by Jonathan Farrow (@JonnyJF) for the 30 May 2026 Poolside × Prime Intellect hackathon.