Repository navigation
living weights v6: folded memory weights, in-flight learning and belief revision (opt-in), stored exactly - #4937
Merged
Merged
Conversation
ashhart
force-pushed
the
lead/living-weights-v6
branch
2 times, most recently
from
November 25, 2026 08:26
1576c20 to
de95633
Compare
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
#4937 gives native/memory_controller.zig a living import. The server builds qwen27_served.zig inside the native engines module, which has living, but the Qwen27 dev tools (tf-qwen27-speed-served, -served-check, -dflash-served-check, -lanes-check, -lanes-run, -bench, -classes, -streams, -reuse, -marks) and the macOS Qwen27 host steps build it as a module of its own without one, so dev-tools failed: no module named 'living' available within module 'qwen27_served'. Both modules now take the engine module's own living (its import table), as residency_host.zig does, so living.zig belongs to one module in each compilation; a new module is made only if an engine has none. Build wiring only.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
#4937 gives native/memory_controller.zig a living import. The server builds qwen27_served.zig inside the native engines module, which has living, but the Qwen27 dev tools (tf-qwen27-speed-served, -served-check, -dflash-served-check, -lanes-check, -lanes-run, -bench, -classes, -streams, -reuse, -marks) and the macOS Qwen27 host steps build it as a module of its own without one, so dev-tools failed: no module named 'living' available within module 'qwen27_served'. Both modules now take the engine module's own living (its import table), as residency_host.zig does, so living.zig belongs to one module in each compilation; a new module is made only if an engine has none. Build wiring only.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
Main's zig/src/platform/environment_test.zig was 597 lines and #4937's five TF_SLIDE_* rows in its valid table make it 602. Its Qwen host GiB cap test moves unchanged to environment_kv_test.zig, the file main already uses for Qwen rows split from it; both stay imported from environment.zig.
ashhart
force-pushed
the
lead/living-weights-v6
branch
from
November 25, 2026 11:21
85246d7 to
b51fb19
Compare
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
#4937 gives native/memory_controller.zig a living import. The server builds qwen27_served.zig inside the native engines module, which has living, but the Qwen27 dev tools (tf-qwen27-speed-served, -served-check, -dflash-served-check, -lanes-check, -lanes-run, -bench, -classes, -streams, -reuse, -marks) and the macOS Qwen27 host steps build it as a module of its own without one, so dev-tools failed: no module named 'living' available within module 'qwen27_served'. Both modules now take the engine module's own living (its import table), as residency_host.zig does, so living.zig belongs to one module in each compilation; a new module is made only if an engine has none. Build wiring only.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
Main's zig/src/platform/environment_test.zig was 597 lines and #4937's five TF_SLIDE_* rows in its valid table make it 602. Its Qwen host GiB cap test moves unchanged to environment_kv_test.zig, the file main already uses for Qwen rows split from it; both stay imported from environment.zig.
ashhart
force-pushed
the
lead/living-weights-v6
branch
from
November 25, 2026 14:09
b51fb19 to
ae922b1
Compare
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
…with learning off #4937 publishes folded_memory as a model capability, as every engine Info flag is (engine_capabilities.zig, between slide_conversations and vision); it is true only when --slide attaches the folded memory weights. The fake server serves no learning, so each /v1/models entry in the 27 golden replies that carry capabilities gains "folded_memory": false before "vision", and each reply's Content-Length grows by 24 bytes an entry; nothing else in them changes. docs/api.md lists the field with the other Info flags. test-golden: security-cases 69/69 and cases 327/340 equal, 0 unexpected differences (12 and 15 before).
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
#4937 gives native/memory_controller.zig a living import. The server builds qwen27_served.zig inside the native engines module, which has living, but the Qwen27 dev tools (tf-qwen27-speed-served, -served-check, -dflash-served-check, -lanes-check, -lanes-run, -bench, -classes, -streams, -reuse, -marks) and the macOS Qwen27 host steps build it as a module of its own without one, so dev-tools failed: no module named 'living' available within module 'qwen27_served'. Both modules now take the engine module's own living (its import table), as residency_host.zig does, so living.zig belongs to one module in each compilation; a new module is made only if an engine has none. Build wiring only.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
Main's zig/src/platform/environment_test.zig was 597 lines and #4937's five TF_SLIDE_* rows in its valid table make it 602. Its Qwen host GiB cap test moves unchanged to environment_kv_test.zig, the file main already uses for Qwen rows split from it; both stay imported from environment.zig.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
…with learning off #4937 publishes folded_memory as a model capability, as every engine Info flag is (engine_capabilities.zig, between slide_conversations and vision); it is true only when --slide attaches the folded memory weights. The fake server serves no learning, so each /v1/models entry in the 27 golden replies that carry capabilities gains "folded_memory": false before "vision", and each reply's Content-Length grows by 24 bytes an entry; nothing else in them changes. docs/api.md lists the field with the other Info flags. test-golden: security-cases 69/69 and cases 327/340 equal, 0 unexpected differences (12 and 15 before).
ashhart
force-pushed
the
lead/living-weights-v6
branch
from
November 25, 2026 15:17
ae922b1 to
7c56985
Compare
ashhart
force-pushed
the
lead/living-weights-v6
branch
from
November 25, 2026 17:41
7c56985 to
4272567
Compare
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
#4937 gives native/memory_controller.zig a living import. The server builds qwen27_served.zig inside the native engines module, which has living, but the Qwen27 dev tools (tf-qwen27-speed-served, -served-check, -dflash-served-check, -lanes-check, -lanes-run, -bench, -classes, -streams, -reuse, -marks) and the macOS Qwen27 host steps build it as a module of its own without one, so dev-tools failed: no module named 'living' available within module 'qwen27_served'. Both modules now take the engine module's own living (its import table), as residency_host.zig does, so living.zig belongs to one module in each compilation; a new module is made only if an engine has none. Build wiring only.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
Main's zig/src/platform/environment_test.zig was 597 lines and #4937's five TF_SLIDE_* rows in its valid table make it 602. Its Qwen host GiB cap test moves unchanged to environment_kv_test.zig, the file main already uses for Qwen rows split from it; both stay imported from environment.zig.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
…with learning off #4937 publishes folded_memory as a model capability, as every engine Info flag is (engine_capabilities.zig, between slide_conversations and vision); it is true only when --slide attaches the folded memory weights. The fake server serves no learning, so each /v1/models entry in the 27 golden replies that carry capabilities gains "folded_memory": false before "vision", and each reply's Content-Length grows by 24 bytes an entry; nothing else in them changes. docs/api.md lists the field with the other Info flags. test-golden: security-cases 69/69 and cases 327/340 equal, 0 unexpected differences (12 and 15 before).
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
#4937 gives native/memory_controller.zig a living import. The server builds qwen27_served.zig inside the native engines module, which has living, but the Qwen27 dev tools (tf-qwen27-speed-served, -served-check, -dflash-served-check, -lanes-check, -lanes-run, -bench, -classes, -streams, -reuse, -marks) and the macOS Qwen27 host steps build it as a module of its own without one, so dev-tools failed: no module named 'living' available within module 'qwen27_served'. Both modules now take the engine module's own living (its import table), as residency_host.zig does, so living.zig belongs to one module in each compilation; a new module is made only if an engine has none. Build wiring only.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
Main's zig/src/platform/environment_test.zig was 597 lines and #4937's five TF_SLIDE_* rows in its valid table make it 602. Its Qwen host GiB cap test moves unchanged to environment_kv_test.zig, the file main already uses for Qwen rows split from it; both stay imported from environment.zig.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
…with learning off #4937 publishes folded_memory as a model capability, as every engine Info flag is (engine_capabilities.zig, between slide_conversations and vision); it is true only when --slide attaches the folded memory weights. The fake server serves no learning, so each /v1/models entry in the 27 golden replies that carry capabilities gains "folded_memory": false before "vision", and each reply's Content-Length grows by 24 bytes an entry; nothing else in them changes. docs/api.md lists the field with the other Info flags. test-golden: security-cases 69/69 and cases 327/340 equal, 0 unexpected differences (12 and 15 before).
ashhart
force-pushed
the
lead/living-weights-v6
branch
from
November 25, 2026 19:32
4272567 to
e66f750
Compare
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
#4937 gives native/memory_controller.zig a living import. The server builds qwen27_served.zig inside the native engines module, which has living, but the Qwen27 dev tools (tf-qwen27-speed-served, -served-check, -dflash-served-check, -lanes-check, -lanes-run, -bench, -classes, -streams, -reuse, -marks) and the macOS Qwen27 host steps build it as a module of its own without one, so dev-tools failed: no module named 'living' available within module 'qwen27_served'. Both modules now take the engine module's own living (its import table), as residency_host.zig does, so living.zig belongs to one module in each compilation; a new module is made only if an engine has none. Build wiring only.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
Main's zig/src/platform/environment_test.zig was 597 lines and #4937's five TF_SLIDE_* rows in its valid table make it 602. Its Qwen host GiB cap test moves unchanged to environment_kv_test.zig, the file main already uses for Qwen rows split from it; both stay imported from environment.zig.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
…with learning off #4937 publishes folded_memory as a model capability, as every engine Info flag is (engine_capabilities.zig, between slide_conversations and vision); it is true only when --slide attaches the folded memory weights. The fake server serves no learning, so each /v1/models entry in the 27 golden replies that carry capabilities gains "folded_memory": false before "vision", and each reply's Content-Length grows by 24 bytes an entry; nothing else in them changes. docs/api.md lists the field with the other Info flags. test-golden: security-cases 69/69 and cases 327/340 equal, 0 unexpected differences (12 and 15 before).
An append cuts a torn tail before it writes and syncs the journal before it returns, and the CRC covers each frame's op and length. The base records a generation and a journal begins with the one it applies to, so a journal left by a compaction interrupted before its delete is never replayed onto the base that already holds it. The base file is synced before its rename and its directory after, a journal that cannot be read is an error rather than empty, and a unit counts as flushed once its frame is durable. The journal moves to journal.zig.
…e disk does A forget changed the live bank before it persisted, so a failed write left replies changed while the response said failure, and a bank emptied in memory swallowed its delete errors and reported success with the fact still on disk. A forget now writes its tombstone, or a base without the parent, first and leaves the bank as it was when that fails; a clear removes the files before the units and reports a failure by name. A replacing lesson forgets the old fact only once the new one is saved, and withdraws the new one if it cannot.
… the request's own prompt A memory prompt is placeholder ids for the folded prefix followed by the request's tail, and the Llama, Qwen3.5, Nemotron and Qwen3.8-27B backends treated a failed restore as a cache miss and prefilled those ids as text. They now refuse that fallback for a memory stream, and the lane host puts the request back at the front of its queue without memory, to run its own prompt from row 0.
…el computed it K and V are kept in the model's own BF16, K at the rows it was computed for: composing a unit shifts its K once to the rows it takes, and not at all when they are the same. Gate prototypes, calibration tokens, recurrent and skill factors stay in their computed F32, and the norm floors and each unit's negative ceiling are saved as their bit patterns. There is no Q4 or Q8 mode: kv_bits and the quantizers are gone, the format is v7, and a v3, v4 or v6 bank, which stored quantized values, is refused by name. A bank saved and reloaded now routes and composes bit for bit as the bank that was taught.
…ide switches in the environment registry bank.zig becomes a facade over types, teach, compose, consolidate, save, load, unit_store and compress; gate.zig gives ClusterIndex, the bridges and its tests their own files; decode_round's partial tap pass, slide_memory's cues, slide_graph's JSON values, lane_host's engine loop and the tests of lanes' stream, metal.zig and qwen27_served move out likewise, each moved block unchanged. Multi-line and over-long comments become single lines without the unmeasured claims. TF_SLIDE_TRACE, TF_SLIDE_LEGACY, TF_SLIDE_FAST_CUES and TF_SLIDE_AUTO are registered slide toggles read through the environment module and documented; the bank takes its trace switch from its controller.
A base records the whole geometry it was written for, and a load into any other family or architecture is refused by name, not only one of another hidden size or layer count. Every base and journal payload carries its data section's CRC32, checked before any value is used, so a damaged file is refused by name. A unit's fields are read with their types and ranges checked instead of trapping on a malformed one. The base, its temporary and the journal are created readable by their owner alone.
A folded-memory lesson marked its fact as checked and recalled, and its learned event said recalled:true, once the lesson was compiled and saved, but no held-out retrieval or answer check ran. A lesson now records no recall verdict and its event carries no recalled field; small-fact consolidation records none either.
…ly key The folded bank is shared, and a chat turn from any key could teach it a standing directive or fact that other keys then received. Automatic learning now takes a chat turn only from a key allowed to change shared memory: an admin key, or any turn on a server without keys, as every admin route already allows. TF_SLIDE_AUTO_ALL=1 is the explicit server switch for learning from every key's turns. A route that does not ask, as Responses and Ollama do not, offers nothing to learning.
…rompt Admission promised a request's bytes for its own prompt and reply, and the lane host then put a memory prefix in front of the prompt without pricing it, so a request could run past the bytes it was promised. The ledger now grows the request's promise to the prompt it will really run before the prefix is used, and a request that the rest does not fit is refused by name instead of run.
A lesson was taught one engine op at a time, so a request admitted between two of its ops routed against half a lesson, and the in-flight answer could run a later CPU-only op ahead of an earlier one. A lesson's units are now taught staged, out of every route, index and count, and go live together in one publish op before the lesson is saved; a consolidated small fact goes live the same way. Memory ops run strictly in arrival order. The bank counts published versions; a request takes the version current when it is opened (memory ops run on that same thread), routes against it alone, and its reply reports it as runtime.memory_version, which is absent with learning off.
…ted it A fact's recurrent-state change was kept as a low-rank SVD, and document chunks on Nemotron and Qwen3.8-27B kept none at all. Each recurrent layer's change S_after - S_prefix is now stored whole in F32 for every unit, and composing adds it at its weight with one fused multiply-add per element. Consolidation keeps the standing policies' summed change whole instead of a rank-8 fit. The conv state is always kept: svd_rank, svd_rank_short and keep_conv are gone. The format is v8; a v7 bank, which stored low-rank changes, is refused by name. A fact composed alone now gives exactly the prefix plus its computed change and the body's conv state, fresh or reloaded.
…server per folder until a lock lands
…he engine thread starts On an M3 Ultra a Qwen3.8-27B server without --slide ran prompts 1.2 to 5.4 percent and four- and eight-stream decode about 4 percent slower than main with equal tokens. The GPU program is main's (E330); the host loop carried three folded-memory additions every iteration: a between-rounds poll, an idle answer block and a memory-queue term in the idle wait. - The engine thread picks its loop once at start from `folded_memory` (set before the host starts): loop(false) is main's loop with the three additions compiled out, loop(true) keeps them. The same for the family-round loop (lane_rounds.zig). - Per request, the HTTP route evaluates the learning scope (auth_scope.learnsFrom, which can read TF_SLIDE_AUTO_ALL) only when the engine serves folded memory; learning turns need its worker anyway. - lane_host_memory.wanted names when a server builds a memory holder (--slide with a checkpoint folder), and the Qwen 27B server asks it. A host test runs a request through the actual lane host with a bank attached after start and an op waiting: without --slide the op is never polled and the bank never called; with --slide it is answered once.
…he guide A --slide server already holds its model folder exclusively for its whole run (server/main.zig takes the folder lease, originals.serving): a second --slide server, any other server or a rollback on that folder is refused at start with the folder named, because a lesson rewrites the model's own files, and the advisory lock ends with the process. New host tests pin it across processes: while a forked writer lives, a second writer and a plain server are both refused; once it is killed, or exits without releasing, the next writer takes the folder. The guide's keep/move/reset list now says so. No behaviour change.
…dy holds a learning folder for one server
… named where its one use is)
#4937 gives native/memory_controller.zig a living import. The server builds qwen27_served.zig inside the native engines module, which has living, but the Qwen27 dev tools (tf-qwen27-speed-served, -served-check, -dflash-served-check, -lanes-check, -lanes-run, -bench, -classes, -streams, -reuse, -marks) and the macOS Qwen27 host steps build it as a module of its own without one, so dev-tools failed: no module named 'living' available within module 'qwen27_served'. Both modules now take the engine module's own living (its import table), as residency_host.zig does, so living.zig belongs to one module in each compilation; a new module is made only if an engine has none. Build wiring only.
Main's zig/src/platform/environment_test.zig was 597 lines and #4937's five TF_SLIDE_* rows in its valid table make it 602. Its Qwen host GiB cap test moves unchanged to environment_kv_test.zig, the file main already uses for Qwen rows split from it; both stay imported from environment.zig.
…with learning off #4937 publishes folded_memory as a model capability, as every engine Info flag is (engine_capabilities.zig, between slide_conversations and vision); it is true only when --slide attaches the folded memory weights. The fake server serves no learning, so each /v1/models entry in the 27 golden replies that carry capabilities gains "folded_memory": false before "vision", and each reply's Content-Length grows by 24 bytes an entry; nothing else in them changes. docs/api.md lists the field with the other Info flags. test-golden: security-cases 69/69 and cases 327/340 equal, 0 unexpected differences (12 and 15 before).
… a fresh path, since Windows can keep a just-deleted file delete-pending
…OS, since Windows opens one and reads it as empty
ashhart
force-pushed
the
lead/living-weights-v6
branch
from
November 25, 2026 21:42
223a869 to
9af2fbd
Compare
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
#4937 gives native/memory_controller.zig a living import. The server builds qwen27_served.zig inside the native engines module, which has living, but the Qwen27 dev tools (tf-qwen27-speed-served, -served-check, -dflash-served-check, -lanes-check, -lanes-run, -bench, -classes, -streams, -reuse, -marks) and the macOS Qwen27 host steps build it as a module of its own without one, so dev-tools failed: no module named 'living' available within module 'qwen27_served'. Both modules now take the engine module's own living (its import table), as residency_host.zig does, so living.zig belongs to one module in each compilation; a new module is made only if an engine has none. Build wiring only.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
Main's zig/src/platform/environment_test.zig was 597 lines and #4937's five TF_SLIDE_* rows in its valid table make it 602. Its Qwen host GiB cap test moves unchanged to environment_kv_test.zig, the file main already uses for Qwen rows split from it; both stay imported from environment.zig.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
…with learning off #4937 publishes folded_memory as a model capability, as every engine Info flag is (engine_capabilities.zig, between slide_conversations and vision); it is true only when --slide attaches the folded memory weights. The fake server serves no learning, so each /v1/models entry in the 27 golden replies that carry capabilities gains "folded_memory": false before "vision", and each reply's Content-Length grows by 24 bytes an entry; nothing else in them changes. docs/api.md lists the field with the other Info flags. test-golden: security-cases 69/69 and cases 327/340 equal, 0 unexpected differences (12 and 15 before).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Living weights v6: folded memory, learning off by default, exact storage, repeatable replies
Living weights v6 lets a served model learn facts, documents and standing instructions without changing its weights. A lesson is compiled into a folded memory unit:
At request time the lane host routes the latest user turn through the gate. Matching units are composed into a prefix state in front of the request's own prompt. With
--slide, lessons come fromPOST /v1/slide/learn, from automatic learning on chat turns, and from belief revision (a newer fact supersedes an older one, and deleting it undoes that). The bank is saved as one safetensors base plus a crash-safe delta journal. Llama, Nemotron, Qwen3.5 and Qwen3.8-27B on Metal attach it.The branch is the original v6 commit plus four stages of fixes from our review.
Stage 1: off by default, and safe
--slide, no bank attaches and no saved file is read. Chat, the server and the lane host do exactly main's work: no query encoding, no header encoding, no lock between rounds.Stage 2: exact storage, small files
Stage 3: repeatable, private, priced, validated, honest
runtime.memory_version).TF_SLIDE_AUTO_ALL=1. Inference-only keys never teach the shared bank.recalledfield.Stage 4: every memory piece whole
S_after - S_prefix) is stored whole in F32 for every unit, documents included. There's no SVD and no rank.keep_convoption is gone.Proven on host (no device)
Needs devices
Learning off, main against branch: tokens, TTFT, prefill, decode, concurrency and memory on M3 Ultra and M5 Ultra, with clean and populated checkpoint directories. On GB10 (CUDA) and Strix Halo (HIP), the off-path lane and server changes, A/B against main.
Learning on, one memory version:
Restore, admission and load: real restore-failure fallback, admission refusal at the budget edge, and the refusal of a bank from another checkpoint revision.
Not in this branch: two writers on one checkpoint are not locked out.
Memory at scale: with about 150 MB per fact on a 27B model, a bank's disk and RAM use needs measuring at a realistic fact count.
Synthena
Known limits (documented in docs/living-weights.md)
--slideserver holds its folder with an exclusive advisory lock for as long as it runs; a second server, a reader or a rollback on that folder is refused at start (main's existing guard, now pinned by a cross-process test).