This is an autonomous research harness for the Alloy Hybrid SSM-Attention model, adapted from autoresearch-mlx.
The goal: let an AI agent autonomously explore the hybrid architecture design space (Mamba-2 + Attention interleaving) to find the optimal configuration on Apple Silicon.
- Agree on a run tag: propose a tag based on today's date (e.g.
mar25). The branchautoresearch/<tag>must not already exist. - Create the branch:
git checkout -b autoresearch/<tag>from current main. - Read the in-scope files:
program.md— this file (experiment protocol).prepare.py— fixed: data prep, tokenizer, dataloader, evaluation. Do not modify.train.py— the file you modify. Hybrid model, optimizer, training loop.
- Verify data exists: Check
~/.cache/autoresearch/for data shards and tokenizer. If not, tell the human to runuv run prepare.py. - Initialize results.tsv: Create
results.tsvwith header row. Runuv run train.pyonce to establish YOUR baseline on this hardware. - Confirm and go.
Each experiment runs on Apple Silicon via MLX with a fixed 5-minute training budget.
Launch: uv run train.py
What you CAN modify (all in train.py):
- Model architecture: depth, d_model, Mamba/Attention ratio, attn_layer_indices
- Mamba parameters: d_state, d_conv, expand, headdim, chunk_size
- Attention parameters: n_heads, n_kv_heads, window_size, full_attn_layers
- FFN: ffn_mult, activation function
- Optimizer: per-parameter LR groups, weight decay, betas, schedule
- Batch size, gradient accumulation
- Any architectural innovation (new block types, gating, normalization, etc.)
What you CANNOT modify:
prepare.py— read-only (evaluation, data loading, tokenizer, constants).- Dependencies in
pyproject.toml. - The evaluation harness (
evaluate_bpb).
The goal: lowest val_bpb.
This is what makes this experiment unique vs vanilla autoresearch. Explore:
- Mamba:Attention ratio — Current default is 3:1. Try 1:1, 7:1, all-Mamba, all-Attention.
- Attention layer placement — Which layers get attention? First/last? Evenly spaced? Clustered?
- SSM hyperparameters — d_state (16/32/64/128), expand factor (1/2/4), headdim.
- Sliding window — Full attention on some layers, sliding window on others.
- Per-parameter LR — Mamba params vs Attention params may need different learning rates.
- Architecture innovations — Value embedding gates, residual lambdas, alternative FFN activations.
Key insight from autoresearch: With a fixed 5-minute budget, smaller models that train faster often beat larger models. The hybrid architecture's advantage is that Mamba layers are cheaper than Attention — exploit this.
All else being equal, simpler is better. A 0.001 val_bpb improvement from 20 lines of hacky code? Probably not worth it. A 0.001 improvement from deleting code? Definitely keep.
The script prints a summary after training:
---
val_bpb: 2.534000
training_seconds: 312.4
total_seconds: 405.7
peak_vram_mb: 27528.9
total_tokens_M: 39.8
num_steps: 46
num_params_M: 50.3
depth: 8
architecture: hybrid (mamba:6 attn:2)
Extract results: grep "^val_bpb:\|^peak_vram_mb:" run.log
Log to results.tsv (tab-separated):
commit val_bpb memory_gb status description
Example:
commit val_bpb memory_gb status description
abc1234 2.667000 26.9 keep baseline hybrid 8L (6M+2A)
def5678 2.534000 26.9 keep reduce depth to 4L (3M+1A)
ghi9012 2.700000 26.9 discard all-mamba 8L (worse than hybrid)
LOOP FOREVER:
- Check git state
- Edit
train.pywith an experimental idea git add train.py && git commit -m "experiment: <description>"- Run:
uv run train.py > run.log 2>&1 - Read results:
grep "^val_bpb:\|^peak_vram_mb:" run.log - If grep empty → crash.
tail -n 50 run.logto debug. - Record in
results.tsv - If val_bpb improved:
git add results.tsv && git commit --amend --no-edit - If equal or worse: record discard hash, then
git reset --hard <previous kept commit>
NEVER STOP: Once the loop begins, do NOT pause to ask the human. You are autonomous. If you run out of ideas, think harder — try combining previous near-misses, try radical architectural changes, read the Mamba-2 paper for ideas. The loop runs until manually interrupted.
Timeout: ~7 minutes per experiment (5 min train + ~2 min compile/eval on Apple Silicon). Kill runs exceeding 15 minutes.