Skip to content

server: POST /lora-adapters/snapshot writes a mind's shadow to an immutable GGUF between steps, and /learn reports the shadow's committed step - #86

Closed
joelteply wants to merge 3 commits into
cormac/per-mind-shadowfrom
cormac/shadow-snapshot
Closed

joelteply wants to merge 3 commits into
cormac/per-mind-shadowfrom
cormac/shadow-snapshot

Conversation

@joelteply

Copy link
Copy Markdown

What a shadow learned on a serving context lived only in memory: a restart
lost it, and nothing could hand it to a gene trial (continuum S4 (d), card
76b05d2a; ONE-RESIDENT-MODEL §9.2 "Snapshot").

  • POST /lora-adapters/snapshot {id, name}: on the server loop, between
    steps (never a half-applied update), the adapter's current weights are
    written beside the name and renamed into place inside --train-dir
    (confine_out, the load route's rule). An existing name is refused: a
    snapshot is immutable. The reply carries the path, bytes and the steps
    the shadow had committed.
  • /learn's outcome carries step: the shadow's committed optimizer steps
    after this one (each shadow counted on its own; unload forgets it), the
    commit the core's cursor stands on.
  • learn-every-format.py --snapshot: two steps (step 1, 2), a snapshot at
    steps 2, a second snapshot of that name refused, and the snapshot loaded
    under a new id shows the forward loss the shadow showed at its third
    step (2.526167, both), so the file is the trained weights. Qwen2.5-0.5B,
    IntelMac CPU, fresh server.

Co-Authored-By: Claude Opus 5.5 (1M context) [email protected]
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

joelteply and others added 2 commits November 7, 2026 12:58
… its own optimizer, /learn trains any loaded shadow, and unload releases it

A serving context trained exactly one shadow per server run (learn_lora_id):
the second mind's /learn was refused, so only one resident could ever
learn in place (continuum S4 (a), card eaeb2b87).

- llama_context keeps an optimizer per shadow (opt_minds); opt_ctx and
  opt_shadow point at the active one, so every training site reads the
  active pair as before. llama_opt_init with another adapter on a
  configured context selects it (opt_select), creating its optimizer the
  first time and keeping each shadow's moments and accumulators across
  switches. Only the active shadow's tensors carry the PARAM flag, so a
  graph never carries a parameter the active optimizer was not built
  with.
- opt_configured() is "this context is sized for training" (scheduler and
  graph): it was read as opt_ctx != nullptr, which a released active
  shadow would have falsified while other shadows' optimizers still held
  the scheduler.
- llama_opt_release forgets one shadow's optimizer; the server's unload
  releases a shadow that learned (its moments go; a snapshot is the
  durable form) instead of refusing it forever.
- learn-every-format.py --two-minds: two shadows from the same file learn
  alternately; their losses match step for step (4.3179, 4.3179, 3.5043,
  3.5043 on Qwen2.5-0.5B, IntelMac CPU), which holds only if each keeps
  its own weights and optimizer. --shadow-retirement now unloads a bound
  shadow and learns on a reloaded one.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…g changes, never asserted (Fable on #85)

opt_select (another mind's shadow) GGML_ASSERTed on caller input: a learn naming a loaded F16 copy of
a shadow killed the serving process (exit 134 at llama-context-opt.cpp:205), and the same asserts
sat on the first learn. Now one validator, llama_context::opt_untrainable (attached at a non-zero
scale, every A/B F32, the filter selecting at least one tensor), runs in opt_init and opt_select
before any parameter flag changes; on failure opt_failure says why and llama_opt_init returns
false. The /learn path restores her adapter set and refuses the learn by name; /train fails the run
by name. Test: learn-every-format.py --non-f32-refused (make-f16-shadow.py writes the F16 copy):
the F32 shadow learns, its F16 copy is refused naming non-F32, /health answers, and the F32 shadow
learns again. The default and --two-minds modes pass unchanged (CPU, Qwen2.5-0.5B, --no-repack).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply
joelteply force-pushed the cormac/per-mind-shadow branch from 7d885c8 to f359df5 Compare November 7, 2026 18:58
…utable GGUF between steps, and /learn reports the shadow's committed step

What a shadow learned on a serving context lived only in memory: a restart
lost it, and nothing could hand it to a gene trial (continuum S4 (d), card
76b05d2a; ONE-RESIDENT-MODEL §9.2 "Snapshot").

- POST /lora-adapters/snapshot {id, name}: on the server loop, between
  steps (never a half-applied update), the adapter's current weights are
  written beside the name and renamed into place inside --train-dir
  (confine_out, the load route's rule). An existing name is refused: a
  snapshot is immutable. The reply carries the path, bytes and the steps
  the shadow had committed.
- /learn's outcome carries step: the shadow's committed optimizer steps
  after this one (each shadow counted on its own; unload forgets it), the
  commit the core's cursor stands on.
- learn-every-format.py --snapshot: two steps (step 1, 2), a snapshot at
  steps 2, a second snapshot of that name refused, and the snapshot loaded
  under a new id shows the forward loss the shadow showed at its third
  step (2.526167, both), so the file is the trained weights. Qwen2.5-0.5B,
  IntelMac CPU, fresh server.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply
joelteply force-pushed the cormac/shadow-snapshot branch from ba57277 to 570984c Compare November 7, 2026 19:24
@joelteply
joelteply force-pushed the cormac/per-mind-shadow branch from f359df5 to c534ae8 Compare November 8, 2026 22:23
@joelteply

Copy link
Copy Markdown
Author

Superseded by the one save route: Codex's #81 /lora-adapters/save (immutable publication via staging + no-replace link) now carries this PR's committed-step report, ported as cormac/save-reports-steps 665f80d and merged on codex/s4-per-mind-integration at c96c2bb. The step count is the shadow's own optimizer's (llama_opt_shadow_steps), not this PR's server-side learn_steps tally. Branch kept, not deleted.

@joelteply joelteply closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant