Independent experiment · 2025–2026In development

Piano,with apulse.

I’m building piano music that reacts to my game. From GPT-2 on a borrowed Mac to RWKV-7 with intensity controls.

Hear where it started
+ Notes, not sound.
MIDI → model → piano
Made for PhantomHuntScroll to explore By Hermes
01 / THE IDEAA game, then a detour

What if the music
could play along?

A quiet room. A chase. A moment to breathe. I wanted the piano in PhantomHunt to follow what was happening.

The idea came from a friend’s project at MIT. At first, the hardware it seemed to need was completely out of scope. So I started with a smaller question: could I train a model to continue a piano passage?

That became one project, in two chapters.

02 / THE FIRST NOTESv1 · GPT-2

A borrowed Mac.
A beginning.

I borrowed a friend’s M1 Max and trained a 12-layer GPT-2 from scratch. No English model underneath. Just piano performances, turned into musical events.

THE FIRST MODEL ↗
200h

Almost 200 hours of MAESTRO competition piano.

Architecture
12-layer GPT-2
Context
2,048 tokens
Tokenizer
MidiTok REMI
Training
PyTorch / MPS
CHECKPOINT COMPARISON LOWER IS BETTER

The earlier checkpoint
stayed ahead.

Epoch 021.43
KEPT
Epoch 041.53

Validation loss went up after epoch 2, so I kept the earlier checkpoint. Loss is only part of the story. I also generated continuations to hear the difference.

“12k” in the repository name is a leftover working name, not a count of training pieces.
LISTEN / V1

A little wobbly.
Still fascinating.

A continuation from the best GPT-2 checkpoint. I chose it from a wider search and shortened the long pauses.

01 / GPT-2 CONTINUATIONMAESTRO → REMI → MIDI
0:00—

Played on Salamander Grand Piano by Alexander Holm, CC BY 3.0. The MIDI download retains the original pauses.

03 / THE REAL-TIME QUESTIONMeasured October 2026

The next note
has a deadline.

A continuation is not live game music. It has to arrive on time, leave room for the game, and respond when the mood changes. v1 couldn’t do that.

V1 / TOKENS PER SECOND MORE IS FASTER
GPT-2 · PyTorch CPU
35
What the music needs · average
40
What the music needs · 99th percentile
110

87M GPT shape, 2,048-token context, on an M1 Pro. The REMI budget came from 200 MAESTRO files. The PyTorch CPU path fell short even on average.

V2 / ONE TOKEN ON THE NEURAL ENGINE
3.5ms

A 94M RWKV-7 step, with int8 weights.
4.2 ms at the 99th percentile.

12 ms budget

Aria’s roughly three tokens per note allow about 12 ms per token in the 99th-percentile second.

A memory that stays the same size.

RWKV-7 carries a fixed-size state from one token to the next. A GPT carries an attention cache. Moving that cache was costly; keeping it inside the model did not compile for the Neural Engine in my tests.

Speed tests used random weights, batch one, on an M1 Pro. These are model timings, not an in-game benchmark or a judgement of the music. RWKV-7 was measured on 7 October; the REMI budget and GPT CPU result on 4 October.

04 / BACK TO THE GAMEv2 · RWKV-7

Same idea.
Different engine.

I came back to the original goal with a recurrent model, much more music, and controls from the start. It trains on two AMD GPUs in my desktop.

THE MODEL94M

RWKV-7 parameters

THE DATA4.6B

Pruned Aria-MIDI tokens

THE PACE29.7k

Training tokens / second

01 / VOCABULARY

Piano, pared back.

Aria’s tokenizer, trimmed to piano. 2,176 tokens, including 13 control tokens for density and loudness. A much larger dataset than MAESTRO’s few million tokens.

02 / CONDITIONING

Music with instructions.

Every five seconds, controls describe the coming music: eight density levels and five loudness levels. Dropping controls 15% of the time enables classifier-free guidance.

03 / HARDWARE

Trained at home.

A Radeon RX 9060 XT and a Radeon VII. ROCm, one process per card. About 43 hours for one epoch at the measured training speed.

01Game state
02Controls
03RWKV-7
041–2 s buffer
05Piano

The planned in-game loop. Controls take effect at the next five-second segment. A rule layer can change velocity or thin notes immediately.

V1 SIDE EXPERIMENT

Less rush.
More room.

The game idea left an intensity editor behind: a softer, sparser phrase or a louder, denser one.

The actual experiment works on short phrases. This preview illustrates the idea; it does not run either model.

0.45
SOFT / SPARSELOUD / DENSE
PHRASE SKETCHBALANCED
Preview notesVelocity target
05 / WHAT THE TESTS SAYSmall runs. Useful signals.

Measure first.
Listen next.

These tests helped choose the architecture and training recipe. They do not tell me whether the full model makes music I want to hear.

A / ARCHITECTURE

RWKV-7 came out ahead.

RWKV-72.172
GPT2.258

Validation loss at about 28M parameters each, after 250M tokens on the same data. The GPT used rotary positions.

B / CONTROL

Soft and loud separate.

Soft32
Loud99

MIDI velocity in fresh-state tests. Density landed in the requested level 69–97% of the time.

C / LONG STREAMS

Guidance keeps it on track.

Dense, guided11/s
Medium, guided2/s

Notes per second at minute 15, with guidance strength 1. Without guidance, “dense” faded from 9 to about 5 notes/s after 10–30 minutes.

What guidance did, and what still needs testing

The small runs compared requested and contrasting controls, running each token step twice. The full recipe adds control dropout for classifier-free guidance. That compares controlled and unconditioned predictions; its strength still needs tuning.

Two passes at 94M would cost about 7 ms per token on the Neural Engine. That is an estimate. It has not been measured as part of the game.

06 / STILL WRITING THE NEXT BARUpdate: 8 October 2026
FIRST EPOCH RUNNING

Not finished.
Getting closer.

The first full epoch is running, expected to finish around 9 October. The next step is to hear what it learned.

v2 samples coming after the first epoch.

  1. 01 / NOW

    Train the first epoch

    One pass through the pruned Aria-MIDI dataset.

  2. 02 / NEXT

    Listen and calibrate

    Judge the music and tune the control strength.

  3. 03 / THEN

    Export the trained model

    Core ML for Macs. ONNX for the portable runtime.

  4. 04 / THE POINT OF IT ALL

    Play it in PhantomHunt

    Find out whether it follows the game.

THE SMALL PRINT, WORTH READING

Notes from the workbench.

01 What this still can’t do

v1 / Continuation, with caveats

Quality depends on the prompt and checkpoint. MAESTRO is small and stylistically narrow. My random file split can put related pieces on both sides, flattering validation loss. The demo is a selected sample. The intensity editor is experimental and not a note-preserving live editor.

v2 / A player needs a conductor

Continuous notes do not make long-form structure. The game needs a conductor to bring themes back and set controls. Listening tests and the full game loop are still ahead. Both versions take musical context, not text prompts.

02 Inside the original GPT-2 workflow

Split MIDI files → transpose only the training split → tokenize with MidiTok REMI → train on 2,048-token windows → compare checkpoints → generate MIDI.

Layers
12
Attention heads
12
Embedding size
768
Vocabulary
423

The public repository contains the v1 workflow. Datasets and checkpoints stay local. The v2 code is not public.

03 Run v1 locally

Training and generation need your own local data and checkpoint. Start with the dependency smoke check:

python3 -m pip install -r requirements-smoke.txt
python3 -m unittest tests.test_dependency_smoke

Then prepare, train, and generate:

python3 scripts/prepare_12k_split.py
python3 scripts/augment_train_transpose.py
python3 scripts/tokenize_12k_augmented.py
python3 scripts/train_gpt2_piano_12k.py --train-from-scratch
python3 scripts/generate_piano_sample.py --checkpoint checkpoints/best
Read the full README ↗
04 Data, sound, and licenses

Aria-MIDI is CC BY-NC-SA, so this v2 work is for non-commercial use. MAESTRO has separate CC BY-NC-SA terms too. The repository’s MIT license covers its code, not its training data.

The v1 clip uses Salamander Grand Piano by Alexander Holm under CC BY 3.0. Long pauses in the selected continuation were shortened. Future v2 samples will also use a freely licensed piano.