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 the Qwen2.5-Coder-3B-Instruct controller (~60 MB, automatically merged on load)
  • razor_spark_bridge.safetensors: Jointly aligned AttachableBridge projections (mem_norm, mem_up, mem_down, mem_alpha) + Switch router weights (8 layers)
  • razor_spark_moe_lora.safetensors: Jointly adapted LoRA weights (r=16, alpha=32) for both shared and routed 30B experts (8 layers)
  • eval_scorecard.json: Recorded Detached vs Attached HumanEval, MBPP, and GSM8K evaluation scorecard

Verified Benchmark Scorecard (v15: 350 SFT + 48x4 Execution-Verified GRPO)

Benchmark Detached (3B Controller Alone) Attached (3B+CtrlLoRA + 8x 30B MoE) Gain
Held-out Coding Cross-Entropy (20 tasks) 0.3477 (PPL 1.4158) 0.2739 (PPL 1.3150) -21.2% CE
OpenAI HumanEval (30 tasks, pass@1) 22 / 30 (73.3%) 29 / 30 (96.7%) +23.4%
Google MBPP Test (50 tasks, pass@1) 26 / 50 (52.0%) 31 / 50 (62.0%) +10.0%
OpenAI GSM8K Test (30 problems) 7 / 30 (23.3%) 18 / 30 (60.0%) +36.7%

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))
Downloads last month
84
Safetensors
Model size
9B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support