Samothrace-4B-Preview

Samothrace-4B-Preview is Qwen3.5-4B with its middle layers looped. Layers 8–19 (three blocks of 3Γ— Gated DeltaNet + 1Γ— full attention) run twice (K=2); layers 0–7 and 20–31 run once. The second pass uses its own LoRA (r=16) and a learned per-channel gate:

h ← h + a βŠ™ (Core(h; W + Ξ”Wβ‚‚) βˆ’ h)        a ∈ R^2560, initialised to 0

With a = 0 the model is bit-identical to Qwen3.5-4B, so the loop starts from the pretrained model and only learns how much of the second pass to mix in. The repo holds only the trainable part (11.4M parameters, fp32): the base weights are pulled from Qwen/Qwen3.5-4B.

Results

Benchmarks

K=1 (= base Qwen3.5-4B) K=2 (Samothrace-4B-Preview) K=3
MATH-500 (n=144) 23.6% 42.4% 39.6%
HumanEval (n=164, pass@1) 85.4% 87.2% 86.0%
Mean generated tokens, MATH-500 2,347 1,980 2,011
Mean generated tokens, HumanEval 1,166 518 553

Setup: greedy decoding, thinking mode, 2,048-token thinking budget with budget forcing (then up to 384 answer tokens), the same problems for every K. MATH-500 is a random 144-problem subset (the run hit its compute budget); HumanEval is complete. K=3 was trained jointly (same run, separate LoRA) and did not beat K=2, so K=2 is the released setting.

Read with care: K=1 is the untouched base model, so the K=1β†’K=2 gain mixes the effect of SFT (much shorter, less truncated thinking) with the effect of the loop. A same-budget non-looped LoRA control has not been run yet. The 2,048-token thinking cap truncates most MATH-500 solutions for every K, so absolute numbers sit well below Qwen3.5-4B's full-budget scores.

Training

  • SFT, 10.0M tokens (3,418 samples, ≀ 6,144 tokens): math 3.0M (DAPO-Math Qwen3-235B-Thinking rejection distill), code 3.5M (Qwen3.5-27B DeepCoder SFT, hardtests Qwen3.5-27B), agent 3.5M (Nemotron-SFT-Agentic-v2, multi-step tool calling and interactive agent).
  • K sampled per sample (K=2 35%, K=3 65%); shortcut-consistency KL(p_K3 β€– p_K2) on 20% of K=3 samples.
  • AdamW, LoRA lr 2e-4, gate lr 3e-3, cosine schedule, fp16 with loss scaling. 7.5 h on Kaggle 2Γ— T4 (DDP), query-chunked attention and per-layer activation checkpointing; 0 OOM skips. Final mean |a| = 0.092.

Held-out SFT-distribution loss (samples not used in training), K=1 / K=2 / K=3: math 0.297 / 0.248 / 0.246, code (DeepCoder) 0.390 / 0.299 / 0.292, code (hardtests) 0.883 / 0.676 / 0.657, agent tool-calling 0.704 / 0.581 / 0.574, interactive agent 0.671 / 0.469 / 0.460.

Usage

Requires transformers with Qwen3.5 support. flash-linear-attention is recommended on GPU.

from huggingface_hub import snapshot_download
import sys
path = snapshot_download("CloudGoat/Samothrace-4B-Preview")
sys.path.insert(0, path)
from samothrace_inference import load_samothrace, generate

model, tok = load_samothrace(path)              # downloads Qwen/Qwen3.5-4B, applies the K=2 loop
print(generate(model, tok, "Find all real x with x^2 - 5x + 6 = 0.", max_new_tokens=4096))

Files: modeling_samothrace.py (looped model, per-step LoRA, loop-aware KV / DeltaNet cache), samothrace_inference.py (loader + simple decoding), samothrace_k2_adapter.safetensors, samothrace_config.json.

Decoding costs about 1.4Γ— a plain Qwen3.5-4B forward per token (44 of 32 layers' worth of compute), and the loop adds its own KV / recurrent-state slots for the second pass.

Limitations

  • Research release; no safety tuning beyond the base model.
  • Evaluated on small subsets with a short thinking budget; no AIME / LiveCodeBench / BFCL numbers yet.
  • RL (GRPO) stage not yet applied.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for CloudGoat/Samothrace-4B-Preview

Finetuned
Qwen/Qwen3.5-4B
Adapter
(1,248)
this model

Datasets used to train CloudGoat/Samothrace-4B-Preview