Commit Graph
2 Commits
Author SHA1 Message Date
osobhandClaude Opus 4.7 0699cdeb45 rtx-csm: Phase 8.5 — Moonshine conv stem (verified end-to-end)
First working piece of the Moonshine v2 candle port. New
src/moonshine.rs module with:

  - MoonshineConfig::tiny()  — hyperparameters from HF config.json
  - ConvStem (Conv1d × 3)    — audio stem, raw 16 kHz → 288-d hidden
  - load_conv_stem()         — VarBuilder from HF safetensors

Conv layout (verified against HF source):
  conv1: in=1,   out=288, k=127, stride=64, no bias
  conv2: in=288, out=576, k=7,   stride=3,  bias
  conv3: in=576, out=288, k=3,   stride=2,  bias
  Activations: tanh after conv1, gelu_erf after conv2 / conv3

Smoke test (`examples/moonshine_smoke`):
  - Downloads UsefulSensors/moonshine-tiny from HF
  - Synthetic 10 s @ 16 kHz audio (silence + sine pulse)
  - input (1, 1, 160000) -> output (1, 415, 288)
  - Expected T_seq=415 ((160000-127)/64+1 -> 2498 -> 831 -> 415)
  - Output max abs = 23.17 (real signal, weights loaded correctly)

Also extends `examples/moonshine_inspect` to dump conv shapes
explicitly (was being truncated by the per-prefix `take(8)` cap).

Next ship: encoder transformer block (partial RoPE, GELU MLP) and
output layer norm. Tracked in Phase 8 plan; ~2-3 hours of work.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2026-04-27 10:27:51 -07:00
osobhandClaude Opus 4.7 c848abef22 rtx-csm: Phase 8.4 spike — Moonshine v2 inspector + port notes
First step on the Tier 2.2 (Moonshine v2 candle port) item from the
Phase 8 plan. Full port is honestly multi-session work (~12-15 hours
of focused implementation across encoder, decoder, generation loop,
tokenizer, weight mapping, smoke test). This commit ships the
foundation so future sessions start from concrete data instead of
arxiv reading.

Two ships:

1. examples/moonshine_inspect — downloads UsefulSensors/moonshine-tiny
   from HF, parses safetensors header, dumps all 160 tensors grouped
   by prefix with shapes + dtypes. Verified output: 27.1 M params,
   108.4 MB safetensors (F32), encoder + decoder layers laid out as
   expected.

2. docs/moonshine_port_notes.md — captures every architectural fact
   established by the inspector + HF config.json:
   - Hyperparameter table (hidden=288, 6+6 layers, vocab=32768,
     partial_rotary=0.9, etc.)
   - Tensor layout per layer (encoder, decoder)
   - Architecture summary (raw waveform input, 3-layer Conv1d stem,
     SwiGLU decoder MLP via fused fc1, tied LM head)
   - Ordered porting tasks with hour estimates totaling ~12-15 h
   - Risks / unknowns (conv strides not in config, tied output head
     question, quality-vs-Kyutai concern)
   - Recommended order of attack for the next session

The full port itself is deferred. Ship the foundation now so the
remaining work has a clean handoff.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2026-04-27 10:21:30 -07:00