Files
OBLITERATUS/docs/distributed-export.md
T
Joseph Magly 002e6e56e1 feat: complete local readiness across UI, MCP and memory admission
Integrate bounded admission, UI ownership and controls, opt-in durable MCP execution, rank-local TP2 groundwork, regression hardening and operator guides. Physical larger-memory and two-host qualification remain separate.
2026-10-20 17:58:20 -04:00

9.4 KiB

EXPERIMENTAL distributed canonical export candidate

Part 5 of upstream issue #244 adds the internal VERIFIED -> STAGED -> PUBLISHED adapter for the exact BF16 Llama TP2 candidate. This remains EXPERIMENTAL: it has no CLI, qualified support row, or evidence of physical multi-host operation. The conditional hardware lane is currently not_qualified. Physical two-host evidence (LMS-E3) and over-one-host-capacity evidence (LMS-E4) remain required; future topology work belongs to part 6 of #244.

The #287 shared-filesystem review explains why marker visibility and a matching mount digest cannot authorize two-host publication. The implemented rank-local candidate instead uses versioned local roots, bounded coordinator replication, independent reload and durable fenced publication. Its exact-profile registry is empty; ordinary two-host refusals remain. Keep ordinary single-host complete-module placement for supported admitted workloads. Do not pass a hand-built two-host runtime or repoint staging to a network mount as a workaround.

Capability boundary

run_live_distributed_export accepts the still-live model session, the exact VerificationResult produced by part 4 VERIFY, an immutable ExportConfig, and a trusted exact-profile semantic-reload validator. The adapter revalidates the live logical parameter roots before staging and again immediately before publication. A changed, stale, rolled-back, already-published, or mismatched capability is rejected.

Version 1 is deliberately closed:

  • world size is exactly two and the model state is BF16;
  • parameters are replicated or evenly sharded on logical dimension 0 or 1;
  • the parameter manifest is complete and agrees with the live named parameters;
  • persistent buffers, tied/aliased storage, scalar tensors, unknown placement, packed/quantized state, and duplicate names refuse before publication; and
  • state_dict() is never used to collect the model.

This is an internal adapter rather than a CLI surface. An exact model adapter must supply the independent reload oracle; there is no generic fallback and semantic reload cannot be disabled.

Bounded reconstruction and resource admission

Assignments are deterministic: logical names sort lexically, sequence n is owned by rank n mod 2, and each tensor receives one unique canonical shard file. Replicated tensors are proven identical. For a sharded tensor, bounded shard broadcasts let its assigned writer construct one complete logical tensor. The complete tensor and receive buffers are dropped before the next assignment. Rank 0 never gathers a complete model.

Before staging, every rank agrees on an admission record covering:

  • live VERIFY/EXCISE host state retained by the caller, plus logical output, copied metadata, and conservative safetensors/header bytes;
  • the previous output that atomic replacement may temporarily retain;
  • the largest logical tensor and local shard;
  • per-rank reconstruction and receive buffers, serialization, independent reload copies, bounded tensor hashing and finite checks, metadata working space, and semantic-reload host/device allowances; and
  • configured safety margin plus currently observed host, device, and staging availability.

The configured output, staging, tensor, metadata-count, metadata-byte, host, device, and deadline limits are hard bounds. File trees also have a 64-directory depth limit and a 131,072-entry limit, checked before publication. Source inspection inventories and parsed header/JSON objects are included in the combined host admission. A parse-free pass reads only safetensors length prefixes and file sizes, reserving 256 bytes per encoded header/JSON byte for overlapping Python objects and copies. Insufficient or unobservable capacity refuses; it is not converted into a smaller or weaker operation.

VERIFY releases its journals before issuing the VERIFIED capability. EXPORT does not rely on journal rollback after that point: failures quarantine the live transaction. The live wrapper returns from VERIFY before EXPORT begins, so its baseline and evaluation snapshots have been released. Callers retaining additional verification baselines or other host tensors must supply their byte reserve through retained_host_bytes; the single voted admission includes that reserve and retained transaction/journal metadata, even though journal files are gone.

Collective failure boundary

Each fallible rank-local step is followed by a unanimous control-group vote before the next collective. EXPORT reserves vote sequences [17_000_000, 24_000_000), disjoint from PROBE, EXCISE, and VERIFY's [10_000_000, 17_000_000) range. The fixed-shape consensus primitives carry a poison payload when a local record cannot be encoded: the failing rank and its peers all fail closed at the same collective. Tensor/file/rank aggregates use versioned, domain-separated streamed SHA-256 records rather than growing one bounded control payload.

Source identities (preflight) and EXCISE aggregates keep their existing bounded-record encodings; their limits are tracked separately (#275, #281). Archived qualification evidence must still be replaced with fresh evidence from this exact candidate.

Primitive-owned fixed-size buffers, deterministic computation over identical gathered bytes, and failures within a TP forward between its own internal collectives are the process-fault boundary. Bounded collective timeouts and rank loss fail closed; they cannot produce successful publication.

Canonical artifact and independent validation

Rank 0 exclusively creates a fresh hidden sibling staging directory. Writers emit one read-only safetensors file per logical tensor with format=pt metadata. Rank 0 copies immutable non-weight configuration/tokenizer files, writes model.safetensors.index.json, and writes a closed distributed-export-manifest.json that binds source, model, tokenizer, code, commit, runtime, storage, topology, placement, surgery, verification, assignment, tensor/file hash, resource-admission, reload, and rank evidence.

Structural validation independently reopens every safetensors file, checks its single key, dtype, shape, header metadata, tensor digest, file digest, index, exact file set, and strict manifest. Every rank must then invoke the supplied semantic validator against the staged directory. The validator must load the canonical model through the exact non-distributed model API, load the tokenizer/configuration, prove the expected key and tensor sets, and compare preregistered logits and deterministic generation. It returns only digests and booleans in ReloadValidationEvidence; raw prompts, tokens, logits, tensors, paths, and exception payloads are not retained.

Atomic publication and failure behavior

Only after structural reload, semantic reload, source and staging-mount revalidation, final live-state revalidation, unanimous STAGED evidence, and a final barrier may rank 0 atomically promote staging to the configured output on the same verified filesystem. A prior valid output remains in place until that rename. Success requires unanimous PUBLISHED lifecycle evidence.

Cancellation and deadlines are checked again immediately before promotion and before returning success. Cleanup or promotion uncertainty produces closed LMS failure codes and a quarantined live transaction, never clean success.

Cancellation, timeout, rank/writer loss, ENOSPC, source change, buffer/tie mismatch, hash/index/manifest disagreement, reload failure, or pre-promotion interruption returns no result and preserves source and prior output. Failed staging is removed. Backup cleanup can fail after partially deleting the old output or after completing deletion but failing a durability sync. That state is uncertain: the promoted destination and any surviving backup are retained for operator inspection, and success is refused. If staging removal cannot be proved, canonical index and safetensors names are invalidated and the hidden attempt is quarantined. The trusted intake path rejects .staging-* and .backup-* directories as model sources. If promotion may have completed but confirmation failed, the state is QUARANTINED and reported as uncertain rather than retried.

A failed export quarantines the live transaction. A retry reloads the immutable source in a new worker group with new run, rendezvous, and 128-bit export identities and a new hidden staging directory. There is no adoption or resumption of prior staging and no reduced-membership fallback. There is no override.

Qualification status

E0 contract tests are provided for closed schemas, bounds, identities, redaction, and symmetric rank-local failures. The two-process CPU/Gloo oracle is provided for replicated, dimension-0, and dimension-1 reconstruction, exact canonical reload, semantic output equality, atomic replacement, cancellation, timeout, rank/coordinator/writer loss, state and source drift, resource refusal, persistent buffers, ties, corruption, cleanup, and fresh-ID retry. The conditional exact Llama lane is wired to reload the staged artifact with LlamaForCausalLM.from_pretrained and retain closed export evidence.

These test definitions do not establish hardware qualification. LMS-E2 must pass on the signed exact candidate, followed by LMS-E3 two-physical-host and LMS-E4 over-one-host-capacity evidence. Until those gates and the upstream publication review pass, the status remains not_qualified and no support row is published.