Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cascade/trainer/lane_c_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,11 @@ def _mkt_arbiters(self, rid: str, block: int, *, entries: int = 1) -> tuple[dict
else:
keep.append({**a, "rid": r, "age": age})
if (entries > 0 or out or keep) and not any(a["rid"] == str(rid) for a in keep):
keep.append({"rid": str(rid), "age": 0, **({"entries": int(entries)}
if entries > 0 else {})})
# the count is recorded even when 0: a round awaited only as a carry
# behind an earlier one has no MarketCast entry of its own, and its
# absence must not read as "?" entries deferred (live 11-27 → 12-02:
# an ERROR at nearly every settlement for candidate-less rounds)
keep.append({"rid": str(rid), "age": 0, "entries": int(entries)})
return out, keep

def _arbiters(self, rid: str, block: int) -> tuple[dict, dict]:
Expand Down
63 changes: 63 additions & 0 deletions tests/unit/test_marketcast_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,69 @@ def _finish(hk, n):
assert not published


def test_candidate_less_carry_round_times_out_as_warning_not_error(tmp_path, caplog):
"""Live 11-27 → 12-02: a settlement with no MarketCast entry of its own is
still awaited while an earlier round is (the carry), but its entry count
was dropped when 0, so its timeout logged an ERROR "? MarketCast entr(ies)
defer as infra" at nearly every settlement. The count is now kept (0):
the timeout is a WARNING and the manifest still records "absent"."""
import logging
from dataclasses import replace

from cascade.funding.queue import LaneCQueue
from cascade.shared.config.lane_c import LaneCConfig
from cascade.shared.lane_c_manifest import load_lane_c_manifest
from cascade.shared.manifest import format_trained_pointer
from cascade.trainer.lane_c_driver import LaneCDriver

FROM = 9000
king = format_trained_pointer("cascade/ckpt@sha256:" + "a" * 64)
ref = "alfa/recipe@sha256:" + "1" * 64
mc = replace(MC, from_block=FROM, report_timeout_settlements=2)
cfg = SimpleNamespace(lane_c=LaneCConfig(from_block=FROM, targets=("mkt:returns",),
legs_per_target=1), marketcast=mc)
published = []

class Ops:
q = LaneCQueue(tmp_path / "q.json", clock=lambda: 1_000_000.0)

def queue(self):
return self.q

def sign(self, m):
return replace(m, signature="ab" * 32)

def publish(self, key, text):
published.append((key, text))

def read_mkt_report(self, rid):
return None # the validator never publishes one

drv = LaneCDriver(cfg, Ops(), tmp_path / "drv.json")
drv.st.finished.append({
"leg": {"hotkey": "BRAVO", "uid": 1, "target": "mkt:returns", "ref": ref,
"entry_ref": "", "started_block": FROM + 1},
"trained_pointer": format_trained_pointer("cascade/ckpt@sha256:" + "1" * 64),
"train_block": FROM + 1})
assert drv.settle(round_id="r1", block=FROM + 7200, era_index=1, base_pointer=king)
# r2 has no entry of its own: awaited only as a carry behind r1, count kept as 0
drv.settle(round_id="r2", block=FROM + 2 * 7200, era_index=1, base_pointer=king)
assert {"rid": "r2", "age": 0, "entries": 0} in drv.st.mkt_await
with caplog.at_level(logging.WARNING, logger="cascade.trainer.lane_c"):
for i, rid in enumerate(("r3", "r4", "r5"), start=3):
drv.settle(round_id=rid, block=FROM + i * 7200, era_index=1, base_pointer=king)
absent = [r for r in caplog.records if "absent after" in r.getMessage()]
r2 = [r for r in absent if " r2 " in r.getMessage()]
assert r2 and all(r.levelno == logging.WARNING for r in r2)
assert not any(r.levelno >= logging.ERROR and " r2 " in r.getMessage() for r in absent)
# r1 HAD an entry: its timeout is still the ERROR alert
assert any(r.levelno == logging.ERROR and " r1 " in r.getMessage() for r in absent)
recorded = {}
for _, text in published:
recorded.update(load_lane_c_manifest(text).mkt_reports or {})
assert recorded.get("r2") == "absent" and recorded.get("r1") == "absent"


def test_marketcast_continuation_preserves_optimizer_sampler_and_ema(tmp_path):
from cascade.trainer.continuation import Continuation, SnapshotStore
snap = _train_snap(tmp_path)
Expand Down
Loading