Museglimmer-30b-triton-kernelgen
A merged LoRA fine-tune of
meta-models/Muse-Glimmer-30B
that writes Triton GPU kernels from PyTorch modules, trained inside an agentic
loop — it compiles, reads the error, and fixes it across turns. The adapter was
fused with merge_and_unload(), so there is no PEFT dependency at load time.
A reduced-scale reproduction of the RFT stage of CUDA Agent (arXiv:2602.24286).
Model details
| Base model | meta-models/Muse-Glimmer-30B |
| Base parameters | 29.6B (incl. perception encoder) |
| Architecture | muse_glimmer — dense causal transformer, 52 layers, GQA 32/2, SwiGLU, [Local, Local, Local, Global] attention with a 2048 sliding window, gated attention |
| Adaptation | LoRA r=16, alpha=32, dropout=0.05 |
| Targeted modules | 7 llama-style projections (q/k/v/o_proj, gate/up/down_proj) across the language model only |
| Untrained | the vision tower, excluded via .*vision_tower.* |
| Training quantisation | 4-bit NF4 QLoRA — training-time only; the shipped weights are bf16 with no quantization_config |
| Shipped size | 56 GB in 2 safetensors shards |
| License | apache-2.0, inherited from the base |
The vision-tower exclusion is load-bearing. It reuses the same q/k/v_proj
names as the language model, so an unexcluded adapter silently trains 1.85B of
vision parameters (6.2% of the model) on a text-only task.
Merge verified by tensor diff, not assumed: a LoRA-targeted q_proj differs
from the base by 3.05e-05, while an untargeted input_layernorm is
bit-identical.
Intended use
Direct use — inside a multi-turn agent loop. This model was trained on trajectories where it writes a kernel, calls a verifier, reads the failure, and edits. Its measured benefit comes from that loop.
How to get started
Prompt format
The model was trained on a chat template with a system turn carrying the workspace rules and a user turn carrying the reference PyTorch module, then alternating assistant actions and tool observations. The format is part of the contract.
The action grammar it emits is a fenced block:
```action
write_file model_new.py
<full file contents>
```
with verbs list_files, read_file, write_file, edit_file, verify,
profile, done.
This is a reasoning model. A turn is chain-of-thought in a
to=selfchannel followed by the reply into=user. Decoding withskip_special_tokens=Trueleaves the literalto=usermarker in the text — split on it and keep what follows. We lost a full generation run to this before catching it: the marker fused onto the first code line, a prose filter dropped that line, and every kernel lost itsimport torch.
System prompt
Single-shot use needs a condensed version of the training system prompt:
You are a Triton and GPU performance expert. Given a PyTorch module, write a
complete, self-contained Triton implementation that computes the same result.
Emit only Python source: @triton.jit kernels plus their host code. Do not call
torch.nn.functional, torch.matmul, or other torch compute ops — write the kernel.
The training-time prompt also carried the workspace layout, the restriction list and an optimisation priority order. That harness is not published, so the block above is the portion that still applies without it.
Loading it
from transformers import AutoModelForImageTextToText, AutoTokenizer
REPO = "SASVAAI/Museglimmer-30b-triton-kernelgen"
tokenizer = AutoTokenizer.from_pretrained(REPO)
model = AutoModelForImageTextToText.from_pretrained(
REPO, dtype="bfloat16", device_map="auto", attn_implementation="sdpa",
)
model.eval()
AutoModelForImageTextToText, not AutoModelForCausalLM: muse_glimmer
has no entry in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES, so the LM head is only
reachable through the conditional-generation class. AutoModelForCausalLM
raises Unrecognized configuration class.
Requires a transformers that knows this architecture — it does not exist in
the 5.7.x line. Verified with 5.16.0.dev0 (git 83d024e).
attn_implementation="sdpa" is forced: the architecture is SDPA-only and the
venv that loads it deliberately drops flash-attn.
Run locally with Ollama
⚠️ NOT VERIFIED. Unlike the sibling
qwen38-27b-terraformcard, this section carries no verified transcript. Neither llama.cpp nor Ollama is installed on the machine this model was trained on, so the GGUF has not been built, loaded, or run. Everything below is derived from upstream documentation. Treat it as a starting point, not a tested recipe — and expect to hit something we have not.
Requirements
| llama.cpp | release b10353 or later. b10344 and older fail with unknown model architecture: 'muse-glimmer' |
| Ollama | a build bundling llama.cpp ≥ b10353. Ollama ships its own copy — if yours predates it, conversion succeeds and loading fails |
| GGUF architecture string | muse-glimmer (hyphenated), not the HF muse_glimmer |
Support landed via llama.cpp PR #26841. Confirm your checkout registers it before converting anything:
python convert_hf_to_gguf.py --print-supported-models | grep -i glimmer
Building your own GGUF
No GGUF ships in this repo. To build one:
git clone https://github.com/ggml-org/llama.cpp && cd llama.cpp
pip install -r requirements.txt
# f16 first (~60 GB). --mmproj is NOT needed: this task is text-only.
python convert_hf_to_gguf.py /path/to/Museglimmer-30b-triton-kernelgen \
--outfile Museglimmer-30b-triton-kernelgen-f16.gguf --outtype f16
cmake -B build -DLLAMA_BUILD_UI=OFF -DLLAMA_USE_PREBUILT_UI=OFF
cmake --build build --config Release -j
./build/bin/llama-quantize \
Museglimmer-30b-triton-kernelgen-f16.gguf \
Museglimmer-30b-triton-kernelgen-Q4_K_M.gguf Q4_K_M
Q4_K_M should land near 17 GB — the size Meta publishes for the base
model's own GGUF (meta-models/Muse-Glimmer-30B-GGUF). That fits a 24 GB card.
Modelfile:
FROM ./Museglimmer-30b-triton-kernelgen-Q4_K_M.gguf
PARAMETER temperature 0
PARAMETER num_ctx 16384
PARAMETER num_predict 6144
SYSTEM """You are a Triton and GPU performance expert. Given a PyTorch module, write a complete, self-contained Triton implementation that computes the same result. Emit only Python source: @triton.jit kernels plus their host code. Do not call torch.nn.functional, torch.matmul, or other torch compute ops — write the kernel."""
ollama create Museglimmer-30b-triton-kernelgen -f Modelfile
ollama run Museglimmer-30b-triton-kernelgen
Pin num_ctx to 16384. Trajectories were trained at that length. Ollama's
default is far larger and a mismatch silently changes the context the model was
conditioned on.
The reasoning channel will show up in Ollama
to=self / to=user markers are template text, not special tokens, so they
survive into Ollama's output. Expect the model's chain-of-thought before the
answer. There is no post-processing layer in ollama run to strip it.
What to expect
Single-shot Triton for a pasted PyTorch module — useful for is this emitting sane kernels? It will not reproduce the 26/100 below: that number comes from the agent loop with a real verifier. Ollama has no verifier, so nothing checks correctness or speed. Assume every kernel it emits is unverified until you run it yourself.
Training details
Data
81 execution-verified agent trajectories (1,475 assistant turns), selected from
300 collected episodes. Not published — the problems derive from
GPUMODE/KernelBook and GPUMODE/kernelbot-data through a local filtering
pipeline, and the trajectories contain model-generated code with no licence
review.
| Episodes collected | 300 (base model, 20-turn budget, 8× H200, ~10 h) |
| Trajectories kept | 81 |
| Assistant turns trained on | 1,475 (median 20 per trajectory) |
| Rejected — final kernel below reward threshold | 118 |
| Rejected — redundant action loop | 71 |
| Rejected — no parseable action | 30 |
| Max sequence length | 16,384 |
Both of the paper's §3.3 filters were applied: a pattern filter dropping
stalled episodes, schema violators and empty finals, and an outcome filter
executing each trajectory's best kernel and keeping those scoring ≥1 on the
milestone reward (-1 incorrect, 1 correct, 2 beats eager, 3 beats eager
and torch.compile by >5%).
Failed turns were kept deliberately. A trajectory that recovered from a compile error on turn 8 retains all seven failures — the failure is the input the recovery responds to.
Method
| SFT method | qlora — 4-bit NF4 base, bf16 compute |
| Refinement stage | none applied on top |
| Hardware | 8× H200 (trajectory collection), 1× H200 (training) |
Final hyperparameters
| Hyperparameter | Value |
|---|---|
learning_rate | 1e-5 |
num_train_epochs | 2 |
per_device_train_batch_size | 1 |
gradient_accumulation_steps | 8 |
| effective batch size | 8 |
| optimizer steps | 22 |
max_length | 16384 |
lora_r / lora_alpha / lora_dropout | 16 / 32 / 0.05 |
Not searched. Chosen as a deliberately gentle refinement pass — a large step over 81 examples would overwrite the base rather than adapt it. The configuration is untuned, not optimal.
Observed training metrics
| Final train loss | 0.5695 |
| Train runtime | 1,428 s |
| Samples/second | 0.113 |
Evaluation
Protocol. Each problem gets a fresh workspace and up to 20 agent turns. The
kernel scored is the best in the trajectory, not the last — of 80 verified
episodes during collection, 30 kept editing after passing, so last-state scoring
records genuine successes as failures. Scoring compiles the kernel, checks it
against the reference on 5 random inputs (atol=rtol=1e-2), and times it
against PyTorch eager and torch.compile with warmup, device synchronisation
and repeated measurement on an idle GPU.
Evaluation set: a seeded 100-problem subset of the kernelgen_mix validation
split, held out from training.
| configuration | correct | beats torch.compile | speedup vs torch.compile |
|---|---|---|---|
| base model, single-shot | 22 | — | 0.943× |
| base model, agent loop | 17 | 12 | 1.263× |
| this model, agent loop | 26 | 18 | 1.321× |
Speedups are geometric means over each row's own correct kernels, so the
denominators differ (22 / 17 / 26). The correct column is the comparable one.
What did not work, published because negative results are the useful part:
- Single-turn RFT changed nothing. An earlier round trained on 148 final answers — same model, reward and harness, no failure/recovery content. 101/367 correct before, 101/367 after.
- The agent loop alone made the untrained model worse — 22 → 17.
- GRPO regressed this model. 3 iterations took it 26 → 23. Mean training reward rose (0.69 → 0.84) then collapsed (0.27). These weights are the RFT model, not the GRPO one.
Limitations.
- The benchmark has almost no speedup headroom. 99.2% of its problems run in under 1 ms — below the 1–100 ms window the paper's own synthesis filter requires. Below a millisecond the clock measures launch overhead, not compute, so every speedup figure here is weak evidence.
- 11 of 26 correct measurements have untrustworthy timings (CV > 5%).
- n = 100. 26 vs 22 is about 1.5 standard errors. Suggestive, not conclusive.
- Not comparable to the paper: they report 98.8% pass and 2.11× on KernelBench with 128 GPUs and a 230B MoE base. We never ran KernelBench.
- The system prompt is a reconstruction — the original was rendered into a gitignored file and is unrecoverable.
- No safety tuning. Inherits all base-model biases and limitations.
Environmental impact
| Hardware | 8× NVIDIA H200 (collection, evaluation), 1× H200 (training) |
| Trajectory collection | ~10 h wall clock on 8 GPUs |
| Training | 24 minutes on 1 GPU |
| Evaluation | ~3.5 h per configuration on 8 GPUs |
| Total incl. discarded runs | roughly 150 GPU-hours |
| Provider / region | on-premise |
Framework versions
- PEFT 0.18.1
- TRL 1.0.0
- Transformers 5.16.0.dev0 (git
83d024e) - PyTorch 2.6.0+cu124
- Tokenizers 0.23.2
transformers must be that commit or newer — muse_glimmer does not exist in
the 5.7.x line. torch>=2.6 is needed only for the RL stack
(trl.GRPOTrainer imports FSDPModule).
Citation
The method being reproduced:
@misc{dai2026cudaagent,
title = {CUDA Agent: Large-Scale Agentic RL for High-Performance CUDA Kernel Generation},
author = {Dai, Weinan and Wu, Hanlin and Yu, Qiying and Gao, Huan-ang and Li, Jiahao
and Jiang, Chengquan and Lou, Weiqiang and Song, Yufan and Yu, Hongli
and Chen, Jiaze and Ma, Wei-Ying and Zhang, Ya-Qin and Liu, Jingjing
and Wang, Mingxuan and Liu, Xin and Zhou, Hao},
year = {2026},
eprint = {2602.24286},
url = {https://arxiv.org/abs/2602.24286}
}
This model:
@misc{museglimmer30btritonkernelgen,
title = {Museglimmer-30b-triton-kernelgen: a reduced-scale reproduction of CUDA Agent's RFT stage},
author = {SASVA AI MCL Team},
year = {2026},
url = {https://huggingface.co/SASVAAI/Museglimmer-30b-triton-kernelgen}
}