First melody symphony created, finally by 2 years of search (647Gb RAM)

#27
by krustik - opened

This is model number 92 test (from year 2020 GPT2 i will put my tests at testai.neocities.org later after digging out all archives).
05:23:27-243774 INFO Loaded "USB-drive/kimi26-unsloth/UD-Q8_K_XL/Kimi-K2.6-UD-Q8_K_XL-00001-of-00014.gguf" in 7563.39 seconds. (thats speed of USB3.0, my SSDs busy at the moment)
05:23:27-249448 INFO LOADER: "llama.cpp"
05:23:27-251598 INFO CONTEXT LENGTH: 65536
RAM - 647Gb at model start, almost 685Gb at the end of all work
Quantization by Unsloth, Q8 is quality equal original model.

Finally, this model was able to create a long and harmonic sound melody in ChucK musical code, which is equal to musical notes (in fact much harder).
So, Kimi K2.6 created this melodies. Successful attempt are possible only in "high" reasoning thinking mode (i've tested non-thinking and its much worse, more errors, more time to repairs).
As preparation in high thinking without errors it created first an exact tunes code from Mozart's "“Ah vous dirai-je, Maman”", K. 265/300e — the melody everyone knows as Twinkle, Twinkle, Little Star. But it was too short - just 29 second (example #1).

Behold, the example # 1; 29 seconds of "Twinkle, Twinkle, Little Star" (Warning VERY HIGH BASS, lower the volume, maybe not recommended for headphones) no open free model by last 2 years was able to recreate exact copy of any classical tune in ChucK, certain only 4 models was able to make just working code with garbled sound, small models incapable to make this, i've tested:
Behold the result (ChucK player supplied from Stanford University in https://chuck.stanford.edu/ide/):

// ============================================================
//  Mozart – Theme from "Ah vous dirai-je, Maman" K.265
//  Two-voice piano arrangement for ChucK
// ============================================================

/* --- tempo & feel --- */
0.55 => float q;                 // quarter-note duration (~109 bpm, Allegretto)
q::second => dur Q;

/* --- sound chain --- */
Rhodey rh => NRev revR => Pan2 panR => dac;
Rhodey lh => NRev revL => Pan2 panL => dac;

0.30 => revR.mix;                // hall ambience
0.30 => revL.mix;
 0.35 => panR.pan;               // melody slightly right
-0.35 => panL.pan;               // bass slightly left
0.50 => dac.gain;                // headroom

/* --- RIGHT HAND: melody (phrases A B C C A B) --- */
[
// A – "Twinkle, twinkle, little star"
72, 72, 79, 79, 81, 81, 79,
// B – "How I wonder what you are"
77, 77, 76, 76, 74, 74, 72,
// C – "Up above the world so high"
79, 79, 77, 77, 76, 76, 74,
// C – "Like a diamond in the sky"
79, 79, 77, 77, 76, 76, 74,
// A
72, 72, 79, 79, 81, 81, 79,
// B
77, 77, 76, 76, 74, 74, 72
] @=> int melNotes[];

/* build melody durations: 6 quarters + 1 half per phrase */
melNotes.cap() => int mLen;
dur melDurs[mLen];
for(0 => int p; p < 6; p++) {
    for(0 => int n; n < 6; n++)  Q      => melDurs[p*7 + n];
                                   2.0*Q => melDurs[p*7 + 6];   // last note held
}

/* --- LEFT HAND: bass line (roots & fifths, half notes) --- */
[
// C major  | C major
36, 43, 36, 43,
// F major  | C major
41, 48, 36, 43,
// G major  | G major
43, 50, 43, 50,
// G major  | G major
43, 50, 43, 50,
// C major  | C major
36, 43, 36, 43,
// F major  | C major
41, 48, 36, 43
] @=> int bassNotes[];

/* bass durations: all half notes */
bassNotes.cap() => int bLen;
dur bassDurs[bLen];
for(0 => int i; i < bLen; i++) 2.0*Q => bassDurs[i];

/* --- player --- */
fun void playVoice(int notes[], dur durs[], Rhodey inst) {
    for(0 => int i; i < notes.cap(); i++) {
        Std.mtof(notes[i]) => inst.freq;
        // gentle velocity randomisation for human touch
        0.55 + Math.random2f(0.0, 0.25) => inst.noteOn;
        durs[i] => now;
        1.0 => inst.noteOff;
    }
}

/* --- perform --- */
spork ~ playVoice(melNotes, melDurs, rh);
spork ~ playVoice(bassNotes, bassDurs, lh);

/* hang until finished plus reverb tail */
0::second => dur total;
for(dur d : melDurs) d +=> total;
total + 3.0::second => now;

#My Hardware# Intel Xeon E5-2699v4 LGA2011-3 22 cores 44 threads (2016) $110 # Gigabyte C612 chipset 12 RAM slots VGA motherboard year 2016 $150 # Samsung-Hynix ECC RAM 12x64Gb=768Gb ~$900 # VGA monitor # IKEA chair # NO GPU # Run: Trillions Deepseeks, Kimis in Q5-Q6, 400-500billions in BF16, super high quality 1 token/sec testai.neocities.org
Tested in "Textgen" with user interface (aka oobabooga aka Text-generation-WebUI https://github.com/oobabooga/textgen/releases) Deterministic preset, high thinking, special system prompt.

Next was a new melody, longer one, it wasnt without errors, in first attempt it was unplayable, but after one repair and rechecking the code - the success!
This test is quite hard for models, they are not just need to remember the rules of musical ChucK language, but also remember the original melody notes as second part and in third attempting to combine both to be playable in ChucK - the thinking data is almost 10 pages long and on my ANCIENT Xeon PC with 768Gb RAM only CPU takes usually whole night, but at night the electricity is 50% discount, stable highest quality 1 token/second.
Example #2, a long almost 3 minutes melody, aka Rondo alla Turca (K. 331, III), but its very different, so here test is kinda 50% failed, no exact recreation, but something very melodic, it also was able to calculate code to be 3 minutes long which is not easy for models (you can see in comments to every code line how it tries to calculate time of song), the start is slightly monotonic.
Behold the result (ChucK player supplied from Stanford University in https://chuck.stanford.edu/ide/):

// ============================================================
//  Mozart – Rondo alla Turca (K. 331, III)
//  ChucK solo piano (~2 min 55 s)
//  Structure: A A A A A A A A | B B B B | A A A A |
//             Turkish episode | A A A A | B B B B |
//             A A | Turkish episode | Coda
//  Fixed voice-pool call and UGen.gain assignment
// ============================================================

Rhodey p[12];
NRev rev => dac;
for (0 => int i; i < 12; i++) {
    p[i] => rev;
    0.22 => p[i].gain;            // FIX: gain is a property, not a method
}
0.09 => rev.mix;

// ---- timing (quarter = 132 BPM) ----------------------------
60::second / 132.0 => dur Q;      // quarter note (the beat)
Q / 2.0                        => dur E;   // eighth note
Q * 2.0                        => dur H;   // half note

// ---- voice pool ---------------------------------------------
int v;
0 => v;

// fire a note on a SPECIFIC pooled voice
fun void voiceOnIdx(int idx, int note, dur len, float vel) {
    if (note <= 0 || idx < 0 || idx >= 12) return;
    Std.mtof(note) => p[idx].freq;
    vel => p[idx].noteOn;
    len => now;
    0 => p[idx].noteOff;
    100::ms => now;               // release tail
}

// chord / poly helper
fun void chord(int notes[], dur len, float vel) {
    int grabbed[notes.cap()];
    // grab voices atomically
    for (0 => int i; i < notes.cap(); i++) {
        if (notes[i] > 0) {
            v => grabbed[i];
            (v + 1) % 12 => v;
        } else {
            -1 => grabbed[i];
        }
    }
    // fire all notes in parallel
    for (0 => int i; i < notes.cap(); i++) {
        if (grabbed[i] >= 0) {
            spork ~ voiceOnIdx(grabbed[i], notes[i], len, vel);
        }
    }
    len => now;
}

// rest helper
fun void rest(dur len) { len => now; }

// ============================================================
//  SECTION A  –  Octave theme (A minor, percussive)
//  8 eighths per call  (~3.636 s)
// ============================================================
fun void playA() {
    int n[3];

    // m1–2 | A B C A | E F# G# E |
    [81,69,45] @=> n; chord(n, E, 0.90);
    [83,71,45] @=> n; chord(n, E, 0.86);
    [84,72,45] @=> n; chord(n, E, 0.90);
    [81,69,45] @=> n; chord(n, E, 0.86);

    [76,64,40] @=> n; chord(n, E, 0.90);
    [78,66,40] @=> n; chord(n, E, 0.86);
    [80,68,40] @=> n; chord(n, E, 0.90);
    [76,64,40] @=> n; chord(n, E, 0.86);

    // m3–4 | A B C A | E D C B |
    [81,69,45] @=> n; chord(n, E, 0.90);
    [83,71,45] @=> n; chord(n, E, 0.86);
    [84,72,45] @=> n; chord(n, E, 0.90);
    [81,69,45] @=> n; chord(n, E, 0.86);

    [76,64,40] @=> n; chord(n, E, 0.90);
    [74,62,40] @=> n; chord(n, E, 0.86);
    [72,60,40] @=> n; chord(n, E, 0.90);
    [71,59,40] @=> n; chord(n, E, 0.86);
}

// ============================================================
//  SECTION B  –  Singing major-theme answer (A major)
//  16 quarters per call  (~7.273 s)
// ============================================================
fun void playB() {
    int n[3];

    // mm. 1–2
    [76,64,45] @=> n; chord(n, Q, 0.84);
    [73,61,45] @=> n; chord(n, Q, 0.80);
    [69,57,45] @=> n; chord(n, Q, 0.84);
    [71,59,45] @=> n; chord(n, Q, 0.80);

    // mm. 3–4
    [73,61,38] @=> n; chord(n, Q, 0.84);
    [74,62,38] @=> n; chord(n, Q, 0.80);
    [76,64,40] @=> n; chord(n, Q, 0.84);
    [73,61,40] @=> n; chord(n, Q, 0.80);

    // mm. 5–6
    [74,62,40] @=> n; chord(n, Q, 0.84);
    [71,59,40] @=> n; chord(n, Q, 0.80);
    [69,57,45] @=> n; chord(n, Q, 0.84);
    [68,56,45] @=> n; chord(n, Q, 0.80);

    // mm. 7–8
    [78,66,38] @=> n; chord(n, Q, 0.84);
    [74,62,38] @=> n; chord(n, Q, 0.80);
    [76,64,40] @=> n; chord(n, Q, 0.84);
    [76,64,40] @=> n; chord(n, Q, 0.80);

    // mm. 9–10  (sequential, higher)
    [69,57,45] @=> n; chord(n, Q, 0.84);
    [73,61,45] @=> n; chord(n, Q, 0.80);
    [76,64,45] @=> n; chord(n, Q, 0.84);
    [73,61,45] @=> n; chord(n, Q, 0.80);

    // mm. 11–12
    [78,66,38] @=> n; chord(n, Q, 0.84);
    [74,62,38] @=> n; chord(n, Q, 0.80);
    [76,64,40] @=> n; chord(n, Q, 0.84);
    [73,61,40] @=> n; chord(n, Q, 0.80);

    // mm. 13–14
    [74,62,40] @=> n; chord(n, Q, 0.84);
    [71,59,40] @=> n; chord(n, Q, 0.80);
    [73,61,45] @=> n; chord(n, Q, 0.84);
    [69,57,45] @=> n; chord(n, Q, 0.80);

    // mm. 15–16  cadence
    [71,59,40] @=> n; chord(n, Q, 0.84);
    [68,56,40] @=> n; chord(n, Q, 0.80);
    [69,57,45] @=> n; chord(n, Q, 0.88);
    [69,57,45] @=> n; chord(n, Q, 0.82);
}

// ============================================================
//  SECTION C / Turkish episode
// ============================================================
// low-register "drum" chords
fun void turkishMeasures(int count) {
    int am[4];
    int em[4];
    [69,64,60,45] @=> am;   // A minor + A2 bass
    [64,59,56,40] @=> em;   // E major + E2 bass
    for (0 => int i; i < count; i++) {
        if (i % 2 == 0) {
            chord(am, E, 1.00); chord(am, E, 0.98);
            chord(am, E, 1.00); chord(am, E, 0.98);
        } else {
            chord(em, E, 1.00); chord(em, E, 0.98);
            chord(em, E, 1.00); chord(em, E, 0.98);
        }
    }
}

// brighter, higher-register Turkish chords
fun void turkishHighMeasures(int count) {
    int am[4];
    int em[4];
    [81,76,72,45] @=> am;   // A5-E5-C5 + A2
    [76,71,68,40] @=> em;   // E5-B4-G#4 + E2
    for (0 => int i; i < count; i++) {
        if (i % 2 == 0) {
            chord(am, E, 1.00); chord(am, E, 0.98);
            chord(am, E, 1.00); chord(am, E, 0.98);
        } else {
            chord(em, E, 1.00); chord(em, E, 0.98);
            chord(em, E, 1.00); chord(em, E, 0.98);
        }
    }
}

// cascading descent flourish
fun void descent() {
    int n[1];

    [81] @=> n; chord(n, E, 0.96);   // A
    [80] @=> n; chord(n, E, 0.94);   // G#
    [79] @=> n; chord(n, E, 0.91);   // G
    [78] @=> n; chord(n, E, 0.89);   // F#
    [77] @=> n; chord(n, E, 0.86);   // F
    [76] @=> n; chord(n, E, 0.83);   // E
    [74] @=> n; chord(n, E, 0.81);   // D
    [72] @=> n; chord(n, E, 0.79);   // C
    [71] @=> n; chord(n, E, 0.77);   // B
    [69] @=> n; chord(n, E, 0.75);   // A
}

// ============================================================
//  CODA  –  decisive A-minor close
// ============================================================
fun void coda() {
    int n[3];
    [81,69,45] @=> n; chord(n, E, 0.94);
    [81,69,45] @=> n; chord(n, E, 0.92);
    [81,69,45] @=> n; chord(n, Q, 0.96);
    rest(E);
    // final chord held
    [81,69,45] @=> n; chord(n, H * 1.5, 1.0);
    rest(Q);
}

// ============================================================
//  MAIN  –  assemble the ~175 s arc
// ============================================================

// ---- Exposition --------------------------------------------
playA(); playA(); playA(); playA();   // ~14.5 s
playA(); playA(); playA(); playA();   // ~14.5 s  (total A x8)

playB(); playB(); playB(); playB();   // ~29.1 s

playA(); playA(); playA(); playA();   // ~14.5 s

// ---- Development / Turkish episode -------------------------
turkishMeasures(12);                  // ~10.9 s
turkishHighMeasures(12);              // ~10.9 s
descent();                            // ~2.3 s

// ---- Recapitulation ----------------------------------------
playA(); playA(); playA(); playA();   // ~14.5 s

playB(); playB(); playB(); playB();   // ~29.1 s

playA(); playA();                     // ~7.3 s

// ---- Final Turkish blaze -----------------------------------
turkishMeasures(12);                  // ~10.9 s
turkishHighMeasures(12);              // ~10.9 s
descent();                            // ~2.3 s

// ---- Coda --------------------------------------------------
coda();                               // ~3.2 s

// end

Everything above produced in fp16 cache quality. I've tried to save something in memory and uplift the speed with going down Q8 cache and in result it produced a working and even playing melody code, but musical harmony is gone completely, melody is horrible to even listen. I always said going lower quality is waste of time, there's no magic.

So, it can write music, but not ordinary.
Longer melody even in Q8 quality with fp16 usually produce a code with errors, so it require also usually 1 repair by model itself.
This is "variation" on Bach melody, repaired after creation. It slightly reminds original but different, original is much more complex, but its still melodic. The melody topic is sadness. It plays for 262 seconds, on mobile devices ChucK is slow, better listen on PC. Repair takes almost 4 hours on my computer from year 2016, overnight, creation even longer but that was my fault with loading too much older data in it (all models by progression getting super slow with amount of data, although this model kinda keep the quality to the end-few syntax errors which can be repaired once is not bad. Broken code by Qwen not repaired by numerous attempts).

// J.S. Bach – Bourrée in E minor (after BWV 996)
// Reduction for 12-voice Rhodey piano pool + plate reverb
// Duration target: ~175.4 s  (≈ 2 min 55 s)
// Baroque binary form: A A | B B | A A | Episode Episode | A | Coda

// ============================================================
// 1.  CLOCK
// ============================================================
104.0 => float BPM;
(60.0 / BPM)::second => dur Q;   // quarter  (float -> dur via ::second)
Q * 2.0  => dur H;               // half
Q / 2.0  => dur E;               // eighth (for rests / articulation)

// ============================================================
// 2.  REVERB
// ============================================================
NRev rev => dac;
0.12 => rev.mix;

// ============================================================
// 3.  RHODEY POOL
// ============================================================
12 => int POOL;
Rhodey r[POOL];
for (0 => int i; i < POOL; i++) {
    r[i] => rev;
}

// ============================================================
// 4.  VOICE MANAGER
// ============================================================
0 => int voiceOnIdx;   // round-robin writer

fun void chord(int notes[], dur len, float vel) {
    int idx[notes.cap()];
    for (0 => int i; i < notes.cap(); i++) {
        voiceOnIdx % POOL => idx[i];
        (voiceOnIdx + 1) % POOL => voiceOnIdx;   // advance cleanly
    }
    // note on
    for (0 => int i; i < notes.cap(); i++) {
        vel * 0.9 + 0.1 => r[idx[i]].gain;
        Std.mtof(notes[i]) => r[idx[i]].freq;
        1 => r[idx[i]].noteOn;
    }
    // hold
    len => now;
    // note off
    for (0 => int i; i < notes.cap(); i++) {
        1 => r[idx[i]].noteOff;
    }
    // microscopic breathing
    E => now;
}

fun void rest(dur d) { d => now; }

// ============================================================
// 5.  SECTIONS
// ============================================================
fun void playA() {
    // m1 Em
    chord([64,55,52], Q, 0.82); chord([66,59,52], Q, 0.80);
    chord([67,59,52], Q, 0.82); chord([66,59,52], Q, 0.80);
    // m2 C/G
    chord([64,55,48], Q, 0.81); chord([62,55,48], Q, 0.79);
    chord([60,55,48], Q, 0.81); chord([59,50,43], Q, 0.80);
    // m3 Am
    chord([69,60,45], Q, 0.83); chord([71,60,45], Q, 0.81);
    chord([72,60,45], Q, 0.83); chord([74,60,45], Q, 0.81);
    // m4 B7
    chord([71,54,47], Q, 0.84); chord([69,54,47], Q, 0.82);
    chord([67,54,47], Q, 0.84); chord([66,51,47], Q, 0.85);
    // m5 Em
    chord([67,59,52], Q, 0.82); chord([66,59,52], Q, 0.80);
    chord([64,59,52], Q, 0.82); chord([62,59,52], Q, 0.80);
    // m6 C/G
    chord([64,55,48], Q, 0.81); chord([62,55,48], Q, 0.79);
    chord([60,55,48], Q, 0.81); chord([59,50,43], Q, 0.80);
    // m7 D major
    chord([74,57,50], Q, 0.83); chord([72,57,50], Q, 0.81);
    chord([71,57,50], Q, 0.83); chord([69,57,50], Q, 0.81);
    // m8 Em cadence
    chord([67,59,52], Q, 0.84); chord([66,59,52], Q, 0.82);
    chord([64,59,52], Q, 0.85); chord([64,55,52], Q, 0.83);
}

fun void playB() {
    // m1 G major
    chord([74,59,43], Q, 0.82); chord([76,59,43], Q, 0.80);
    chord([74,59,43], Q, 0.82); chord([71,50,43], Q, 0.81);
    // m2 G / Em color
    chord([69,59,43], Q, 0.80); chord([67,55,43], Q, 0.79);
    chord([66,55,43], Q, 0.80); chord([64,55,43], Q, 0.79);
    // m3 C major
    chord([76,52,48], Q, 0.81); chord([74,52,48], Q, 0.79);
    chord([72,52,48], Q, 0.81); chord([71,52,48], Q, 0.79);
    // m4 D major
    chord([69,54,50], Q, 0.83); chord([67,54,50], Q, 0.81);
    chord([66,54,50], Q, 0.83); chord([64,54,50], Q, 0.81);
    // m5 G major
    chord([71,59,43], Q, 0.82); chord([72,59,43], Q, 0.80);
    chord([74,59,43], Q, 0.82); chord([71,50,43], Q, 0.81);
    // m6 E minor
    chord([67,59,52], Q, 0.81); chord([66,59,52], Q, 0.79);
    chord([64,59,52], Q, 0.81); chord([62,59,52], Q, 0.79);
    // m7 A minor
    chord([76,60,45], Q, 0.82); chord([74,60,45], Q, 0.81);
    chord([72,60,45], Q, 0.82); chord([71,60,45], Q, 0.81);
    // m8 cadence D -> G
    chord([69,54,50], Q, 0.83); chord([67,54,50], Q, 0.82);
    chord([66,54,50], Q, 0.83); chord([67,59,43], Q, 0.85);
}

fun void playEpisode() {
    // circle-of-fifths sequence
    // m1 Am
    chord([69,60,45], Q, 0.81); chord([71,60,45], Q, 0.79);
    chord([72,60,45], Q, 0.81); chord([74,60,45], Q, 0.79);
    // m2 Dm
    chord([76,57,50], Q, 0.80); chord([74,65,50], Q, 0.79);
    chord([72,65,50], Q, 0.80); chord([71,65,50], Q, 0.79);
    // m3 G major
    chord([72,55,43], Q, 0.81); chord([71,55,43], Q, 0.80);
    chord([69,55,43], Q, 0.81); chord([67,55,43], Q, 0.80);
    // m4 C major
    chord([64,52,48], Q, 0.79); chord([65,57,48], Q, 0.78);
    chord([67,55,48], Q, 0.79); chord([64,52,48], Q, 0.78);
    // m5 F major
    chord([69,48,41], Q, 0.80); chord([70,48,41], Q, 0.79);
    chord([72,48,41], Q, 0.80); chord([69,48,41], Q, 0.79);
    // m6 B7
    chord([69,51,47], Q, 0.82); chord([67,54,47], Q, 0.81);
    chord([66,54,47], Q, 0.82); chord([64,54,47], Q, 0.81);
    // m7 Em
    chord([64,55,52], Q, 0.80); chord([66,55,52], Q, 0.78);
    chord([67,55,52], Q, 0.80); chord([69,55,52], Q, 0.78);
    // m8 B7 -> Em
    chord([71,54,47], Q, 0.83); chord([69,54,47], Q, 0.82);
    chord([66,51,47], Q, 0.84); chord([64,55,52], Q, 0.85);
}

fun void coda() {
    // m1 Em (octave higher echo)
    chord([76,59,52], Q, 0.76); chord([78,59,52], Q, 0.74);
    chord([79,59,52], Q, 0.76); chord([78,59,52], Q, 0.74);
    // m2 Am (open voicing)
    chord([81,60,45], Q, 0.75); chord([79,60,45], Q, 0.73);
    chord([76,60,45], Q, 0.75); chord([72,60,45], Q, 0.73);
    // m3 B7 (tension)
    chord([71,54,47], Q, 0.78); chord([69,54,47], Q, 0.76);
    chord([67,54,47], Q, 0.78); chord([66,51,47], Q, 0.80);
    // m4 final Em – whole note, then silence
    chord([64,55,52], H + H, 0.88);
}

// ============================================================
// 6.  MAIN SEQUENCE
// ============================================================
2::ms => now;       // DAC priming

playA(); playA();   // 36.92 s
playB(); playB();   // 73.85 s
playA(); playA();   // 110.77 s
playEpisode(); playEpisode(); // 147.69 s
playA();            // 166.15 s
coda();             // 175.38 s

now / second => float elapsed;
<<< "Bourree in E minor - total duration:", elapsed, "seconds" >>>;

Sign up or log in to comment