Instructions to use sarimahsan101/Spire-9B-RL with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sarimahsan101/Spire-9B-RL with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sarimahsan101/Spire-9B-RL") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("sarimahsan101/Spire-9B-RL") model = AutoModelForMultimodalLM.from_pretrained("sarimahsan101/Spire-9B-RL", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use sarimahsan101/Spire-9B-RL with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sarimahsan101/Spire-9B-RL" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sarimahsan101/Spire-9B-RL", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sarimahsan101/Spire-9B-RL
- SGLang
How to use sarimahsan101/Spire-9B-RL with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "sarimahsan101/Spire-9B-RL" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sarimahsan101/Spire-9B-RL", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "sarimahsan101/Spire-9B-RL" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sarimahsan101/Spire-9B-RL", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use sarimahsan101/Spire-9B-RL with Docker Model Runner:
docker model run hf.co/sarimahsan101/Spire-9B-RL
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-27BBase (59.6%vs.42.8%):Spire-9B-RLoutperformsQwen/Qwen3.5-27BBase by +16.8pp overall and +50.0pp on Vulkan GLSL (65.4%vs.15.4%), while nearly 3ร its ownQwen3.5-9Bbase (20.7% โ 59.6%, +38.9pp). - Vulkan GLSL Breakthrough (
0.0% โ 65.4%): BaseQwen3.5-9Bscores0.0%on standalone Vulkan#version 450compute shaders; SFT lifts it to52.9%, and Verifier-GRPO pushes it another +12.5pp to65.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 and91.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:
- Compile & Validate:
glslangValidator -V+spirv-val(for GLSL) ornaga/wgpuvalidation (for WGSL). - Execute on GPU: Dispatch cleanly on a real GPU compute pipeline without device loss or out-of-bounds faults.
- Pass Numerical Equivalence: Match reference NumPy/PyTorch outputs across multiple tensor shapes (
atol=1e-3,rtol=1e-2).
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)
| 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-RLwas trained with direct shader emission (enable_thinking=False) and outputs clean, standalone shaders inside a single fenced code block (```glslor```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 450and 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
Model tree for sarimahsan101/Spire-9B-RL
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-reported59.620
- GLSL Pass@1 (104 tests) on Spire Held-Out 104-Task Compute Shader Benchmark (GLSL + WGSL)test set self-reported65.380
- WGSL Pass@1 (104 tests) on Spire Held-Out 104-Task Compute Shader Benchmark (GLSL + WGSL)test set self-reported53.850
- Compile & Run Rate on Spire Held-Out 104-Task Compute Shader Benchmark (GLSL + WGSL)test set self-reported91.830