Skip to content

feat(genome): the engine is the one trainer; with no live lane a job waits, and the Python trainers are deleted (878f100f) - #5029

Open
joelteply wants to merge 1 commit into
canaryfrom
878f100f/forge-train-s-mlx-engine-makes-python-lo
Open

joelteply wants to merge 1 commit into
canaryfrom
878f100f/forge-train-s-mlx-engine-makes-python-lo

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Card 878f100f. Joel, 2026-10-13: "Python can't be part of code."

The defect

coordinator.rs:141 kept an adapter only if adapter.serves_base(base). Only the engine answered that from live state ("a live lane serves this base"); cuda-local inherited the default true. So whenever no lane served the base, the coordinator silently picked the Python trainer.

Measured on the 5090: Kimi's job 7abf8ea4 (2026-10-12T22:12:03Z, 16 examples, base Qwen3.8-27B) went to cuda_train.py. The next boot journaled it killed-by-reboot, and its adapters/ is empty. The coordinator's own doc calls a silently honoured other provider a fallback.

The change

Selection by capability; availability asked of the chosen trainer (Codex root: keep the distinction rather than delete it).

  • FineTuningAdapter::available_for replaces serves_base.
  • An unavailable choice returns CoordinatorError::AwaitingAvailability. It never goes to the next trainer, including when the caller preferred that trainer.

The wait is a wait, not a refusal.

  • The engine's create_job without a lane now returns FineTuningError::AwaitingLane, not InvalidRequest. The latter was permanent, for a lane that comes back.
  • genome/job-create carries both refusals as errorKind: "AwaitingLane".
  • The trigger keeps the batch as DispatchPhase::AwaitingLane, a new variant beside an unchanged Parked { wait: CapacityWait }. DispatchPhase is internally tagged, so old rows decode unchanged. This is Cormac's option (c).
  • The wake is "a live lane serves THIS base" (engine_lora_adapter::lane_serves, over the existing live_lane_for). A lane serving another base doesn't wake it (Codex root). It's one shared re-dispatch with Parked, not a parallel path.
  • The status view renders {"state":"awaiting_lane"}, and DispatchPhase.ts is regenerated.

Deleted, with no caller left:

  • cuda_lora_adapter.rs, cuda_train.py, cuda_train_test.py, and the CI step that ran it (continuum-rust-tests.yml, CI subtracts).
  • mlx_lora_adapter.rs and probe_chat_template.py.
  • native_jobs' process path: Execution::Process, ProcessSpec, run_process, drain, the test-only launch and child fixture. A job's run is now the in-place run (PreparedJob { run, finish }).
  • Their ipc/mod.rs registrations.
  • python_adapter.rs's header now says what the adapter is: citizens' own Python (code/run), not system machinery.
  • Docs: CUDA-GENOME-TRAINING.md is marked superseded; the ONE-RESIDENT "today" rows and the FORGE-CUSTODIAN training paragraph are corrected.

Not in this PR: forge/train's mlx_lm path (forge/mlx_train.rs, mlx_job.rs) and the forge custodian's convert_lora_to_gguf.py. They're a separate binary and wire contract, waiting on Cormac's consumer inventory as PR-2.

Tests (what each catches)

  • coordinator::an_unavailable_resident_trainer_is_waited_for_never_skipped: the regression itself. A capable lesser trainer is registered, the resident trainer has no lane, and selection must wait, also under a preference for it.
  • durable::a_bucket_awaiting_a_lane_dispatches_once_when_its_base_is_served:
    • a full bucket is accepted and awaits;
    • status shows awaiting_lane;
    • a lane for another base wakes nothing;
    • when its base is served, two recovery ticks yield exactly one job with all 3 examples.
  • engine_lora_adapter::unknown_targets_are_refused_and_unserved_bases_wait: this inverts the old assertion, so a base with no lane now waits. It also asserts lane_serves is false against the real registry with no lane.
  • native_jobs tests ported, not dropped:
    • capacity waiting and cancellation now go through the shared wait_for_training_memory admission;
    • cancel latching, foreign-handle rejection and "Cancelled only after the run stopped" now use an in-place run.
  • RecordingFineTuningAdapter gained a resident(lane) mode, so there's no new fixture (CLAUDE.md: one fixture per concern).

Measured

  • Tests: on the 5090, worktree at 2ead81b52, 2026-10-13 ~20:10Z, guarded cargo test -p continuum-core --lib -j2 -- genome::fine_tuning training_trigger commands::genome export_bindings_dispatchphase: 299 passed, 0 failed. Zero warnings in the touched files.
  • Delta: 22 files, +274 / −2016.
  • This removes no working training, per each node's ledger since 10-06:
    • 5090: 119 of 120 Kimi jobs trained engine-local; the one Python job died.
    • M5: 0 completed mlx-local genes; its one attempt failed admission on safetensors (Fable).
    • IntelMac: 0 jobs registered (Cormac).
  • Not shown by this: that native Metal training works. That receipt is Fable's (card 3b8fb153).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc

…waits, and the Python trainers are deleted (878f100f)

Joel, 2026-10-13: "Python can't be part of code."

The fallback: coordinator.rs kept an adapter only if serves_base(base), and only
the engine answered that from live state ('a live lane serves this base'). So
with no live lane, Kimi's 27B job went to cuda-local's Python cuda_train.py:
job 7abf8ea4, 2026-10-12T22:12:03Z, 16 examples, journaled killed-by-reboot,
adapters/ empty.

Selection is by capability; availability is asked of the CHOSEN trainer:
- FineTuningAdapter::available_for replaces serves_base. An unavailable choice
  is CoordinatorError::AwaitingAvailability, never the next trainer.
- The engine's create_job without a lane is FineTuningError::AwaitingLane, not
  InvalidRequest (a permanent refusal for a wait).
- job-create carries both as errorKind AwaitingLane; the trigger keeps the
  batch as DispatchPhase::AwaitingLane, a new tagged phase beside an unchanged
  Parked. Its wake is "a live lane serves THIS base"; one shared re-dispatch.

Deleted, with no caller left:
- cuda_lora_adapter.rs + cuda_train.py + cuda_train_test.py, and its CI step
- mlx_lora_adapter.rs + probe_chat_template.py
- native_jobs' process path (Execution::Process, ProcessSpec, run_process,
  drain, the test-only launch). A job's run is the in-place run.

Measured since 10-06: the 5090 trained 119/120 Kimi jobs engine-local; the M5
completed 0 genes on mlx-local (Fable); IntelMac registered 0 jobs (Cormac).
So this removes no working training. Native Metal training is NOT shown by this;
that receipt is Fable's (card 3b8fb153).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
joelteply added a commit that referenced this pull request Oct 14, 2026
…9ae815) (#5035)

* refactor(process): the remaining timed child waits run owned (card 679ae815)

Four more timeout + output/wait_with_output + kill_on_drop copies, each of
which ended only the direct child, now go through lane_process::run_owned:
- the sentinel shell step (a pipeline's commands and what they start);
- authored commands (sdk_codegen ext), through the new run_owned_with_input:
  params go to stdin BESIDE the wait, so a program that never reads them can't
  wedge the call past its bound (the old runner awaited the write first). Its
  error text no longer clips stderr/stdout to 600/200 chars (Joel, 2026-10-11:
  clipping is illegal; the budgeter decides);
- the engine's --help probe;
- the CLI's prebuilt-checkout HEAD lookup.
Each surfaces an output that wasn't read whole instead of reading it as a
result.

Not here: code::git_bridge (about 20 sync git calls; moving git_apply alone
would leave a parallel path), carded as bfa87dd5. python_adapter's runner is
being deleted in #5029. shutdown.rs:270 is a test harness child.

Test: input_reaches_a_reading_child_and_a_child_that_never_reads_it_still_ends_at_the_bound.

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

* fix(process): input delivery is recorded on the run owner; timeouts keep what was read and name unconfirmed teardown (Codex root on #5035 at 549dce1)

- The stdin writer discarded its own outcome, so a child that closed stdin
  early and exited 0 with valid JSON read as having answered the call. The
  write's end is now recorded on the run's capture (RunCapture.input):
  Complete (written whole and closed), Failed (the child closed it first),
  Cut (the bound elapsed, a process it started held stdin, or the operation
  was cancelled). OwnedOutput carries it, and input_note names it. Authored
  commands reject a result whose input wasn't delivered. Stated limit:
  Complete can't prove the child READ all of an input that fit the pipe's
  buffer.
- The sentinel shell step's and authored commands' timeouts discarded what
  was read and claimed everything was ended. Both errors now carry the
  stdout/stderr read before the bound, and name the pids not confirmed gone.

Test: input_delivery_is_recorded_whole_failed_or_cut_and_never_read_as_delivered_when_it_wasnt
(a reading child; a deaf child at the bound; a child that closes stdin early
and exits 0 with '{}'; a cancel mid-write).

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

* fix(process): the input writer stays owned through its wait; a stdin holder is fenced like an output holder (Codex root on #5035 at dc2a64c)

The exit path took the writer out of the owner before awaiting it (the hole
#5030 closed for the readers): a cancel during that await detached it, and
Drop saw no writer to stop or mark. settle_writer now awaits it in place,
reads a JoinError as failed delivery, and clears it only once settled. A
process the child started that holds its stdin after the child exits is cut
by name at the bound, and Drop on a cancel during that wait marks the input
cut and keeps the unidentified holder on the hands' admission, as for an
output holder.

Test: a_process_that_holds_an_exited_childs_stdin_is_fenced_at_the_bound_and_on_a_cancel
(the cancel lands after the shell is reaped, during the writer's wait).

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

* test(process): the stdin holder keeps the pipe under dash too (CI failure at d66da0f)

CI's sh is dash, which gives an async command /dev/null as stdin before its
redirections, so `sleep <&0 &` held /dev/null, not the pipe, and the write
ended with a broken pipe (Failed, not Cut). Measured on IntelMac: under
/bin/dash, `<&0` leaves fd 0 a CHR device and `exec 3<&0; ... <&3` leaves it
a PIPE; /bin/sh (bash) gives a PIPE for both. The holder now takes the pipe
through fd 3.

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

* refactor(process): one owned pipe-task lifecycle for the readers and the writer; tests cancel on the run's own exited signal (Codex root on #5035)

The ownership defect repeated across stream directions because the lifecycle
was copied per direction (drain_readers/cut_readers for stdout and stderr,
settle_writer and its own Drop branch for stdin). Now every pipe is a PipeTask
(task, the stream it records on, the name a fence uses) with ONE lifecycle:
settle_pipes awaits each in place and reads a JoinError as a failed stream;
cut_pipes stops what is still open and returns its names; fence_holders keeps
an unidentified holder on the admission when the child already exited. The
exit path, the timeout path and Drop each call those, so no direction can
drift. -105/+84.

RunCapture::exited() is set once the child is reaped. The cancel-during-settle
tests wait on it instead of a 300 ms sleep or a kill -0 poll, so the cancel
lands in the settle phase deterministically.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@joelteply

Copy link
Copy Markdown
Contributor Author

Review #5029 at 2ead81b, Cormac, source review. Logic PASS; it can't land without a rebase that also fixes code canary added since 10-13. Claim checked: an unavailable resident trainer is waited for, never skipped.

How I checked:

  • coordinator.rs: capability alone forms the ranked set, and availability is asked only of the chosen trainer, through available(...), on both the ranked path and the preferred path. So nothing routes past it. an_unavailable_resident_trainer_is_waited_for_never_skipped pins no-preference, preference, and the lane coming back.
  • durable.rs: AwaitingLane holds the bucket. recover_tick dispatches only when lane_serves(base), and the new test pins "another base's lane wakes nothing" and "exactly one job, all 3 examples".

To land, from a trial merge with canary 0dcd2f7 (not pushed):

  1. Textual conflicts, both mechanical:
    • genome/fine_tuning/mod.rs: keep canary's pub(crate) use native_jobs::materialized_defaults; and drop pub mod cuda_lora_adapter;.
    • continuum-rust-tests.yml: drop the cuda_train_test.py line and keep canary's four test-moe-residency.cpp lines.
  2. Semantic, which git won't flag but the compile will. Canary now uses cuda_lora_adapter::PROVIDER_ID in:
    • native_jobs.rs:274, materialized_defaults' provider match;
    • modules/training_trigger/durable.rs tests, around :2470-2513.
      Both need the engine's provider id, or the deleted provider dropped.
  3. A stale reference: forge/mlx_train.rs:705's comment cites genome/fine_tuning/mlx_lora_adapter.rs::lora_config_yaml.

Question, not blocking: on a node where no lane ever serves a base (IntelMac's CPU engine training crashes, card 5b497852), does an AwaitingLane bucket keep taking examples without bound? If yes, it needs a byte bound or an expiry, since everything stored needs a drain.

Author: I'll rebase and carry it if you want. Otherwise it's yours to rebase; I won't touch your branch.

@joelteply

Copy link
Copy Markdown
Contributor Author

Review: #5029 "feat(genome): the engine is the one trainer; with no live lane a job waits, and the Python trainers are deleted" (card 878f100f; Codex)

Decision: SUPERSEDED in part, stale in the rest. Close, and re-cut the Python deletion as a fresh PR on the current crate layout (owner: Cormac, genome). Author: agent (Codex), not a resident.

What I read and ran

Credit. It measured the failure (Kimi's job 7abf8ea4 went to Python and was killed by reboot with empty adapters). It also designed "the wait is a wait" correctly: AwaitingLane as a phase, woken by a lane serving this base.

Open question for the owner. #5356 kept the Python trainers behind a readiness probe. This PR deletes them ("Python can't be part of code", Joel 10-13; ONE-RESIDENT-MODEL: the engine is the one trainer). That is a design decision for Cormac. If deletion is still the direction, re-cut it as a fresh PR on continuum-genome/continuum-dreaming, reusing this PR's AwaitingLane phase design.

Verdict line: SUPERSEDED (fallback, by #5356) plus stale (16 conflicts). Verified by reading canary cuda_lora_adapter.rs:83 and coordinator.rs:167.

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