Spire-9B-RL โ€” Vulkan GLSL & WebGPU WGSL Compute Shader Model

Base Model GGUF Quantizations Pass@1 59.6% GLSL Pass@1 65.4% Apache 2.0

Spire-9B-RL is an open-weights 9B GPU compute shader model fine-tuned from Qwen/Qwen3.5-9B using BF16 LoRA SFT followed by Execution-Verified GRPO against a live Vulkan (SPIR-V) & WebGPU compiler and GPU verifier.


Highlights

  • Beats 3ร— Larger Qwen3.5-27B Base (59.6% vs. 42.8%): Spire-9B-RL outperforms Qwen/Qwen3.5-27B Base by +16.8pp overall and +50.0pp on Vulkan GLSL (65.4% vs. 15.4%), while nearly 3ร— its own Qwen3.5-9B base (20.7% โ†’ 59.6%, +38.9pp).
  • Vulkan GLSL Breakthrough (0.0% โ†’ 65.4%): Base Qwen3.5-9B scores 0.0% on standalone Vulkan #version 450 compute shaders; SFT lifts it to 52.9%, and Verifier-GRPO pushes it another +12.5pp to 65.4%.
  • Zero Category Regressions Under RL: Across all 8 GPU compute kernel domains, Verifier-GRPO improves or matches SFT everywhere โ€” with the largest gains on hard algorithmic kernels (Quantization +13.6pp, Scan & Sort +12.5pp, Reduction +10.7pp, Attention +8.3pp).
  • 100% Runtime Stability on Valid Shaders: 91.8% compile rate and 91.8% execution rate โ€” zero runtime crashes on compiled shaders.
  • Multi-Task Compute Engineering: Writes standalone Vulkan GLSL (#version 450) and WebGPU WGSL compute shaders from natural-language specs, fixes broken kernels from compiler/runtime diagnostics, and translates between GLSL โ†” WGSL.

Benchmark Results

All models are evaluated with greedy decoding (do_sample=False, enable_thinking=False) on the 104 held-out test tasks across both Vulkan GLSL and WebGPU WGSL (208 total tests). Every generated shader must:

  1. Compile & Validate: glslangValidator -V + spirv-val (for GLSL) or naga / wgpu validation (for WGSL).
  2. Execute on GPU: Dispatch cleanly on a real GPU compute pipeline without device loss or out-of-bounds faults.
  3. Pass Numerical Equivalence: Match reference NumPy/PyTorch outputs across multiple tensor shapes (atol=1e-3, rtol=1e-2).

Spire-9B-RL Benchmark Progression: Base vs SFT vs Verifier-GRPO

Overall Held-Out Benchmark (208 Tests)

Model Method Compile Rate Run Rate Overall Pass@1 GLSL Pass@1 WGSL Pass@1
Qwen/Qwen3.5-9B Base (Zero-Shot) 32.7% 30.3% 20.7% (43/208) 0.0% (0/104) 41.3% (43/104)
Qwen/Qwen3.5-27B (3ร— larger) Base (Zero-Shot) 76.4% 62.5% 42.8% (89/208) 15.4% (16/104) 70.2% (73/104)
Spire-9B-SFT BF16 LoRA SFT 91.4% 90.9% 52.9% (110/208) 52.9% (55/104) 52.9% (55/104)
sarimahsan101/Spire-9B-RL BF16 SFT + Verifier-GRPO 91.8% 91.8% 59.6% (124/208) 65.4% (68/104) 53.8% (56/104)
Gain vs. Qwen3.5-9B Base โ€” +59.1pp +61.5pp +38.9pp (+81) +65.4pp (+68) +12.5pp (+13)
Gain vs. Qwen3.5-27B Base โ€” +15.4pp +29.3pp +16.8pp (+35) +50.0pp (+52) -16.3pp (-17)
Gain vs. Spire-9B SFT โ€” +0.5pp +1.0pp +6.7pp (+14) +12.5pp (+13) +1.0pp (+1)

Per-Category Pass@1 Breakdown (SFT โ†’ Verifier-GRPO)

Spire-9B-RL Per-Category Pass@1 Breakdown

Compute Kernel Category Tests Spire-9B SFT Spire-9B-RL (Ours) RL Gain (ฮ”)
Elementwise 34 94.1% (32/34) 97.1% (33/34) +2.9pp (+1)
Quantization 22 54.6% (12/22) 68.2% (15/22) +13.6pp (+3)
Data Movement 22 63.6% (14/22) 68.2% (15/22) +4.5pp (+1)
Scan & Sort 24 41.7% (10/24) 54.2% (13/24) +12.5pp (+3)
Matrix Multiply 28 50.0% (14/28) 53.6% (15/28) +3.6pp (+1)
Reduction 28 35.7% (10/28) 46.4% (13/28) +10.7pp (+3)
Attention & Data 24 37.5% (9/24) 45.8% (11/24) +8.3pp (+2)
Conv & Pooling 26 34.6% (9/26) 34.6% (9/26) 0.0pp (0)

Quickstart

Important: Spire-9B-RL was trained with direct shader emission (enable_thinking=False) and outputs clean, standalone shaders inside a single fenced code block (```glsl or ```wgsl).

1. Transformers (Python)

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "sarimahsan101/Spire-9B-RL"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)

messages = [
    {
        "role": "system",
        "content": (
            "You are an expert GPU compute shader engineer specializing in "
            "Vulkan GLSL and WebGPU WGSL. Write standalone, race-free, valid compute "
            "shaders that strictly follow the requested bindings and workgroup layout. "
            "Output the shader inside a single fenced code block (```glsl or ```wgsl)."
        ),
    },
    {
        "role": "user",
        "content": (
            "Write a Vulkan GLSL (#version 450) compute shader with local_size_x = 64 "
            "that computes row-wise LayerNorm over a float buffer X (binding 0, shape [R, C]) "
            "with gamma (binding 1, shape [C]), beta (binding 2, shape [C]), "
            "output Y (binding 3, shape [R, C]), and uniform Params { uint R; uint C; float eps; } (binding 4)."
        ),
    },
]

prompt = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
    enable_thinking=False,
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=1536, do_sample=False)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))

2. vLLM (OpenAI-Compatible Server)

vllm serve sarimahsan101/Spire-9B-RL \
  --dtype bfloat16 \
  --max-model-len 4096

3. llama.cpp / Ollama (GGUF)

Pre-quantized GGUF weights are available at sarimahsan101/Spire-9B-RL-GGUF:

# Run directly with llama.cpp
llama-cli \
  -hf sarimahsan101/Spire-9B-RL-GGUF:Q4_K_M \
  --temp 0.0 \
  -p "Write a WebGPU WGSL compute shader for 1D prefix sum (Blelloch scan) with workgroup_size(64)."

Available Formats & Quantizations

Repository Format / Quant Approx. Size Recommended Use
sarimahsan101/Spire-9B-RL BF16 (safetensors) ~18 GB Full-precision inference, vLLM, further fine-tuning
sarimahsan101/Spire-9B-RL-GGUF Q8_0 ~9.5 GB Near-lossless local GPU inference (llama.cpp / LM Studio / Ollama)
sarimahsan101/Spire-9B-RL-GGUF Q5_K_M ~6.5 GB Best quality-to-size balance for 8โ€“12 GB GPUs
sarimahsan101/Spire-9B-RL-GGUF Q4_K_M ~5.5 GB Fast local inference on consumer GPUs & Apple Silicon

Limitations & Intended Use

  • Domain Focus: Optimized specifically for compute shaders (Vulkan GLSL #version 450 and WebGPU WGSL). Graphics pipeline stages (vertex, fragment, tessellation, ray tracing) were not part of the RL verifier curriculum.
  • Verification Recommended: While 91.8% of generated shaders compile and execute cleanly, complex multi-pass or shared-memory kernels (e.g., 2D convolutions or custom attention variants) should still be validated against unit tests in your target graphics/compute pipeline.
  • License: Released under Apache 2.0, inheriting the permissive open-source terms of Qwen/Qwen3.5-9B.

Citation

@misc{spire2026,
  title  = {Spire-9B-RL: Execution-Verified Compute Shader Generation for Vulkan GLSL and WebGPU WGSL},
  author = {Sarim Ahsan},
  year   = {2026},
  url    = {https://huggingface.co/sarimahsan101/Spire-9B-RL}
}
Downloads last month
409
Safetensors
Model size
10B params
Tensor type
BF16
ยท
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for sarimahsan101/Spire-9B-RL

Finetuned
Qwen/Qwen3.5-9B
Finetuned
(1,612)
this model
Quantizations
2 models

Collection including sarimahsan101/Spire-9B-RL

Evaluation results

  • Overall Pass@1 (208 tests) on Spire Held-Out 104-Task Compute Shader Benchmark (GLSL + WGSL)
    test set self-reported
    59.620
  • GLSL Pass@1 (104 tests) on Spire Held-Out 104-Task Compute Shader Benchmark (GLSL + WGSL)
    test set self-reported
    65.380
  • WGSL Pass@1 (104 tests) on Spire Held-Out 104-Task Compute Shader Benchmark (GLSL + WGSL)
    test set self-reported
    53.850
  • Compile & Run Rate on Spire Held-Out 104-Task Compute Shader Benchmark (GLSL + WGSL)
    test set self-reported
    91.830