mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-05 02:24:12 +01:00
Review r2: "stage budgets + one stalled collective" only holds where a cooperative deadline is checked. PROBE's DISTILL tail, surgery's post-EXCISE restoration and VERIFY's rollback run unchecked. Restore the pre-PR process-group timeouts (VERIFY 4 s; PROBE, surgery and model 5 s). The observed flake was the 5 s EXCISE stage budget, and the original collective limits held under the same load. Each reaper is now checked stage budgets + (collectives outside stage clocks + each unchecked interval + each stage's longest overshoot interval) x collective timeout + one stalled collective + exit. Counts are named constants with production source pointers: model 45 s, PROBE 520 s, surgery 695 s, VERIFY 914 s, VERIFY rank-exit setup 638 s. The short oracles are unchanged from r2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
590 lines
25 KiB
Python
590 lines
25 KiB
Python
"""Real two-rank CPU/Gloo manifest consensus tests for issue 60."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import multiprocessing as mp
|
|
import json
|
|
import time
|
|
from dataclasses import replace
|
|
from datetime import timedelta
|
|
from contextlib import ExitStack, contextmanager, nullcontext
|
|
from pathlib import Path
|
|
from queue import Empty
|
|
from types import SimpleNamespace
|
|
from unittest.mock import PropertyMock, patch
|
|
|
|
import pytest
|
|
import torch
|
|
import torch.distributed as dist
|
|
from transformers import LlamaConfig
|
|
|
|
import obliteratus.distributed.model as model_module
|
|
import obliteratus.distributed.model_session as session_module
|
|
import obliteratus.distributed.preflight as preflight_module
|
|
from obliteratus.distributed.consensus import (
|
|
gather_failure_codes,
|
|
gloo_all_gather_records,
|
|
require_consensus_digest,
|
|
require_record_consensus,
|
|
)
|
|
from obliteratus.distributed.contracts import ContractError, RuntimeStage, canonical_record
|
|
from obliteratus.distributed.model import LLAMA_BF16_TP2_PROFILE, build_parameter_manifest
|
|
from obliteratus.distributed.model_session import _prepare_evidence_directory
|
|
from obliteratus.distributed.model_topology import TP2DeploymentLayout
|
|
from tests.test_distributed_gloo import _FixedProbes, _preflight_config
|
|
from tests.test_distributed_model_session_contracts import _exact
|
|
|
|
|
|
pytestmark = pytest.mark.gloo
|
|
|
|
WORLD_SIZE = 2
|
|
|
|
# Keep the original short collective failure detector: the observed load flake
|
|
# was the EXCISE stage budget. Allow cold starts separately from this window.
|
|
# With no checked stages, the ordinary reaper covers all three sequential gathers
|
|
# plus exit: a pacing/hang-guard envelope, not an expected duration. Prompt-failure
|
|
# tests keep their short bounds.
|
|
_COLD_START_TIMEOUT_SECONDS = 60.0
|
|
_COLLECTIVE_TIMEOUT_SECONDS = 5
|
|
_FAILURE_COLLECTIVE_TIMEOUT_SECONDS = 5
|
|
_WORKER_EXIT_TIMEOUT_SECONDS = 30.0
|
|
# test_distributed_model_gloo.py:_worker — manifest, record-consensus, plan gathers.
|
|
_ORDINARY_COLLECTIVE_COUNT = 3
|
|
# 3 unchecked gathers * 5 + 30 exit = 45 (no stage or cooperative-check overshoot).
|
|
_WORKER_TIMEOUT_SECONDS = (
|
|
_ORDINARY_COLLECTIVE_COUNT * _COLLECTIVE_TIMEOUT_SECONDS + _WORKER_EXIT_TIMEOUT_SECONDS
|
|
)
|
|
|
|
|
|
class _CpuParameter(torch.nn.Parameter):
|
|
@property
|
|
def device(self):
|
|
return torch.device("cuda", 0)
|
|
|
|
|
|
def _local_failure(rank: int, root: Path, mode: str, manifest) -> None:
|
|
if mode.startswith("preflight_"):
|
|
config = _preflight_config(root)
|
|
launch = SimpleNamespace(
|
|
rank=rank, local_rank=0, group_rank=rank, world_size=2, local_world_size=1,
|
|
rendezvous_id=config.rendezvous_id,
|
|
)
|
|
if mode == "preflight_directory_failure":
|
|
preflight_module._prepare_attempt_directory(config, launch)
|
|
elif mode == "preflight_lifecycle_refusal":
|
|
original_validate = preflight_module._validate_stage_messages
|
|
|
|
def validate(*args, **kwargs):
|
|
if rank == 1 and kwargs["stage"] is RuntimeStage.PREFLIGHTED:
|
|
raise ContractError("private lifecycle detail")
|
|
return original_validate(*args, **kwargs)
|
|
|
|
with patch.object(preflight_module, "_validate_stage_messages", validate):
|
|
preflight_module.run_live_preflight(
|
|
config, launch, probes=_FixedProbes(rank, config.software_versions),
|
|
)
|
|
else:
|
|
probes = _FixedProbes(rank, config.software_versions)
|
|
original_attestation = preflight_module._attestation
|
|
|
|
def attestation(*args):
|
|
if rank == 1 and mode == "preflight_attestation_failure":
|
|
raise RuntimeError("injected local attestation preparation failure")
|
|
return original_attestation(*args)
|
|
|
|
if rank == 1 and mode == "preflight_probe_failure":
|
|
def unavailable(*_args):
|
|
raise OSError("injected local probe failure")
|
|
|
|
probes.collect = unavailable
|
|
with patch.object(preflight_module, "_attestation", attestation):
|
|
preflight_module.run_preflight(config, launch, probes=probes)
|
|
elif mode == "model_prepare_failure":
|
|
def prepare(*_args):
|
|
if rank == 1:
|
|
raise RuntimeError("injected local admission failure")
|
|
return SimpleNamespace(manifest=manifest)
|
|
|
|
with patch.object(model_module, "_prepare_local_model", prepare):
|
|
model_module.prepare_distributed_model(None, None, None)
|
|
elif mode == "model_digest_failure":
|
|
with patch.object(type(manifest), "digest", new_callable=PropertyMock) as digest:
|
|
if rank == 1:
|
|
digest.side_effect = RuntimeError("injected local manifest digest failure")
|
|
else:
|
|
digest.return_value = "a" * 64
|
|
model_module._manifest_consensus(manifest, None)
|
|
elif mode == "model_parameter_hash_failure":
|
|
mesh = object()
|
|
parameters = {
|
|
entry.name: _CpuParameter(torch.zeros(entry.local_shape, dtype=torch.bfloat16))
|
|
for entry in manifest.entries
|
|
}
|
|
model = SimpleNamespace(
|
|
tp_plan=LLAMA_BF16_TP2_PROFILE.plan_dict,
|
|
_tp_size=2,
|
|
_device_mesh=mesh,
|
|
named_parameters=lambda **_kwargs: parameters.items(),
|
|
get_submodule=lambda name: SimpleNamespace(_hf_tp_plan=(
|
|
LLAMA_BF16_TP2_PROFILE.plan_dict.get(".".join(
|
|
"*" if item.isdecimal() else item for item in name.split(".")
|
|
))
|
|
)),
|
|
)
|
|
original_digest = model_module.tensor_digest
|
|
|
|
def digest(value):
|
|
if rank == 1:
|
|
raise ContractError("injected local parameter hash failure")
|
|
return original_digest(value)
|
|
|
|
with patch.object(model_module, "tensor_digest", digest):
|
|
model_module._validate_loaded_model(
|
|
model, manifest, LLAMA_BF16_TP2_PROFILE,
|
|
SimpleNamespace(rank=rank, local_rank=0), mesh, None,
|
|
)
|
|
elif mode in {"session_evidence_allocation_failure", "session_evidence_callback_failure"}:
|
|
original_tensor = torch.tensor
|
|
original_callback = session_module.ExitStack.callback
|
|
original_open = session_module.os.open
|
|
opened: list[int] = []
|
|
|
|
def allocate(*args, **kwargs):
|
|
if (
|
|
rank == 1 and mode == "session_evidence_allocation_failure"
|
|
and kwargs.get("dtype") is torch.int32 and kwargs.get("device") == "cpu"
|
|
):
|
|
raise MemoryError("private evidence tensor allocation failure")
|
|
return original_tensor(*args, **kwargs)
|
|
|
|
def register(stack, callback, *args, **kwargs):
|
|
if (
|
|
rank == 1 and mode == "session_evidence_callback_failure"
|
|
and callback is session_module.os.close
|
|
):
|
|
raise RuntimeError("private evidence cleanup registration failure")
|
|
return original_callback(stack, callback, *args, **kwargs)
|
|
|
|
def open_descriptor(*args, **kwargs):
|
|
descriptor = original_open(*args, **kwargs)
|
|
opened.append(descriptor)
|
|
return descriptor
|
|
|
|
with (
|
|
patch.object(torch, "tensor", allocate),
|
|
patch.object(session_module.ExitStack, "callback", register),
|
|
patch.object(session_module.os, "open", open_descriptor),
|
|
patch.object(dist, "all_reduce", wraps=dist.all_reduce) as reduction,
|
|
):
|
|
try:
|
|
_prepare_evidence_directory(root, SimpleNamespace(rank=rank))
|
|
finally:
|
|
reduction.assert_not_called()
|
|
assert len(opened) == 1
|
|
for descriptor in opened:
|
|
with pytest.raises(OSError):
|
|
session_module.os.fstat(descriptor)
|
|
elif mode == "session_lifecycle_preparation_failure":
|
|
original_digest = session_module.contract_digest
|
|
|
|
def digest(value):
|
|
if rank == 1:
|
|
raise RuntimeError("injected local lifecycle preparation failure")
|
|
return original_digest(value)
|
|
|
|
with patch.object(session_module, "contract_digest", digest):
|
|
session_module._emit_loaded_messages(
|
|
SimpleNamespace(run_id="1" * 32, world_size=2), SimpleNamespace(rank=rank),
|
|
SimpleNamespace(lifecycle_identity_digest="a" * 64), "b" * 64,
|
|
)
|
|
elif mode in {
|
|
"session_mesh_preparation_failure", "session_mesh_identity_failure",
|
|
"session_mesh_identity_refusal",
|
|
}:
|
|
group = object()
|
|
mesh = SimpleNamespace(
|
|
get_group=lambda _name: group, ndim=1, size=lambda: 2, device_type="cuda",
|
|
mesh=SimpleNamespace(tolist=lambda: [0, 1]), get_local_rank=lambda _name: rank,
|
|
)
|
|
original_digest = session_module.contract_digest
|
|
|
|
def layout(*_args):
|
|
if rank == 1 and mode == "session_mesh_preparation_failure":
|
|
raise RuntimeError("injected local mesh preparation failure")
|
|
return TP2DeploymentLayout.LOCAL_TP2
|
|
|
|
def digest(value):
|
|
if rank == 1 and mode == "session_mesh_identity_failure":
|
|
raise RuntimeError("injected local mesh identity failure")
|
|
return original_digest(value)
|
|
|
|
with ExitStack() as stack:
|
|
stack.enter_context(patch.object(session_module, "configured_tp2_layout", layout))
|
|
stack.enter_context(patch.object(session_module, "contract_digest", digest))
|
|
stack.enter_context(patch.object(
|
|
session_module, "_bounded_destroy_data_group", lambda *_a, **_k: None,
|
|
))
|
|
stack.enter_context(patch(
|
|
"torch.distributed.device_mesh.init_device_mesh", return_value=mesh,
|
|
))
|
|
ranks = [1, 0] if rank == 1 and mode == "session_mesh_identity_refusal" else [0, 1]
|
|
stack.enter_context(patch.object(dist, "get_process_group_ranks", return_value=ranks))
|
|
stack.enter_context(patch.object(
|
|
dist, "get_backend", lambda candidate=None: "nccl" if candidate is group else "gloo",
|
|
))
|
|
with session_module.exact_nccl_data_plane(
|
|
SimpleNamespace(teardown_timeout_seconds=1), SimpleNamespace(rank=rank),
|
|
):
|
|
raise AssertionError("failed mesh preparation must not yield")
|
|
elif mode.startswith("session_"):
|
|
@contextmanager
|
|
def plane(*_args, **_kwargs):
|
|
yield session_module.DataPlane(group=object(), device_mesh=object(), digest="a" * 64)
|
|
|
|
def prepare(*_args, **_kwargs):
|
|
if rank == 1 and mode == "session_preload_failure":
|
|
raise RuntimeError("injected local preload binding failure")
|
|
return {}
|
|
|
|
def bind(*_args, **_kwargs):
|
|
if rank == 1 and mode == "session_handle_binding_failure":
|
|
raise RuntimeError("injected local handle binding failure")
|
|
return {}
|
|
|
|
def publish(*_args, **_kwargs):
|
|
if mode.startswith("session_evidence_"):
|
|
raise AssertionError("failed evidence cleanup must precede publication")
|
|
if rank == 1 and mode == "session_publish_failure":
|
|
raise OSError("injected local evidence publication failure")
|
|
return object()
|
|
|
|
def evidence_directory(*args):
|
|
if not mode.startswith("session_evidence_"):
|
|
return root
|
|
original_close = session_module.os.close
|
|
close_count = 0
|
|
failed_close = 1 if mode == "session_evidence_child_close_failure" else 2
|
|
|
|
def close_descriptor(descriptor):
|
|
nonlocal close_count
|
|
close_count += 1
|
|
original_close(descriptor)
|
|
if rank == 1 and close_count == failed_close:
|
|
raise OSError("private evidence descriptor close failure")
|
|
|
|
with patch.object(session_module.os, "close", close_descriptor):
|
|
return _prepare_evidence_directory(*args)
|
|
|
|
def forbidden(*_args, **_kwargs):
|
|
raise AssertionError("failed local publication must precede summary consensus")
|
|
|
|
with patch.multiple(
|
|
session_module,
|
|
ProcessHardWatchdog=lambda *_args, **_kwargs: nullcontext(),
|
|
runtime_diagnostic_guard=lambda **_kwargs: nullcontext(),
|
|
control_group=lambda *_args: nullcontext(),
|
|
run_live_preflight=lambda *_args, **_kwargs: SimpleNamespace(attempt_path=root),
|
|
verify_source_mount_attestation=lambda *_args: "a" * 64,
|
|
_control_group_identity=lambda *_args: (None, "a" * 64),
|
|
_validate_preload_bindings=prepare,
|
|
_validate_handle_bindings=bind,
|
|
_complete_evidence_bindings=lambda *_args: {},
|
|
_prepare_evidence_directory=evidence_directory,
|
|
build_rank_load_evidence=lambda **_kwargs: {},
|
|
publish_rank_load_evidence=publish,
|
|
_gather_load_summaries=forbidden,
|
|
):
|
|
with session_module.live_model_session(
|
|
SimpleNamespace(teardown_timeout_seconds=1, run_id="1" * 32),
|
|
SimpleNamespace(rank=rank, world_size=2), _exact(),
|
|
protocol_loader=lambda *_args, **_kwargs: SimpleNamespace(
|
|
manifest=SimpleNamespace(to_dict=lambda: {})
|
|
),
|
|
protocol_data_plane=plane,
|
|
):
|
|
raise AssertionError("failed session preparation must not yield")
|
|
else:
|
|
raise AssertionError(f"unknown local failure mode {mode}")
|
|
|
|
|
|
def _config() -> LlamaConfig:
|
|
config = LlamaConfig(
|
|
vocab_size=32,
|
|
hidden_size=16,
|
|
intermediate_size=32,
|
|
num_hidden_layers=1,
|
|
num_attention_heads=4,
|
|
num_key_value_heads=2,
|
|
max_position_embeddings=32,
|
|
attention_dropout=0.0,
|
|
tie_word_embeddings=False,
|
|
bos_token_id=1,
|
|
eos_token_id=2,
|
|
pad_token_id=0,
|
|
)
|
|
config.architectures = ["LlamaForCausalLM"]
|
|
config.dtype = "bfloat16"
|
|
return config
|
|
|
|
|
|
def _worker(rank: int, rendezvous: str, mode: str, queue: mp.Queue, ready: mp.Event) -> None:
|
|
preparation_votes: list[tuple[int, bool]] = []
|
|
try:
|
|
dist.init_process_group(
|
|
"gloo",
|
|
init_method=f"file://{rendezvous}",
|
|
rank=rank,
|
|
world_size=WORLD_SIZE,
|
|
timeout=timedelta(
|
|
seconds=(
|
|
_FAILURE_COLLECTIVE_TIMEOUT_SECONDS
|
|
if mode in {"hang", "evidence_mkdir_failure"}
|
|
or mode.startswith(("preflight_", "model_", "session_"))
|
|
else _COLLECTIVE_TIMEOUT_SECONDS
|
|
)
|
|
),
|
|
)
|
|
manifest = build_parameter_manifest(
|
|
_config(),
|
|
profile=LLAMA_BF16_TP2_PROFILE,
|
|
rank=rank,
|
|
world_size=WORLD_SIZE,
|
|
)
|
|
plan_digest = LLAMA_BF16_TP2_PROFILE.plan_digest
|
|
if mode == "plan_drift" and rank == 1:
|
|
plan_digest = "f" * 64
|
|
if mode == "manifest_drift" and rank == 1:
|
|
first = replace(manifest.entries[0], global_shape=(1,))
|
|
manifest = replace(manifest, entries=(first, *manifest.entries[1:]))
|
|
# Exclude interpreter/import/process-group cold start from the bounded
|
|
# collective-operation window measured by the parent process.
|
|
ready.set()
|
|
if mode == "evidence_mkdir_failure":
|
|
_prepare_evidence_directory(Path(rendezvous).parent, SimpleNamespace(rank=rank))
|
|
queue.put((rank, "ok", None))
|
|
return
|
|
if mode.startswith(("preflight_", "model_", "session_")):
|
|
def vote(sequence, code, **kwargs):
|
|
preparation_votes.append((sequence, code is None))
|
|
return gather_failure_codes(sequence, code, **kwargs)
|
|
|
|
with ExitStack() as stack:
|
|
for module in (preflight_module, model_module, session_module):
|
|
stack.enter_context(patch.object(module, "gather_failure_codes", vote))
|
|
_local_failure(rank, Path(rendezvous).parent, mode, manifest)
|
|
queue.put((rank, "unexpected", None))
|
|
return
|
|
if mode == "hang" and rank == 1:
|
|
time.sleep(7)
|
|
payloads = gloo_all_gather_records(manifest.consensus_record())
|
|
manifests = tuple(json.loads(item) for item in payloads)
|
|
require_record_consensus(manifest.consensus_record())
|
|
plan_digest = require_consensus_digest(plan_digest)
|
|
logical = {
|
|
item.name: tuple(
|
|
(candidate.rank, candidate.start, candidate.end) for candidate in item.rank_shards
|
|
)
|
|
for item in manifest.entries
|
|
}
|
|
queue.put((rank, "ok", (plan_digest, logical, canonical_record(manifests))))
|
|
except Exception as exc:
|
|
payload = (type(exc).__name__, str(exc), getattr(exc, "code", None))
|
|
if preparation_votes:
|
|
payload = (*payload, preparation_votes)
|
|
queue.put((rank, "error", payload))
|
|
finally:
|
|
if dist.is_available() and dist.is_initialized():
|
|
dist.destroy_process_group()
|
|
|
|
|
|
def _run(
|
|
tmp_path: Path,
|
|
mode: str,
|
|
*,
|
|
timeout: float = _WORKER_TIMEOUT_SECONDS,
|
|
measured_seconds: list[float] | None = None,
|
|
):
|
|
context = mp.get_context("spawn")
|
|
queue = context.Queue()
|
|
rendezvous = tmp_path / f"{mode}-{time.monotonic_ns()}.rendezvous"
|
|
if mode == "evidence_mkdir_failure":
|
|
# Rank 0 must fail closed rather than reuse an existing evidence directory.
|
|
(tmp_path / "model-load-evidence").mkdir(mode=0o700)
|
|
if mode == "preflight_directory_failure":
|
|
(tmp_path / "staging" / ("1" * 32)).mkdir(mode=0o700, parents=True)
|
|
ready = [context.Event() for _rank in range(WORLD_SIZE)]
|
|
processes = [
|
|
context.Process(
|
|
target=_worker,
|
|
args=(rank, str(rendezvous), mode, queue, ready[rank]),
|
|
)
|
|
for rank in range(WORLD_SIZE)
|
|
]
|
|
for process in processes:
|
|
process.start()
|
|
cold_start_deadline = time.monotonic() + _COLD_START_TIMEOUT_SECONDS
|
|
for event in ready:
|
|
if not event.wait(max(0.0, cold_start_deadline - time.monotonic())):
|
|
for process in processes:
|
|
if process.is_alive():
|
|
process.terminate()
|
|
process.join(3)
|
|
pytest.fail(f"{mode} workers did not become ready within the cold-start bound")
|
|
operation_started = time.monotonic()
|
|
operation_deadline = operation_started + timeout
|
|
for process in processes:
|
|
process.join(max(0.0, operation_deadline - time.monotonic()))
|
|
if process.is_alive():
|
|
process.terminate()
|
|
process.join(3)
|
|
pytest.fail(f"{mode} worker did not terminate within the test bound")
|
|
assert process.exitcode == 0
|
|
if measured_seconds is not None:
|
|
measured_seconds.append(time.monotonic() - operation_started)
|
|
results = []
|
|
for _ in range(WORLD_SIZE):
|
|
try:
|
|
results.append(queue.get(timeout=2))
|
|
except Empty:
|
|
pytest.fail(f"{mode} did not report one result per rank")
|
|
queue.close()
|
|
queue.join_thread()
|
|
return sorted(results)
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def manifest_success_results(tmp_path_factory):
|
|
return _run(tmp_path_factory.mktemp("manifest-success"), "success")
|
|
|
|
|
|
def test_two_rank_manifest_consensus_tiles_every_sharded_parameter(manifest_success_results):
|
|
results = manifest_success_results
|
|
assert [status for _rank, status, _payload in results] == ["ok", "ok"]
|
|
assert {payload[0] for _rank, _status, payload in results} == {
|
|
LLAMA_BF16_TP2_PROFILE.plan_digest
|
|
}
|
|
for _rank, _status, (_plan, logical, _record) in results:
|
|
for name, intervals in logical.items():
|
|
if all(start == end == 0 for _owner, start, end in intervals):
|
|
assert {owner for owner, _start, _end in intervals} == {0, 1}
|
|
continue
|
|
ordered = sorted(intervals)
|
|
assert ordered[0][1] == 0
|
|
assert ordered[0][2] == ordered[1][1]
|
|
assert ordered[1][2] > ordered[1][1]
|
|
|
|
|
|
def test_rank_local_manifest_serialization_is_deterministic(tmp_path, manifest_success_results):
|
|
first = manifest_success_results
|
|
second = _run(tmp_path, "success")
|
|
for results in (first, second):
|
|
assert [status for _rank, status, _payload in results] == ["ok", "ok"]
|
|
assert [payload[2] for _rank, _status, payload in first] == [
|
|
payload[2] for _rank, _status, payload in second
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize("mode", ["plan_drift", "manifest_drift"])
|
|
def test_plan_or_manifest_drift_fails_on_every_rank(tmp_path, mode):
|
|
results = _run(tmp_path, mode)
|
|
assert [status for _rank, status, _payload in results] == ["error", "error"]
|
|
assert all(payload[0] == ContractError.__name__ for _rank, _status, payload in results)
|
|
|
|
|
|
def test_rank_hang_is_bounded_and_never_becomes_success(tmp_path):
|
|
measured_seconds: list[float] = []
|
|
results = _run(tmp_path, "hang", timeout=12, measured_seconds=measured_seconds)
|
|
assert len(measured_seconds) == 1 and measured_seconds[0] < 12
|
|
assert [status for _rank, status, _payload in results] == ["error", "error"]
|
|
|
|
|
|
def test_rank_zero_evidence_mkdir_failure_is_prompt_and_symmetric(tmp_path):
|
|
measured_seconds: list[float] = []
|
|
results = _run(tmp_path, "evidence_mkdir_failure", timeout=4, measured_seconds=measured_seconds)
|
|
|
|
assert measured_seconds[0] < 4 # Below the five-second process-group timeout.
|
|
assert [status for _rank, status, _payload in results] == ["error", "error"]
|
|
assert results[0][2] == results[1][2]
|
|
assert results[0][2][2] == "LMS_LOAD_EVIDENCE_UNAVAILABLE"
|
|
|
|
|
|
@pytest.mark.parametrize("mode", [
|
|
"session_evidence_allocation_failure", "session_evidence_callback_failure",
|
|
])
|
|
def test_one_rank_evidence_preparation_failure_votes_before_all_reduce(tmp_path, mode):
|
|
measured_seconds: list[float] = []
|
|
results = _run(tmp_path, mode, timeout=4, measured_seconds=measured_seconds)
|
|
|
|
assert measured_seconds[0] < 4 # Below the five-second process-group timeout.
|
|
assert [status for _rank, status, _payload in results] == ["error", "error"]
|
|
assert results[0][2][:3] == results[1][2][:3]
|
|
for rank, _status, payload in results:
|
|
assert payload[2] == "LMS_LOAD_EVIDENCE_UNAVAILABLE"
|
|
assert "private" not in payload[1]
|
|
assert payload[3] == [(52, rank != 1), (44, False)]
|
|
|
|
|
|
@pytest.mark.parametrize("mode", [
|
|
"session_evidence_child_close_failure", "session_evidence_parent_close_failure",
|
|
])
|
|
def test_one_rank_evidence_close_failure_votes_before_publication(tmp_path, mode):
|
|
measured_seconds: list[float] = []
|
|
results = _run(tmp_path, mode, timeout=4, measured_seconds=measured_seconds)
|
|
|
|
assert measured_seconds[0] < 4
|
|
assert [status for _rank, status, _payload in results] == ["error", "error"]
|
|
for rank, _status, payload in results:
|
|
assert payload[2] == "LMS_LOAD_EVIDENCE_UNAVAILABLE"
|
|
assert "private" not in payload[1]
|
|
assert payload[3][-1] == (44, rank != 1)
|
|
assert all(sequence != 43 for sequence, _accepted in payload[3])
|
|
|
|
|
|
@pytest.mark.parametrize("mode", [
|
|
"preflight_directory_failure", "preflight_probe_failure", "preflight_attestation_failure",
|
|
"model_prepare_failure", "model_digest_failure", "model_parameter_hash_failure",
|
|
"session_lifecycle_preparation_failure", "session_preload_failure",
|
|
"session_handle_binding_failure", "session_publish_failure",
|
|
"session_mesh_preparation_failure", "session_mesh_identity_failure",
|
|
])
|
|
def test_rank_local_preparation_failures_vote_before_the_next_collective(tmp_path, mode):
|
|
measured_seconds: list[float] = []
|
|
results = _run(tmp_path, mode, timeout=4, measured_seconds=measured_seconds)
|
|
assert measured_seconds[0] < 4
|
|
assert [status for _rank, status, _payload in results] == ["error", "error"]
|
|
assert all(payload[2] is not None and payload[2].startswith("LMS_")
|
|
for _rank, _status, payload in results)
|
|
assert len({payload[2] for _rank, _status, payload in results}) == 1
|
|
sequence = {
|
|
"preflight_directory_failure": 10,
|
|
"preflight_probe_failure": 16,
|
|
"preflight_attestation_failure": 16,
|
|
"model_prepare_failure": 31,
|
|
"model_digest_failure": 30,
|
|
"model_parameter_hash_failure": 32,
|
|
"session_lifecycle_preparation_failure": 45,
|
|
"session_preload_failure": 40,
|
|
"session_handle_binding_failure": 42,
|
|
"session_publish_failure": 43,
|
|
"session_mesh_preparation_failure": 50,
|
|
"session_mesh_identity_failure": 51,
|
|
}[mode]
|
|
failed_rank = 0 if mode == "preflight_directory_failure" else 1
|
|
for rank, _status, payload in results:
|
|
assert (sequence, rank != failed_rank) in payload[3]
|
|
|
|
|
|
@pytest.mark.parametrize(("mode", "sequence", "code"), [
|
|
("preflight_lifecycle_refusal", 24, "LMS_CONSENSUS_RECORD_INVALID"),
|
|
("session_mesh_identity_refusal", 51, "LMS_LOAD_PROFILE_MISMATCH"),
|
|
])
|
|
def test_rank_local_contract_refusals_keep_closed_codes_and_vote(tmp_path, mode, sequence, code):
|
|
measured_seconds: list[float] = []
|
|
results = _run(tmp_path, mode, timeout=4, measured_seconds=measured_seconds)
|
|
assert measured_seconds[0] < 4
|
|
assert [status for _rank, status, _payload in results] == ["error", "error"]
|
|
for rank, _status, payload in results:
|
|
assert payload[2] == code
|
|
assert "private" not in payload[1]
|
|
assert payload[3][-1] == (sequence, rank != 1)
|