Razor-Spark 30B (karthik-a/razor-spark-30b)
Razor-Spark 30B upgrades the controller backbone to Qwen/Qwen2.5-Coder-3B-Instruct (hidden_size=2048, 36 attention/MLP layers, 16 Q / 2 KV heads, rope_theta=1e6, native KV-cache, trained with rank-16 controller LoRA) connected to 8 Attachable 30B MoE Memory Banks (hidden_size=4096, intermediate_size=2048, 1 shared expert + 31 top-2 routed experts per bank) mapped directly from the 30B SafeTensor shards, jointly post-trained with Long-Context Coding SFT + Execution-Verified GRPO Reinforcement Learning.
Architecture Overview
| Component | Configuration |
|---|---|
| Base Controller | Qwen/Qwen2.5-Coder-3B-Instruct (hidden=2048, layers=36, rope_theta=1,000,000.0, ChatML) + merged rank-16 Controller LoRA |
| Bridged Layers | Layers [16, 18, 20, 22, 24, 26, 28, 30] mapped from 30B shard layers 0..7 |
| 30B MoE Memory Banks | LoRAInt8Linear (Int8 frozen 30B weights + rank=16 LoRA on shared & routed experts) |
| Bridge Residual Gate | x + tanh(alpha) * mem_down(MoE_30B(mem_up(RMSNorm(x)))) |
| Post-Training | Stage 1: CoT Coding & Math SFT (LeetCode, MBPP, Magicoder, CodeFeedback, GSM8K) -> Stage 2: Python Unit-Test Sandbox GRPO RL |
| Detach / Attach Mode | Toggle dynamically via model.set_attached(True / False) |
Weight Files in Repository
model-00001-of-00006.safetensors..model-00006-of-00006.safetensors(model.safetensors.index.json): 30B MoE expert shards (model.layers.{0..9}.mlp.*)razor_spark_controller_lora.safetensors: Trained rank-16 LoRA deltas for theQwen2.5-Coder-3B-Instructcontroller (~60 MB, automatically merged on load)razor_spark_bridge.safetensors: Jointly alignedAttachableBridgeprojections (mem_norm,mem_up,mem_down,mem_alpha) + Switchrouterweights (8 layers)razor_spark_moe_lora.safetensors: Jointly adaptedLoRAweights (r=16, alpha=32) for bothsharedandrouted30B experts (8 layers)eval_scorecard.json: Recorded Detached vs Attached HumanEval, MBPP, and GSM8K evaluation scorecard
Verified Benchmark Scorecard (v17: Direct 30B Shard Weight-Space Surgery + Multi-Language GRPO)
Evaluated directly on the healed & LoRA-baked bfloat16 30B shards (model-00002..00006-of-00006.safetensors with residual moe_lora.lora_B = 0) across strictly held-out tasks (bigcode/humanevalpack tasks 134..163 per language + MBPP test split):
| Benchmark | Pre-Surgery Baseline | Post-Surgery & Baked 30B (v17) | Delta |
|---|---|---|---|
Python (HumanEvalPack, 30 tasks) | 19 / 30 (63.3%) | 22 / 30 (73.3%) | +10.0% (+3) |
Java (HumanEvalPack, 30 tasks) | 17 / 30 (56.7%) | 19 / 30 (63.3%) | +6.6% (+2) |
Go (HumanEvalPack, 30 tasks) | 6 / 30 (20.0%) | 7 / 30 (23.3%) | +3.3% (+1) |
Python MBPP (test split, 50 tasks) | 29 / 50 (58.0%) | 30 / 50 (60.0%) | +2.0% (+1) |
C++ (HumanEvalPack, 30 tasks) | 13 / 30 (43.3%) | 12 / 30 (40.0%) | -3.3% (-1) |
JavaScript (HumanEvalPack, 30 tasks) | 17 / 30 (56.7%) | 13 / 30 (43.3%) | -13.4% (-4) |
(Also recorded in prior v15 single-language evaluation: OpenAI HumanEval 29/30 (96.7%) and OpenAI GSM8K 18/30 (60.0%). Direct shard surgery report and before/after spectral & router diagnostics are saved in weight_space_diagnostics.json.)
Quickstart (transformers)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo_id = "karthik-a/razor-spark-30b"
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-3B-Instruct")
model = AutoModelForCausalLM.from_pretrained(
repo_id,
trust_remote_code=True,
device_map="auto",
torch_dtype="auto",
)
model.set_attached(True)
messages = [
{"role": "system", "content": "You are Razor-Spark 30B, an expert AI software engineer and reasoning assistant."},
{"role": "user", "content": "Write a Python function `two_sum(nums, target)` with O(n) time complexity."},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=256, do_sample=False)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))