model-rampage/BareTorch-Qwen3.5-0.8B-HybridBuilding Hardware-Portable, Pure-GEMM Sub-Quadratic LLM Architectures for the Edge & Cloud
model-rampage/BareTorch-Qwen3.5-0.8B-Hybrid is an ultra-lightweight edge CS-LRAD (Chunked Selective Low-Rank Associative Delta) hybrid language model surgically distilled from Qwen/Qwen3.5-0.8B and up-distilled from Qwen/Qwen3.5-4B using the multi-stage BareTorch Layerwise Up-Distillation Engine.
While existing sub-quadratic architectures (such as Mamba-2, RWKV, and Gated DeltaNet) rely on hardware-locked C++/CUDA/Triton extensions (causal-conv1d, flash-linear-attention) that fail to port cleanly to systolic arrays and edge devices, BareTorch formulates sub-quadratic sequence mixing using 100% standard matrix multiplications (GEMMs) and an exact $O(1)$ low-rank recurrent associative state update for decoding.
By replacing 75% of the backbone's token mixers (18 of 24 layers) with pure-PyTorch torch.compile-compatible low-rank (r=16, chunk_size=64) associative recurrent blocks while preserving 6 interleaved Full-Attention anchor layers, model-rampage/BareTorch-Qwen3.5-0.8B-Hybrid delivers:
Qwen/Qwen3.5-0.8B on the 10-task lm-evaluation-harness suite (58.45% vs. 54.83% macro average, including +12.58% on ARC-Easy, +9.80% on SciQ, and +8.32% on BoolQ).Qwen/Qwen3.5-0.8B on the 5-task <think> Generative Reasoning & Python Coding suite (20.01% vs. 11.47% macro average, including 35.80% GSM8K CoT, 27.68% GPQA-Diamond, 16.80% MBPP Pass@1, and 10.98% HumanEval Pass@1).662.0M vs. 752.4M), and 1.21 GB lower 32K Peak VRAM than native Qwen3.5-0.8B on an NVIDIA RTX 4090—with zero custom CUDA/Triton C++ dependencies (causal-conv1d / fla not required).| Property | Value |
|---|---|
| Architecture Type | 3:1 Interleaved Hybrid (18 CS-LRAD Recurrent + 6 Full-Attention) |
| Active Parameters | 662.0M (bf16, Static Weights VRAM: ~1.29 GB vs. 752.4M / 1.43 GB Teacher) |
Hidden Dimension (d_model) |
1024 (8 Query Heads, 2 KV Heads) |
CS-LRAD Low-Rank State (r) |
rank = 16, chunk_size = 64 |
| Context Window | 32,768 tokens (512 chunks) |
| Base Architecture Teacher | Qwen/Qwen3.5-0.8B |
| Stage 4B/4C Skew-KD Teacher | Qwen/Qwen3.5-4B (Top-64 Skew-KL + Skew-RKL + 2,000-Step 4-Pillar <think> Dr. GRPO) |
| Distillation Pipeline Repo | github.com/martin-kbcc/BareTorch_Layerwise_Distill |
transformers + torch.compile)No external custom C++/CUDA packages are required—only torch and transformers. Simply pass trust_remote_code=True, and call model.compile_cs_lrad() to enable TorchInductor kernel fusion across all CS-LRAD blocks (accelerating both prefill and decoding with dynamic=True so variable prompt lengths never trigger recompilation stalls):
model.compile_cs_lrad() Hardware Acceleration)import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "model-rampage/BareTorch-Qwen3.5-0.8B-Hybrid"
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
dtype=torch.bfloat16,
device_map=device,
trust_remote_code=True,
).eval()
# Compile all CS-LRAD blocks (chunk_forward, RMSNorms, SwiGLU MLPs) with dynamic=True
# Note: First call takes ~10s to JIT-compile fused Triton kernels; subsequent calls run at peak speed!
if torch.cuda.is_available():
model.compile_cs_lrad(mode="default", dynamic=True)
# Example: Step-by-Step <think> Math / Scientific Reasoning
reasoning_prompt = (
"Question: A store sells notebooks for $4 each and pens for $1.50 each. "
"If Maria buys 6 notebooks and 8 pens, how much change does she get from a $50 bill?\n"
"Answer: <think>\n"
)
inputs = tokenizer(reasoning_prompt, return_tensors="pt").to(device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=256,
do_sample=False,
use_cache=True,
pad_token_id=tokenizer.eos_token_id,
)
print(tokenizer.decode(outputs[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
prompts = [
"Question: What is the primary function of mitochondria in eukaryotic cells?\nAnswer:",
"Question: Solve for x: 4x + 9 = 33.\nAnswer: <think>\n",
"You are an expert Python programmer, and here is your task: Write a function `is_palindrome(s)` that returns True if a string is a palindrome.\n",
]
tokenizer.padding_side = "left"
if tokenizer.pad_token_id is None:
tokenizer.pad_token_id = tokenizer.eos_token_id
batch_inputs = tokenizer(prompts, return_tensors="pt", padding=True).to(device)
prompt_padded_len = batch_inputs["input_ids"].shape[1]
with torch.no_grad():
batch_outputs = model.generate(
**batch_inputs,
max_new_tokens=192,
do_sample=False,
use_cache=True,
pad_token_id=tokenizer.pad_token_id,
)
for i, prompt in enumerate(prompts):
generated_text = tokenizer.decode(batch_outputs[i, prompt_padded_len:], skip_special_tokens=True)
print(f"=== Prompt {i+1} ===\n{generated_text}\n")
lm-evaluation-harness 10-Task Suite)| Benchmark | Metric | Base Teacher (Qwen/Qwen3.5-0.8B) |
BareTorch Hybrid (0.8B) |
Delta (S - T) | Retention |
|---|---|---|---|---|---|
| ARC-Challenge | acc_norm | 37.71% | 41.72% | +4.01% | 110.6% |
| ARC-Easy | acc_norm | 61.57% | 74.16% | +12.58% | 120.4% |
| BoolQ | acc | 62.48% | 70.80% | +8.32% | 113.3% |
| HellaSwag | acc_norm | 49.59% | 48.66% | -0.94% | 98.1% |
| LAMBADA (OpenAI) | acc | 43.64% | 38.58% | -5.07% | 88.4% |
| MMLU (57 Subjects) | acc | 48.11% | 43.95% | -4.17% | 91.3% |
| MMLU - Humanities | acc | 44.53% | 40.43% | -4.10% | 90.8% |
| MMLU - Other | acc | 52.01% | 47.22% | -4.80% | 90.8% |
| MMLU - Social Sciences | acc | 54.01% | 49.89% | -4.13% | 92.4% |
| MMLU - STEM | acc | 43.86% | 40.18% | -3.68% | 91.6% |
| OpenBookQA | acc_norm | 30.80% | 36.00% | +5.20% | 116.9% |
| PIQA | acc_norm | 68.99% | 72.58% | +3.59% | 105.2% |
| SciQ | acc_norm | 86.50% | 96.30% | +9.80% | 111.3% |
| WinoGrande | acc | 58.88% | 61.80% | +2.92% | 105.0% |
| 10-Task Macro Average | mean_acc | 54.83% | 58.45% | +3.63% | 106.6% |
<think> & Unit-Test Suite)| Generative Benchmark | Metric | Base Teacher (Qwen/Qwen3.5-0.8B) |
BareTorch Hybrid (0.8B) |
Delta (S - T) | Retention |
|---|---|---|---|---|---|
GSM8K (<think> CoT Math) |
exact_match | 39.00% | 35.80% | -3.20% | 91.8% |
MATH-500 (<think> Boxed) |
boxed_match | 2.60% | 8.80% | +6.20% | 338.5% |
| GPQA-Diamond (PhD STEM) | mc_think | 6.03% | 27.68% | +21.65% | 459.3% |
| MBPP (Python Synthesis) | pass@1 | 1.80% | 16.80% | +15.00% | 933.3% |
| HumanEval (Python Synthesis) | pass@1 | 7.93% | 10.98% | +3.05% | 138.5% |
| 5-Task Generative Average | macro_avg | 11.47% | 20.01% | +8.54% | 174.5% |
BareTorch-Qwen3.5-0.8B-Hybrid vs. Native Qwen3.5-0.8B on NVIDIA RTX 4090 — 512 to 32,768 Context)| Context Length | Model | TTFT (ms) | Prefill (tok/s) | Decode (tok/s) | KV-Cache (MB) | Peak VRAM (GB) | Speedup / Memory Savings |
|---|---|---|---|---|---|---|---|
| 512 | BareTorch-Qwen3.5-0.8B-Hybrid (r=16, Compiled) | 23.6 ms | 21,693 tok/s | 48.5 tok/s | 7.9 MB | 1.28 GB | 1.62x Prefill, 1.09x Decode, 3.2x Smaller Cache |
| 512 | Qwen3.5-0.8B (Native) | 38.2 ms | 13,419 tok/s | 44.4 tok/s | 25.6 MB | 1.49 GB | Baseline |
| 1,024 | BareTorch-Qwen3.5-0.8B-Hybrid (r=16, Compiled) | 23.6 ms | 43,474 tok/s | 51.2 tok/s | 13.9 MB | 1.30 GB | 1.64x Prefill, 1.13x Decode, 2.3x Smaller Cache |
| 1,024 | Qwen3.5-0.8B (Native) | 38.7 ms | 26,487 tok/s | 45.2 tok/s | 31.6 MB | 1.53 GB | Baseline |
| 2,048 | BareTorch-Qwen3.5-0.8B-Hybrid (r=16, Compiled) | 24.7 ms | 82,874 tok/s | 51.2 tok/s | 25.9 MB | 1.34 GB | 1.57x Prefill, 1.13x Decode, 1.7x Smaller Cache |
| 2,048 | Qwen3.5-0.8B (Native) | 38.9 ms | 52,651 tok/s | 45.2 tok/s | 43.6 MB | 1.61 GB | Baseline |
| 4,096 | BareTorch-Qwen3.5-0.8B-Hybrid (r=16, Compiled) | 45.5 ms | 89,973 tok/s | 51.4 tok/s | 49.9 MB | 1.43 GB | 1.37x Prefill, 1.13x Decode, 1.4x Smaller Cache |
| 4,096 | Qwen3.5-0.8B (Native) | 62.2 ms | 65,845 tok/s | 45.5 tok/s | 67.6 MB | 1.76 GB | Baseline |
| 8,192 | BareTorch-Qwen3.5-0.8B-Hybrid (r=16, Compiled) | 100.9 ms | 81,166 tok/s | 50.6 tok/s | 97.9 MB | 1.61 GB | 1.30x Prefill, 1.12x Decode, 1.2x Smaller Cache |
| 8,192 | Qwen3.5-0.8B (Native) | 131.0 ms | 62,531 tok/s | 45.4 tok/s | 115.6 MB | 2.07 GB | Baseline |
| 16,384 | BareTorch-Qwen3.5-0.8B-Hybrid (r=16, Compiled) | 235.5 ms | 69,584 tok/s | 50.6 tok/s | 193.9 MB | 1.97 GB | 1.30x Prefill, 1.11x Decode, 710 MB Less VRAM |
| 16,384 | Qwen3.5-0.8B (Native) | 306.2 ms | 53,515 tok/s | 45.6 tok/s | 211.6 MB | 2.68 GB | Baseline |
| 32,768 | BareTorch-Qwen3.5-0.8B-Hybrid (r=16, Compiled) | 586.4 ms | 55,878 tok/s | 51.4 tok/s | 385.9 MB | 2.70 GB | 1.24x Prefill, 1.16x Decode, 1.21 GB Less VRAM |
| 32,768 | Qwen3.5-0.8B (Native) | 729.7 ms | 44,906 tok/s | 44.2 tok/s | 403.6 MB | 3.91 GB | Baseline |
@article{kovacevic2026baretorch,
title={BareTorch: Challenging State-of-The-Art Sequence Mixing Topologies via Kernel-Free, Pure GEMM-Compliant Architectures},
author={Kovacevic Buvinic, Martin Ignacio},
journal={BareTorch Framework Laboratory Technical Report},
year={2026},
url={https://github.com/martin-kbcc/baretorch}
}
Qwen/Qwen3.5-0.8B