Instructions to use sarimahsan101/Spire-27B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sarimahsan101/Spire-27B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sarimahsan101/Spire-27B") 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-27B") model = AutoModelForMultimodalLM.from_pretrained("sarimahsan101/Spire-27B", 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-27B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sarimahsan101/Spire-27B" # 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-27B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sarimahsan101/Spire-27B
- SGLang
How to use sarimahsan101/Spire-27B 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-27B" \ --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-27B", "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-27B" \ --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-27B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use sarimahsan101/Spire-27B with Docker Model Runner:
docker model run hf.co/sarimahsan101/Spire-27B
Spire-27B is the 27B flagship model in the Spire compute shader family, fine-tuned from Qwen/Qwen3.5-27B for high-reliability Vulkan GLSL (#version 450) and WebGPU WGSL compute shader generation, debugging, and translation.
Highlights
- 96.6% Compile & Run Reliability (
201/208): Achieves near-perfect shader compilation (76.4% โ 96.6%, +20.2pp) and GPU execution (62.5% โ 96.6%, +34.1pp) with zero runtime crashes across all compiled shaders. - +16.3pp Overall Pass@1 & +36.5pp Vulkan GLSL: Lifts
Qwen/Qwen3.5-27Bfrom42.8% โ 59.1%overall Pass@1 and boosts standalone Vulkan GLSL Pass@1 from15.4% โ 51.9%(+38 additional passing kernels). - Best-in-Family WebGPU WGSL & Complex Kernels: Leads all fine-tuned Spire models on WGSL (
66.4%), Data Movement (77.3%), Quantization (77.3%), Attention (58.3%), and Matrix Multiply (57.1%). - 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).
Spire Model Family Benchmark (208 Tests)
| Model | Size | Compile Rate | Run Rate | Overall Pass@1 | GLSL Pass@1 | WGSL Pass@1 |
|---|---|---|---|---|---|---|
Qwen/Qwen3.5-9B (Base) |
9B | 32.7% | 30.3% | 20.7% (43/208) | 0.0% (0/104) | 41.3% (43/104) |
Qwen/Qwen3.5-27B (Base) |
27B | 76.4% | 62.5% | 42.8% (89/208) | 15.4% (16/104) | 70.2% (73/104) |
sarimahsan101/Spire-9B-RL |
9B | 91.8% | 91.8% | 59.6% (124/208) | 65.4% (68/104) | 53.8% (56/104) |
sarimahsan101/Spire-27B |
27B | 96.6% | 96.6% | 59.1% (123/208) | 51.9% (54/104) | 66.4% (69/104) |
| Gain vs. Qwen3.5-27B Base | โ | +20.2pp | +34.1pp | +16.3pp (+34) | +36.5pp (+38) | -3.8pp (-4) |
Per-Category Pass@1 Breakdown (Qwen3.5-27B Base โ Spire-27B)
| Compute Kernel Category | Tests | Qwen3.5-27B Base |
Spire-27B (Ours) | Gain (ฮ) |
|---|---|---|---|---|
| Elementwise | 34 | 70.6% (24/34) | 94.1% (32/34) | +23.5pp (+8) |
| Data Movement | 22 | 54.6% (12/22) | 77.3% (17/22) | +22.7pp (+5) |
| Quantization | 22 | 59.1% (13/22) | 77.3% (17/22) | +18.2pp (+4) |
| Attention & Data | 24 | 37.5% (9/24) | 58.3% (14/24) | +20.8pp (+5) |
| Matrix Multiply | 28 | 42.9% (12/28) | 57.1% (16/28) | +14.3pp (+4) |
| Scan & Sort | 24 | 29.2% (7/24) | 41.7% (10/24) | +12.5pp (+3) |
| Reduction | 28 | 10.7% (3/28) | 35.7% (10/28) | +25.0pp (+7) |
| Conv & Pooling | 26 | 34.6% (9/26) | 26.9% (7/26) | -7.7pp (-2) |
Choosing Between Spire-27B and Spire-9B-RL
| Use Case | Recommended Model | Why |
|---|---|---|
| WebGPU WGSL, Attention, Quantization, Data Movement, MatMul | Spire-27B |
Highest compile/run rate (96.6%), best fine-tuned WGSL (66.4%), strongest on complex memory/attention kernels |
| Vulkan GLSL, Fast Local Inference, Scan/Sort & Reduction | Spire-9B-RL |
RL-optimized for Vulkan GLSL (65.4%), 3ร smaller/faster, GGUF quants available |
Quickstart
Important:
Spire-27Bwas 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-27B"
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 WebGPU WGSL compute shader with @workgroup_size(64, 1, 1) "
"that computes row-wise RMSNorm over a float buffer X (binding 0, shape [R, C]) "
"with weight W (binding 1, shape [C]), output Y (binding 2, shape [R, C]), "
"and uniform Params { R: u32, C: u32, eps: f32 } (binding 3)."
),
},
]
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-27B \
--dtype bfloat16 \
--max-model-len 4096
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 outside the target scope. - Verification Recommended: While
96.6%of generated shaders compile and execute cleanly, complex multi-pass or shared-memory kernels (e.g., 2D convolutions) should still be validated against unit tests in your target compute pipeline. - License: Released under Apache 2.0, inheriting the permissive open-source terms of
Qwen/Qwen3.5-27B.
Citation
@misc{spire27b2026,
title = {Spire-27B: Compute Shader Generation for Vulkan GLSL and WebGPU WGSL},
author = {Sarim Ahsan},
year = {2026},
url = {https://huggingface.co/sarimahsan101/Spire-27B}
}
- Downloads last month
- 12
Model tree for sarimahsan101/Spire-27B
Base model
Qwen/Qwen3.5-27BCollection including sarimahsan101/Spire-27B
Evaluation results
- Overall Pass@1 (208 tests) on Spire Held-Out 104-Task Compute Shader Benchmark (GLSL + WGSL)test set self-reported59.130
- GLSL Pass@1 (104 tests) on Spire Held-Out 104-Task Compute Shader Benchmark (GLSL + WGSL)test set self-reported51.920
- WGSL Pass@1 (104 tests) on Spire Held-Out 104-Task Compute Shader Benchmark (GLSL + WGSL)test set self-reported66.350
- Compile & Run Rate on Spire Held-Out 104-Task Compute Shader Benchmark (GLSL + WGSL)test set self-reported96.630