Skip to content

inkling: adopt route_trace.h, keeping the IKU1 history readable - #742

Merged
JustVugg merged 1 commit into
JustVugg:devfrom
terrizoaguimor:feat/inkling-route-trace
Aug 1, 2026
Merged

inkling: adopt route_trace.h, keeping the IKU1 history readable#742
JustVugg merged 1 commit into
JustVugg:devfrom
terrizoaguimor:feat/inkling-route-trace

Conversation

@terrizoaguimor

@terrizoaguimor terrizoaguimor commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Third engine onto the shared telemetry from #700, after colibri.c (#716) and kimi_k3.c
(#719). The counters, the load and the save move to route_trace.h; the bump sites are
untouched, because m->eusage now aliases rt_counts_all().

The transition is the point. rt_load reads both the IKU1 block every previous inkling
wrote and the shared text format, so an existing .coli_usage keeps working and is rewritten
in the new form. The magic / n_layers / n_experts checks pins_load did inline all still
fire, now in the reader, and for an IKU1 block the acceptance is unchanged. The reader adds
the other direction — a non-inkling engine cannot read an IKU1 file — which was previously
free, because only inkling had the code path. Dimension mismatches are refused at any trust
level, since there the dimensions are the parse geometry rather than an attribution.

It also fixes a latent bug. PIN_N=0 is documented as seeding the ranking from the history
without pinning, but the npin guard ran before the memcpy, so it seeded nothing and the
next usage_save replaced the accumulated ranking with that run's counts alone.

Verified on the tiny fixture: clean rebuild, oracle token-exact (36/36 teacher-forced argmax,
24/24 generated), make check 273 passed / 34 skipped, and the built engine reading a planted
legacy history pins the right 9 experts while dropping the dense layer's counts. Detail and
the dimension-refusal cases are in #700.

🤖 Generated with Claude Code

Third engine onto the shared telemetry from JustVugg#700, after colibri.c (JustVugg#716) and
kimi_k3.c (JustVugg#719). The counters, the load and the save move to route_trace.h;
the bump sites are untouched, since m->eusage now aliases rt_counts_all().

The transition is the point: rt_load reads both the IKU1 block every previous
inkling wrote and the shared text format, so an existing .coli_usage keeps
working and is rewritten in the new form. The header checks the old pins_load
did inline -- magic, n_layers, n_experts against the live config -- all still
fire, now in the reader, which additionally refuses a history written by a
different engine. Narrower than before, never wider; and parse geometry does
not bend to a trusted path the way identity does.

Fixes a latent bug on the way: pins_load documents PIN_N=0 as "seeds the
ranking from the history but pins nothing", but the npin guard ran before the
memcpy, so the counters started at zero and the next usage_save replaced the
accumulated ranking with that run's counts alone.

Verified on the tiny fixture: rebuild clean, oracle token-exact (36/36
teacher-forced, 24/24 generated), make check 273 passed / 34 skipped, and the
built engine reading a planted legacy history pins the right 9 experts while
dropping the dense layer's counts.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@JustVugg
JustVugg merged commit 9d240ab into JustVugg:dev Aug 1, 2026
13 checks passed
terrizoaguimor added a commit to terrizoaguimor/colibri that referenced this pull request Aug 1, 2026
Fourth and final engine for JustVugg#700, after colibri.c (JustVugg#716), kimi_k3.c (JustVugg#719) and
inkling.c (JustVugg#742). Every engine that routes experts now writes the same format.

m->freq moves from one flat [n_layers * n_experts] block to route_trace.h's row
per layer, so the three read sites -- the hot-pin ranking, the bump in moe() and
the LFRU eviction guard -- change shape but not meaning. last_access stays flat;
it is a separate array route_trace.h does not own. Every olmoe layer routes and
there is no MTP layer, so the only row dropped is the spare one rt_init leaves.

The history is opt-in behind COLI_USAGE, exactly as kimi_k3 does it: with the
variable unset nothing is loaded and nothing is written, so the default path is
unchanged. PPL=1 deliberately does not save, so a loss sweep cannot fold its own
tokens into the persisted ranking.

Verified against the real OLMoE-1B-7B-0125-Instruct converted with
tools/convert_olmoe_merged.py. Output is byte-identical to dev on the same run,
down to hit=1216 miss=832 -- the eviction path decides exactly as before, which
is the property the layout change could have broken. The COLI_USAGE round trip
writes the -1/-2 header with the olmoe identity, leaves no row for the dropped
layer, and accumulates 2048 -> 4096 across two runs. make check green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
terrizoaguimor added a commit to terrizoaguimor/colibri that referenced this pull request Aug 1, 2026
Fourth and final engine for JustVugg#700, after colibri.c (JustVugg#716), kimi_k3.c (JustVugg#719) and
inkling.c (JustVugg#742). Every engine that routes experts now writes the same format.

m->freq moves from one flat [n_layers * n_experts] block to route_trace.h's row
per layer, so the three read sites -- the hot-pin ranking, the bump in moe() and
the LFRU eviction guard -- change shape but not meaning. last_access stays flat;
it is a separate array route_trace.h does not own. Every olmoe layer routes and
there is no MTP layer, so the only row dropped is the spare one rt_init leaves.

The history is opt-in behind COLI_USAGE, exactly as kimi_k3 does it: with the
variable unset nothing is loaded and nothing is written, so the default path is
unchanged. PPL=1 deliberately does not save, so a loss sweep cannot fold its own
tokens into the persisted ranking.

Verified against the real OLMoE-1B-7B-0125-Instruct converted with
tools/convert_olmoe_merged.py. Output is byte-identical to dev on the same run,
down to hit=1216 miss=832 -- the eviction path decides exactly as before, which
is the property the layout change could have broken. The COLI_USAGE round trip
writes the -1/-2 header with the olmoe identity, leaves no row for the dropped
layer, and accumulates 2048 -> 4096 across two runs. make check green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants