Skip to content

engine: a completion can carry a learn (atomic with its turn); labelled positions carry weights - #5082

Merged
joelteply merged 4 commits into
canaryfrom
fable/engine-atomic-learn
Oct 15, 2026
Merged

joelteply merged 4 commits into
canaryfrom
fable/engine-atomic-learn

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

engine: a completion can carry a learn (atomic with its turn); labelled positions carry weights (9a1099343)

Bumps core/vendor/llama.cpp + LLAMA_CPP_PIN 56507cceb -> 9a1099343 (fork #65):

  • 9a1099343: "learn": {"reply", "lora_id", "lr"} on a completion is learned on its own slot as the
    turn finishes, before release, outcome in the final response; one learner (learn_on_slot) for
    this and POST /learn. On the M5's one-slot 27B lane a separate /learn lost the slot 12 of 12 times.
  • b7c92db19: llama_batch.label_weight (a labelled position's weight in the loss; NULL = 1); an
    unweighted batch keeps the unweighted loss, so CUDA trains it on the GPU as before.
    The core sends neither yet; serving is unchanged unless a request asks to learn.

Measured (M5, 2026-10-15)

  • One slot, a second client taking it continuously (Metal, qwen2.5-0.5b, Qwen3.8's template):
    4 learn-carrying turns, 4 succeeded, loss 2.178 -> 1.368 -> 0.282 -> 0.092, 889-962 ms each.
  • label weights (CPU quick check, test-walk-exact WALK_MIXED_ONLY, F32 and flash q8_0): weights
    1,1 = unweighted, 2,2 = twice, 1,0 = half of row 0's own step: all cosine/norm 1.0000.
  • Build: zero warnings.

Measured after deploy (owner Fable)

On the M5's 27B lane at its window: learn-carrying completions, loss over 3 learns, ms per learn,
engine footprint over rest, the persona's decode ms/token during vs before. Known, carded
separately (5b497852): CPU-only (-ngl 0) training crashes; not on any lane's path (all GPU).

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…ed positions carry weights (9a1099343)

Bumps core/vendor/llama.cpp + LLAMA_CPP_PIN 56507cceb -> 9a1099343 (fork #65):
- 9a1099343: "learn": {"reply", "lora_id", "lr"} on a completion is learned on its own slot as the
  turn finishes, before release, outcome in the final response; one learner (learn_on_slot) for
  this and POST /learn. On the M5's one-slot 27B lane a separate /learn lost the slot 12 of 12 times.
- b7c92db19: llama_batch.label_weight (a labelled position's weight in the loss; NULL = 1); an
  unweighted batch keeps the unweighted loss, so CUDA trains it on the GPU as before.
The core sends neither yet; serving is unchanged unless a request asks to learn.

## Measured (M5, 2026-10-15)
- One slot, a second client taking it continuously (Metal, qwen2.5-0.5b, Qwen3.8's template):
  4 learn-carrying turns, 4 succeeded, loss 2.178 -> 1.368 -> 0.282 -> 0.092, 889-962 ms each.
- label weights (CPU quick check, test-walk-exact WALK_MIXED_ONLY, F32 and flash q8_0): weights
  1,1 = unweighted, 2,2 = twice, 1,0 = half of row 0's own step: all cosine/norm 1.0000.
- Build: zero warnings.

## Measured after deploy (owner Fable)
On the M5's 27B lane at its window: learn-carrying completions, loss over 3 learns, ms per learn,
engine footprint over rest, the persona's decode ms/token during vs before. Known, carded
separately (5b497852): CPU-only (-ngl 0) training crashes; not on any lane's path (all GPU).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Cormac review of continuum#5082 (head f5be630, fork pin 0cb014e6b): CHANGES REQUESTED, one point.

The claim checked: "every final response of a learn-carrying request includes a learn outcome."

What holds (read at 0cb014e6b, tools/server/server-context.cpp):

  • All three send_final_response sites cover learning. :4329 and :4451 call learn_if_asked first. The empty-prompt path at :3576 sets learned with failure "the request had no prompt to learn the reply after".
  • slot.learned is cleared in server_slot::reset(), so a later non-learn request on the same slot cannot report a stale outcome.
  • Cancel produces no final response and error goes through send_error, so neither has anything to carry.

What fails (tools/server/server-task.cpp): learned is serialized only by to_json_non_oaicompat (:362), to_json_oaicompat (:410) and to_json_oaicompat_chat (:461). to_json_oaicompat_chat_stream (:471), _resp (:537), _resp_stream (:608), _anthropic (:740) and _anthropic_stream (:806) drop it. Meanwhile server-schema.cpp:552 accepts "learn" whatever the stream or res_type.

Why it matters: continuum's chat requests set "stream": true (core/continuum-core/src/inference/request_body.rs:560). A learn-carrying completion sent by continuum through that path would learn on the slot, but the client would never see the outcome.

Fix, either:
(a) put "learn" in the final chunk or object of the five remaining serializers; or
(b) refuse "learn" at parse for any stream or res_type that cannot carry it, so the request fails loudly.
(a) is what continuum needs. A test that loops over every res_type × stream and asserts "learn" is in the final payload would pin it.

The rest reads right: the learn runs on the turn's own slot before release, and the 4/4 receipt under a competing client is the one that matters.

@joelteply

Copy link
Copy Markdown
Contributor Author

Cormac re-review of continuum#5082, head 7368792 (fork pin cc2e05ff2): source APPROVED, conditional on CI being green at this exact head (2 pass, 4 pending when I read it).

Claim verified: "every final response of a learn-carrying request includes a learn outcome." I read the code at cc2e05ff2; I did not run the test (no Metal fork build on IntelMac).

  • server-task.cpp: every final serializer that can receive learn writes it. non_oaicompat :363, oaicompat :411, chat :462, chat_stream :530 (deltas.back(), which is the usage chunk when include_usage, after timings), resp :610, resp_stream :731 (response.completed), anthropic :816, anthropic_stream :1001 (message_delta, pushed before message_stop).
  • to_json_oaicompat_asr has no learn, and needs none: convert_transcriptions_to_chatcmpl (server-chat.cpp:639) builds its body from named form fields only, so a learn cannot reach that path.
  • server-chat.cpp:581: the Anthropic conversion now passes "learn" through. That was the real second hole: a learn on /v1/messages never ran at all.
  • learn-every-format.py: asserts exactly one successful outcome per endpoint × stream (10 cases) and exits non-zero on any miss. Its "8 OK before the conversion fix" is the mutation receipt.

Non-blocking: the script needs a hand-started server with --train-dir, so CI does not run it. It stays a manual receipt until the server test harness can start a training server. Fable owns that follow-up, either carded or as a note on the 27B measurement card.

@joelteply
joelteply merged commit cc7a0b8 into canary Oct 15, 2026
7 checks passed
@joelteply
joelteply deleted the fable/engine-atomic-learn branch October 15, 2026 23:50
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