Files
OBLITERATUS/docs/distributed-two-host-protocol.md
T
Joseph Magly 76e20f2aba test(distributed): cover float E4 receipt and workload values; align two-host docs
Add a receipt with greedy_steps 3.0 and float, string and mismatched
expected workloads to the E4 admission tests. The two-host protocol and
runbook, merged in #691, still said the qualification runner admits only
the E3 reference job; point them at the E4 workload worker and keep its
EXPERIMENTAL, not_qualified status.
2026-11-27 15:39:21 -05:00

10 KiB

Two-host TP2 cross-host protocol (#287)

Status: EXPERIMENTAL, not_qualified. This note describes the protocol so reviewers can find it in one place. The binding operator contract is the rank-local guide, and it wins wherever the two disagree. This file is not one of the rank_local.POLICY_FILES, so editing it does not change policy_digest().

Problem and chosen option

The schema v1/v2 protocol assumes both ranks can see one attempt tree. Rank 0 creates the attempt directory, the peer opens it, receipts are exchanged through files, model-load-evidence is shared, and EXPORT writers share one sibling destination. Two hosts without a shared filesystem cannot do that.

Of the two options in #287, the code implements the first: collectives instead of shared files. Each rank keeps its storage local. Only bounded, digest-bound records and fixed-size tensor frames cross the Gloo control plane. No peer-supplied pathname is ever opened. The shared-filesystem option remains design-only (plan).

Selection is explicit. The ranks use this protocol only when a schema v3 profile carries rank_storage and the profile matches an exact record in the reviewed registry ci/rank-local-profiles.json (rank_local.config_review). That registry is empty in this repository. Without such a record, v1/v2 behaviour and its refusals are unchanged.

Stage mapping

Shared-file step (v1/v2) Cross-host replacement (v3 rank_storage)
Rank 0 creates the attempt directory, peers open it Each rank runs create_attempt(root, run_id, rank), which creates <run_id>.rank-<rank> with O_EXCL, mode 0700, and an fsynced owner.json. Attempts cannot be reused.
Rank-zero nonce and terminal receipts in files exchange_summary phases PREFLIGHTED (seq 1) and PREPARED (seq 2) (preflight.py ~1521, ~2164)
Shared model-load-evidence Load evidence is written privately on each rank, and phase SOURCE_MOUNTS (seq 3) exchanges only source-mount digests (model_session.py ~865)
Writers share one destination tree Rank 0 is the only writer. Every canonical file is streamed to the peer with replicate_file (export.py ~1527).
Rank 0 validates, both ranks reload, rank 0 promotes Each rank validates and reloads its own complete tree independently. Only the coordinator publishes, through DurablePublication (export.py ~1721).
Qualification envelope Phase QUALIFICATION (seq 10) (rank_local_qualification.py ~70)

Message formats

All control records travel as canonical JSON (sorted keys, no NaN) through consensus.gloo_all_gather_records with a fixed byte capacity. A receiver checks that a record is a dict with exactly the expected keys and integer-typed integers, and that its canonical re-encoding equals the bytes received.

Summary record (capacity 8192 bytes, world size 2):

{"schema_version": 1, "run_id": "<run_id>", "identity": "<64-hex lifecycle digest>",
 "rank": 0, "phase": "PREFLIGHTED", "sequence": 1, "payload": {}}

Each gathered row must match the local run_id, identity, phase and sequence, and its rank must equal its position in the gather. Anything else raises ContractError ("stale, forged or out of phase"). The PREFLIGHTED payload is exactly {attestation_digest, mapping_digest, root_identity, attempt_identity}. Its attestation digest must equal the attested membership, and its mapping digest must equal rank_storage.mapping_digest.

Chunk record (capacity 1024 bytes), sent with each frame:

{"schema_version": 1, "identity": "<export identity>", "file_digest": "<sha256 of file>",
 "offset": 0, "size": 32768, "total": 1048576, "chunk_digest": "<sha256 of chunk>"}

The data travels as a uint8 tensor of exactly CHUNK_BYTES (32 KiB) through dist.broadcast(src=0). The receiver rejects a frame when the record differs from the expected one, when the offset is not chunk-aligned, when it overruns total, or when the padding past size is nonzero.

Vote sequence for one file

Every fallible local step ends in a unanimous_vote, in the same order on both ranks:

  1. Continue vote: cancellation first, then deadline.
  2. Prepare: rank 0 opens the source read-only and checks its size and link count. The receiver opens the target with O_CREAT|O_EXCL|O_NOFOLLOW beneath retained O_DIRECTORY|O_NOFOLLOW descriptors.
  3. For each chunk: a prepare vote, a continue vote, the record gather and frame broadcast, then a validate-and-append vote and another continue vote.
  4. Finalize: both ranks compare the complete SHA-256 with file_digest. The receiver sets the file read-only and fsyncs it. Rank 0 checks that its source inode did not change. Then a final vote and a continue vote.

A failed vote stops both ranks at the same step. No rank goes on alone.

Atomicity and promotion

Only the coordinator publishes. DurablePublication takes an exclusive fence directory .<output>.rank-local-fence and creates the state directory .<output>.rank-local-state-<export_id> and the staging directory .<output>.rank-local-stage-<export_id>. It writes append-only, fsynced phase records: PREPARED, STAGED, PROMOTION_INTENT, BACKED_UP, PROMOTED, COMMIT_DECIDED, ACKNOWLEDGED, COMPLETE, or ABORTED, UNCERTAIN or RETURN_UNCERTAIN.

The previous output moves to .<output>.rank-local-backup-<export_id> and stays there until both ranks agree on readiness. COMMIT_DECIDED is the irrevocable commit point. It is not atomic across ranks or across process death:

  • Before PROMOTION_INTENT, a failure aborts: the coordinator removes the staging directory, writes ABORTED and removes the fence. The prior output is untouched, both ranks return the failing step's error (never success), and, once PREPARED exists, recovery_inventory() reports outcome not_published.
  • From PROMOTION_INTENT until COMMIT_DECIDED, a failure returns LMS_EXPORT_STATE_UNCERTAIN. The coordinator writes UNCERTAIN (or, if it died, writes nothing more) and keeps the fence, any backup and the state records. The inventory reports outcome uncertain with decision undecided.
  • After COMMIT_DECIDED, the commit stands, but returns are still not atomic. A rank whose step fails, or the survivor of a coordinator death, returns LMS_EXPORT_STATE_UNCERTAIN; the coordinator writes RETURN_UNCERTAIN if it fails after the decision. Until COMPLETE is written, the inventory reports outcome uncertain with decision commit, and the fence stays. If the coordinator reaches COMPLETE and only a peer's acknowledgement was lost, the coordinator returns success, the peer returns LMS_EXPORT_STATE_UNCERTAIN, and the inventory reports complete with no fence.

recovery_inventory() reports these states but does not repair anything.

Failure handling (fail closed)

Every row below is covered by multi-process Gloo tests on CPU, each rank with its own non-shared directory. _candidate_worker raises if a rank opens a path under its peer's root.

Failure Outcome Test (tests/test_distributed_rank_local_gloo.py)
Rank dies during preflight, writing, replication or reload Survivor returns an error, never success test_rank_death_is_bounded_and_never_claims_success[*_rank_death]
Coordinator killed at each publication state from PROMOTION_INTENT through ACKNOWLEDGED Survivor returns LMS_EXPORT_STATE_UNCERTAIN, and inventory reports uncertain (decision commit once COMMIT_DECIDED is written) ...[crash_PROMOTION_INTENT…crash_ACKNOWLEDGED]
Corrupt, truncated or replayed chunk (digest mismatch or partial transfer) Both ranks report an error, and the prior output is kept test_candidate_failure_matrix_fails_closed[corrupt_chunk, truncated_chunk, replayed_chunk]
Source truncated mid-stream, deadline, cancellation, cancellation callback fails on one rank Both refuse at the same frame boundary test_streaming_multiple_fixed_frames_and_midstream_truncation
Forged, stale or poisoned summary Both ranks refuse test_collective_summary_rejects_poison_stale_and_forged_records
Wrong storage observation or profile, resource denial, load, reload or tokenizer/index corruption, root replacement Error, and foreign or prior trees are kept test_candidate_failure_matrix_fails_closed
Peer cleanup fails before the decision Both ranks return LMS_EXPORT_STATE_UNCERTAIN; fence and backup kept, decision undecided, a competing publisher is blocked test_peer_cleanup_failure_…
Peer acknowledgement lost after the decision Coordinator returns success, peer returns LMS_EXPORT_STATE_UNCERTAIN; inventory reports complete with decision commit and no fence test_post_decision_lost_ack_…
Directory swapped for a symlink during replication No write lands outside the root ...[intermediate_symlink]

Refusals that remain

LMS_TOPOLOGY_UNSUPPORTED (preflight layout admission), LMS_TP_PLAN_UNSUPPORTED (load) and LMS_EXPORT_TOPOLOGY_UNSUPPORTED (EXPORT entry votes 17_000_071 and 17_000_072) still refuse two-host v1/v2 configs, configs without a reviewed rank_storage record, and any disagreement between ranks about layout. Lifting them further would make the reviewed registry optional, which would weaken the integrity guarantee. That decision belongs to the maintainers.

Remaining work

  • Physical work: same-candidate E2, two-host E3 and over-capacity E4 evidence, following the runbook.
  • Software for E4: scripts/run_rank_local_qualification.py also admits a fully bound E4 workload job, and StreamingLlamaReference builds its pristine reference one leaf module at a time; see the E4 workload worker. It is EXPERIMENTAL and not_qualified until physical E4 evidence is reviewed. rank_local_qualification and the checker enforce the E4 capacity rule.
  • Issue item 3 (refreshing PROBE RAM observations) is tracked separately. The correction delivered with the shared-storage review covers part of it.