Skip to content

The capacity beacon names the bases a peer may lease training to this node for (card 6f05b89d, S1) - #5356

Merged
joelteply merged 7 commits into
canaryfrom
6f05b89d/advertise-training
Oct 24, 2026
Merged

joelteply merged 7 commits into
canaryfrom
6f05b89d/advertise-training

Conversation

@joelteply

@joelteply joelteply commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Card 6f05b89d, slice S1 of grid training. This serves the learning line: IntelMac's residents have no trainer, so a reviewed correction never becomes a gene there. The first step is that the grid knows who can train. The design for all slices is in the card body (S2 grid-peer trainer, S3 artifact return, S4 pending-gene adoption).

  • CapacityOffer.trainable_bases (gossip.rs, wire name trainableBases, serde default). It lists the served base when a trainer on THIS host would accept a LoRA job for it: either its resident weights or its own copy. A grid-peer or cloud trainer never counts, so a node never advertises training it would only pass on. An older core advertises nothing, which reads as "trains nothing", never "all".

  • FineTuningCoordinator::trains_base_here uses the same gate select uses. The hardware and prefix half of caps_match is now runs_base_here, shared by both, so there is no second selection rule.

  • GridCapacityModule asks the genome module at offer time through the module registry, which is installed in initialize. The order modules initialize in never matters. With no genome module, nothing is trainable here.

  • Usable, not merely registered (Codex's reviews). The MLX and CUDA trainers kept the default serves_base = true, and an existing interpreter file proves nothing. So they were selected, and would have been advertised, for jobs they cannot run.

    • PythonTrainerReadiness (new file) is the trainer owner's cached answer. When the trainer is built, a background thread runs python -c "import ..." once: import mlx_lm for MLX, and torch plus the packages in cuda-requirements.txt for CUDA.
    • Until the probe answers yes the trainer is not ready, so no guessed timeout decides it, and a hung import stays unadvertised.
    • Nothing runs per beacon or per selection, and a missing interpreter spawns nothing.
    • serves_base answers with readiness plus the base's trainable HF source.
    • Dependencies installed later take effect at the next core start.

Tests: python_trainer_readiness::tests::an_interpreter_missing_its_dependencies_is_not_a_ready_trainer (fake interpreters, unix), and coordinator::tests::only_a_trainer_on_this_host_makes_a_base_trainable_here. It covers a cloud trainer, a grid-peer trainer, a trainer without LoRA, a trainer for another base, and one that does count.

No consumer yet; S2 selects a peer by this field. No file touched is over 1,000 lines (gossip.rs ends at 887).

ask_python (python_trainer_readiness.rs) is the single owner for asking a trainer's interpreter something. MLX's chat-template probe moved onto it, so spawn sites are unchanged.

Measured

  • Import-probe bound: 120 s. Codex measured the CUDA trainer's imports in a fresh process on the 5090 (Windows, cuda-training venv, under serving load): exit 0 in 28.3 s at 2026-10-24T08:25Z. 120 s is about 4× that observed sample, not a worst case, and exceeding it reads as unavailable. MLX's import mlx_lm on the M5 is still owed (owner Fable, asked); this sample does not bound every machine.
  • The chat-template probe's error line is capped at 2000 characters, not bytes. The runner's capture is the final cap.
  • Windows compilation is SKIPPED by the CI selector for this PR, so a green Windows summary is not a compile receipt. The custody tests are unix-only.

CI at 561c0f0:

  • genome job: 328 passed, 0 failed. These are ok by name:
    • the_import_probe_answers_ready_missing_or_unavailable_and_owns_its_process
    • dropping_the_trainer_ends_a_probe_still_running
    • a_noisy_probe_is_captured_as_nothing
    • only_a_trainer_on_this_host_makes_a_base_trainable_here
  • core job: 2582 passed, 0 failed, warnings 15 (baseline 15);
  • source-hygiene ratchets pass.

Source and CI only; nothing was built on IntelMac. After deploy (owner Cormac): grid/nodes or the beacon on the M5 shows trainableBases equal to its served base, and IntelMac's shows [].

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

joelteply and others added 2 commits October 24, 2026 02:47
… node for (card 6f05b89d, S1)

IntelMac's residents have no trainer, so a reviewed correction never becomes a gene
there. Grid training starts with the grid knowing who can train. CapacityOffer gains
trainable_bases: the served base, when a trainer on THIS host (its resident weights
or its own copy) would accept a LoRA job for it. A grid-peer or cloud trainer never
counts, so a node never advertises training it would only pass on. An older core
advertises nothing (serde default), which reads as "trains nothing".

FineTuningCoordinator::trains_base_here answers it with the same gate select uses:
caps_match's hardware and prefix half is now runs_base_here, shared by both. The
grid-capacity module asks the genome module at offer time through the module
registry, so initialization order never matters. No consumer yet; S2 (the grid-peer
trainer) selects a peer by it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
… never selected, never advertised (card 6f05b89d, S1)

Codex's review of the S1 design: advertise only a trainer that can actually run, not
an adapter that is merely registered with a missing dependency. The MLX and CUDA
trainers kept the default serves_base (true), so the coordinator selected them, and
the beacon would have advertised them, for a job they refuse at create_job: no
interpreter is TrainerUnavailable, and a base whose registry row names no hf_source
is InvalidRequest. Both now answer serves_base with a_python_trainer_serves: the
interpreter is a file, and the base resolves to a trainable source. That is the same
check create_job makes, run before selection instead of after it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply
joelteply force-pushed the 6f05b89d/advertise-training branch from bcb55bf to 7b92320 Compare October 24, 2026 07:47
joelteply and others added 2 commits October 24, 2026 02:58
…cies, probed once (card 6f05b89d, S1)

Codex's review of #5356 at 7b92320: an interpreter file that exists is not a usable
trainer. A venv missing mlx_lm, or the CUDA trainer's packages, would still be selected
and advertised as trainable.

PythonTrainerReadiness (new file) is the trainer owner's cached answer. When the
trainer is built, a background thread runs `python -c "import ..."` once:
`import mlx_lm` for MLX, and torch plus cuda-requirements.txt's packages for CUDA.
Until it answers yes the trainer is not ready, so no guessed timeout decides it, and
a hung import stays unadvertised. Nothing runs per beacon or per selection. A missing
interpreter is never ready and spawns nothing. serves_base asks it, plus the base's
trainable HF source. adapter.rs's file-existence helper is gone.

Test: an interpreter whose imports fail is not ready, a missing one is never ready,
and only a succeeding probe is (fake interpreters, unix).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…e adds no spawn site (card 6f05b89d, S1)

The spawn-site ratchet failed #5356 at 541e226 (job 120819980667: spawn_sites
126 -> 127). The readiness probe was a new Command::new. ask_python
(python_trainer_readiness.rs) is now the one place a trainer spawns its interpreter
to ask something: the readiness import probe, and MLX's chat-template probe, which
dropped its own tokio spawn and runs through spawn_blocking. Spawn sites are back to
canary's count. One behaviour note: a cancelled job now lets that short probe finish
its tokenizer load instead of killing it on drop. It never runs past that load.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@github-actions github-actions Bot added size: L and removed size: M labels Oct 24, 2026
joelteply and others added 3 commits October 24, 2026 03:22
… reaped on drop or bound, output bounded (card 6f05b89d, S1)

Codex's review of #5356 at 4187a9c: ask_python used a blocking
Command::output with no cancellation, bound or output cap. The MLX chat-template
probe lost kill_on_drop, and the readiness probe dropped its handle, so a hung or
noisy probe could hold a process and memory forever.

- ask_python is async and runs under lane_process::run_owned. Dropping it, or
  outliving the bound, ends the interpreter and everything it started and reaps it.
  It answers Exited{output, cut} or Unavailable (could not start, outlived its bound,
  end unconfirmed).
- Readiness has a verdict: Ready, Missing (no interpreter, or its imports failed) or
  Unavailable. A probe that cannot answer is never read as missing dependencies. The
  probe is an owned tokio task, and Drop aborts it, which ends the process.
  Registration now runs inside the runtime (start_server enters rt_handle around it).
- Output bound: the import probe's statement redirects fds 1 and 2 to the null device
  before importing, so nothing is captured. The chat-template probe sends stderr to a
  log in its job directory and keeps only its one-word answer on stdout; a failure
  quotes the log's last 2 KiB.
- The import bound is None until the cold import time is measured on the M5 (mlx_lm)
  and the 5090 (CUDA packages), which I've asked for. Unbounded is still owned: a hung
  import stays unadvertised and ends with its trainer.

Tests (unix): failing imports are Missing, success is Ready, a missing interpreter is
Missing, a probe past a 500 ms bound is Unavailable and its process is gone, and
dropping the readiness ends a probe still running. With a real /usr/bin/python3, 50 MB
printed to both streams is captured as zero bytes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…g (card 6f05b89d, S1)

Codex's review of #5356 at 3e28979: the stderr log was an unlimited file, and the
failure path read all of it to take a 2 KiB tail. The log is gone. probe_chat_template.py
now writes its answer to a private dup of stdout, sends fds 1 and 2 to the null device
before transformers loads (nothing a library prints is captured), and reports a failure
as one line of at most ~2 KiB on the answer channel, exiting 1. The capture is bounded
by construction and run_owned still owns the process. Verified on IntelMac, where
transformers is absent: one line, `error: ModuleNotFoundError("No module named
'transformers'")`, exit 1.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…4x the 5090's 28.3 s (card 6f05b89d, S1)

Codex measured the CUDA trainer's imports in a fresh process on the 5090 (Windows,
cuda-training venv, under serving load): exit 0 in 28.3 s at 2026-10-24T08:25Z. The
production bound is 120 s, about 4x that observed sample (not a worst case). Past it the
probe is ended and readiness is unavailable, never missing. MLX's import on the M5 is
still to be measured.

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

Copy link
Copy Markdown
Contributor Author

Source re-review at 561c0f0 resolves my previous process-custody and unbounded-log blockers: the readiness task retains cancellation ownership through run_owned, the production import probe has a 120-second deadline, timeout remains Unavailable, and the chat-template probe no longer creates or reads an unlimited stderr log. Fresh exact-head CI and the named timeout/drop/noisy-output regressions are still required before integration. Windows compilation is skipped by the current selector; the summary check is not compilation evidence.

The deadline cites my measured Windows trainer import: fresh process, 28.293 seconds, exit 0 at 2026-10-24T08:25Z under serving load. OS cache state was not established and this is not a worst-case bound. M5 import measurement remains explicitly outstanding. The Python diagnostic limit is 2,000 characters rather than precisely 2 KiB; the runner capture limit remains authoritative.

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