Skip to content

server: create dormant dream adapters and save immutable snapshots - #81

Open
joelteply wants to merge 5 commits into
889580fc/seq-state-across-stream-countsfrom
codex/dream-adapters
Open

joelteply wants to merge 5 commits into
889580fc/seq-state-across-stream-countsfrom
codex/dream-adapters

Conversation

@joelteply

Copy link
Copy Markdown

Continuous dreaming needs a dormant shadow and an immutable candidate without launching a training job. Adds POST /lora-adapters/fresh (name, rank, alpha, comma-separated targets, top_layers, seed) using the existing zero-B writer and dormant loader, and POST /lora-adapters/save (id, name) using the existing tensor serializer.

Names stay under --train-dir. Publication uses a private staging directory and a no-replace hard link; conflicts fail rather than overwrite. Save executes on the server task queue, serialized with learning and unload. Responses retain the load route's success/id/path shape. A lost fresh response can be recovered through load of its known name; fresh never silently replaces it.

Validation: diff check and Python AST parse passed. Added live D1 script covering zero-B parity, a learned shadow's snapshot/reload parity, invalid ids/path escapes, and competing save requests. C++ compilation and live execution pending CI/coordinated non-serving test window. This does not claim bounded snapshot latency: the existing save copies tensors and writes on the loop, so that cost needs measurement and later budgeted extraction. No optimizer checkpoint or multi-mind state claim.

AI-assisted implementation by Codex, reviewed line by line; private CambrianTech fork.

@joelteply

Copy link
Copy Markdown
Author

D1 behavioral receipt at exact b747897: Server workflow40779254560 SUCCESS, Ubuntu job123136504785 explicitly passes Dream adapter creation and snapshot parity. The isolated CPU tiny-model fixture checks dormant/zero-B output, successful completion-attached learn, snapshot/reload output parity, overwrite/path/id refusals and competing immutable publication. This is functional CPU proof, not 27B CUDA/Metal latency, restart retention, optimizer persistence, or canonical learning acceptance. Full log retained locally as d1-live-b747.log. Platform test and peer source review still required; snapshot remains synchronous on server loop.

@joelteply

Copy link
Copy Markdown
Author

Source review PASS at 1d73333 (Fable). Verified by reading: (1) SAVE_LORA runs on the server loop's queue beside LEARN/UNLOAD, so a snapshot cannot observe a partial optimizer step or a freed adapter; (2) server_publish_adapter reserves via a .pending directory and publishes by hard link, which cannot replace an existing destination, so names are immutable and a crash leaves no partial public GGUF; (3) fresh validates rank/alpha/top_layers/seed and confines the name, writes through common_lora_write_fresh (zero-B), then reuses load's dormant install; (4) the result JSON carries {success,id,path}, which the core client reads. Integration note (core side, handled in fable/dream-stage 'reopen her shadow file'): after an engine restart a second fresh with the same name refuses by design, so the core loads the existing shadow file first and calls fresh only when none exists. Platform (Metal) window pending on the M5, held until the M5 serving plan is fixed (it is on 1 slot x 27904 now).

🤖 Generated with Claude Code

@joelteply
joelteply marked this pull request as ready for review October 29, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant