Add FlowDiT weights (step 140k) and model card
Browse files
README.md
CHANGED
|
@@ -1,3 +1,120 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: cc-by-nc-4.0
|
| 3 |
+
tags:
|
| 4 |
+
- audio
|
| 5 |
+
- music
|
| 6 |
+
- music-generation
|
| 7 |
+
- flow-matching
|
| 8 |
+
- diffusion-transformer
|
| 9 |
+
- realtime
|
| 10 |
+
- codicodec
|
| 11 |
---
|
| 12 |
+
|
| 13 |
+
# CoDiCodec-Flow
|
| 14 |
+
|
| 15 |
+
Realtime music generation with a flow-matching diffusion transformer on
|
| 16 |
+
[CoDiCodec](https://github.com/sony/codicodec) latents. It continues an audio prompt
|
| 17 |
+
(or starts from silence) chunk by chunk, 0.68 s at a time, fast enough to stream live
|
| 18 |
+
on a laptop, with keyboard controls for steps, temperature, seeds and latent
|
| 19 |
+
modulation, and swappable LoRA style adapters.
|
| 20 |
+
|
| 21 |
+
Author: Moisés Horta Valenzuela ([hexorcismos](http://hexorcismos.bandcamp.com)) ·
|
| 22 |
+
Code: [github.com/moiseshorta/CoDiCodec-Flow](https://github.com/moiseshorta/CoDiCodec-Flow)
|
| 23 |
+
|
| 24 |
+
## Files
|
| 25 |
+
|
| 26 |
+
| File | Size | Contents | Use |
|
| 27 |
+
|---|---|---|---|
|
| 28 |
+
| `ema.pt` | 388 MB | EMA weights, step 140 000 | generation: `sample`, `realtime`, `server`; base for LoRA training |
|
| 29 |
+
| `last.pt` | 1.5 GB | raw weights + optimizer + EMA, step 140 000 | resuming or full fine-tuning (`train --init-from`) |
|
| 30 |
+
|
| 31 |
+
The CoDiCodec checkpoint is not included; it downloads automatically on first use.
|
| 32 |
+
|
| 33 |
+
## Quick start
|
| 34 |
+
|
| 35 |
+
```bash
|
| 36 |
+
git clone https://github.com/moiseshorta/CoDiCodec-Flow && cd CoDiCodec-Flow
|
| 37 |
+
pip install -r requirements.txt && pip install -e ./codicodec
|
| 38 |
+
hf download hexorcismos/CoDiCodec-Flow ema.pt --local-dir weights
|
| 39 |
+
|
| 40 |
+
# continue a prompt, chunk by chunk (the condition the model was trained on)
|
| 41 |
+
python cli.py sample --ckpt weights/ema.pt --prompt-wav prompt.wav \
|
| 42 |
+
--duration-s 30 --mode chunked --nfe 8 --solver heun --out out.wav
|
| 43 |
+
|
| 44 |
+
# unconditional
|
| 45 |
+
python cli.py sample --ckpt weights/ema.pt --duration-s 30 --mode chunked --out uncond.wav
|
| 46 |
+
|
| 47 |
+
# live, with keyboard controls (press ? for help, q to quit)
|
| 48 |
+
python cli.py realtime --ckpt weights/ema.pt --nfe 8 --solver heun
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
Runs on NVIDIA GPUs (CUDA) and Apple Silicon (MPS). On an M4 Max, a 0.68 s chunk
|
| 52 |
+
takes ~270 ms at the default realtime settings (Euler, 4 steps). Live playback needs
|
| 53 |
+
macOS or Linux.
|
| 54 |
+
|
| 55 |
+
## LoRA adapters
|
| 56 |
+
|
| 57 |
+
Teach the model a new style from your own audio without retraining it: the base stays
|
| 58 |
+
frozen and small adapters train on top (1.7M parameters at rank 16, about 35 min on an
|
| 59 |
+
M4 Max for 45 min of audio). Load any number of adapters into `realtime` and switch
|
| 60 |
+
or blend them live (`l` next adapter, `k`/`K` strength):
|
| 61 |
+
|
| 62 |
+
```bash
|
| 63 |
+
python cli.py preprocess --in-dir ./my_audio --out-dir ./data/mine --offsets 2
|
| 64 |
+
python cli.py train --lora-base weights/ema.pt --data-dir ./data/mine --out-dir ./runs/mine \
|
| 65 |
+
--objective teacher_forcing --crop-tokens 256 --batch-size 8 --grad-accum 1 \
|
| 66 |
+
--lr 3e-4 --warmup-steps 100 --max-steps 4000 --val-every 250 --ckpt-every 250
|
| 67 |
+
python cli.py realtime --ckpt weights/ema.pt --lora runs/mine/mine.pt
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
See the "LoRA adapters" section of the GitHub README for details.
|
| 71 |
+
|
| 72 |
+
## Model
|
| 73 |
+
|
| 74 |
+
FlowDiT, 96.9M parameters: dim 768, 10 layers, 12 heads × 64, block-causal attention
|
| 75 |
+
over 8-token chunks, max 1024 tokens (~87 s window). It predicts flow-matching
|
| 76 |
+
velocities on CoDiCodec's continuous latents (~11.7 Hz, 64 channels, 48 kHz stereo);
|
| 77 |
+
latent normalization stats are stored in the checkpoint.
|
| 78 |
+
|
| 79 |
+
## Training
|
| 80 |
+
|
| 81 |
+
Objective: teacher forcing. Every chunk is denoised from its clean preceding chunks,
|
| 82 |
+
which is exactly how realtime generation runs. Uniform noise levels, AdamW
|
| 83 |
+
(0.9, 0.95), weight decay 0.01, grad clip 1.0, EMA 0.9999, bf16, 512-token crops
|
| 84 |
+
(~44 s), dropout 0.1, cosine LR.
|
| 85 |
+
|
| 86 |
+
| Phase | Steps | Data | Batch | Peak LR |
|
| 87 |
+
|---|---|---|---|---|
|
| 88 |
+
| 1a | 0 – 14k | FSL10K loops, 80.7 h (offset-augmented ×2) | 16 | 3e-4 |
|
| 89 |
+
| 1b | 14k – 17k | same | 128 | 5e-4 |
|
| 90 |
+
| 2 | 17k – 140k | FSL10K + 2000 Suno-generated songs: 198.9 h train / 9.5 h val | 32 | 2.5e-4 |
|
| 91 |
+
|
| 92 |
+
About 48 h of phase 2 on one NVIDIA GB10.
|
| 93 |
+
|
| 94 |
+
Next-chunk validation loss (held-out recordings): 1.049 (26k) → 1.029 (46k) →
|
| 95 |
+
1.024 (66k) → 1.025 (140k). It is flat after ~70k steps: more data, not more steps,
|
| 96 |
+
is what would improve it.
|
| 97 |
+
|
| 98 |
+
## What to expect
|
| 99 |
+
|
| 100 |
+
- **Strength:** timbre and texture. Output sounds codec-clean, with the right instrument colour.
|
| 101 |
+
- **Weakness:** long-range structure. On new prompts, continuations match the timbre but develop
|
| 102 |
+
rhythm and harmony vaguely and can drift.
|
| 103 |
+
- **Style bias:** about 60 % of phase-2 hours are Suno songs, so unconditioned output is
|
| 104 |
+
more often song-like (vocals, pop production) than loop-like.
|
| 105 |
+
- **Loop prompts:** loops continue convincingly for a few bars, with limited novelty over time.
|
| 106 |
+
- **Sampling:** use chunked generation (`--mode chunked` or `realtime`) with Heun at
|
| 107 |
+
8–16 steps; the model was trained only on that condition.
|
| 108 |
+
|
| 109 |
+
## License and data
|
| 110 |
+
|
| 111 |
+
CC BY-NC 4.0: non-commercial use only. The CoDiCodec codec (Sony CSL Paris) is also
|
| 112 |
+
CC BY-NC 4.0. Training data: FSL10K (Freesound loops, individually Creative Commons
|
| 113 |
+
licensed) and 2000 songs generated with Suno.
|
| 114 |
+
|
| 115 |
+
## Credits
|
| 116 |
+
|
| 117 |
+
- CoDiCodec-Flow: Moisés Horta Valenzuela, 2026
|
| 118 |
+
- CoDiCodec: Pasini et al., 2025, [CoDiCodec: Unifying Continuous and Discrete Compressed
|
| 119 |
+
Representations of Audio](https://arxiv.org/abs/2509.09836),
|
| 120 |
+
[github.com/sony/codicodec](https://github.com/sony/codicodec)
|
ema.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:96272a6e03a36bedc870d9c485eabf94af74c474d5e5341e998553b298f36cca
|
| 3 |
+
size 388061997
|
last.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:efa912ca41358889c18424b0fed316f24bf01b77420cadd0ee61f9e44bfd48dd
|
| 3 |
+
size 1550710387
|