Skip to content

Commit c388c69

Browse files
committed
[None][fix] trtllm_modeling_v2: keep the suite's width in a checkpoint's keep gate
A tune checkpoint runs the target's suite through KeepGate.tests_only(), which drops the accuracy members because accuracy runs once on the final tree. suite_devices was derived from those members only, so the checkpoint's suite job asked for one device. The target's multi-rank tests (a collective's op matrix at the widest member's world size) then failed for the job's size at every checkpoint, and every keep since the last checkpoint was rolled back. tests_only() now records the members' width in a suite_width field, which suite_devices prefers, so the checkpoint's suite job holds as many devices as the full gate's suite. The field only restates the members' width, so refresh_inputs leaves it out of the campaign's evidence inputs. Otherwise a campaign resumed across this change would discard its controls and measurements and measure them all again. Signed-off-by: Ruocheng Jia <ruochengj@nvidia.com>
1 parent 737bf56 commit c388c69

3 files changed

Lines changed: 54 additions & 3 deletions

File tree

‎agent-flow/agent_flow/workflows/trtllm_modeling_v2/tune/campaign.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ def refresh_inputs(self) -> None:
317317
"""Invalidate reusable evidence when measurement or judgment inputs have changed."""
318318
inputs = evidence_key(self.bench, self.base_configs)
319319
gate_identity = asdict(self.keep_gate)
320+
# The suite's width restates the members' (``KeepGate.tests_only``), which the identity
321+
# already holds: it changes nothing the gate judges.
322+
gate_identity.pop("suite_width", None)
320323
gate_identity["spec"] = {
321324
k: v
322325
for k, v in self.keep_gate.spec.items()

‎agent-flow/agent_flow/workflows/trtllm_modeling_v2/tune/keep_gate.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,19 @@ class KeepGate:
129129
planned_floor: Mapping[str, Any] = field(default_factory=dict)
130130
#: Why this gate runs no accuracy part though the campaign has one (:meth:`tests_only`).
131131
skipped: str = ""
132+
#: The suite's devices once the members are dropped (:meth:`tests_only`); 0: the members'.
133+
suite_width: int = 0
132134

133135
@property
134136
def suite_devices(self) -> int:
135137
"""The devices the suite's job holds: the widest member's.
136138
137139
The target's suite carries multi-rank tests (a collective's op matrix
138140
needs as many devices as the widest member); on fewer devices such a
139-
test fails for the job's size, not for the candidate.
141+
test fails for the job's size, not for the candidate. A checkpoint's
142+
gate has no members (:meth:`tests_only`) and keeps their width.
140143
"""
141-
return max((_width(m) or 1 for m in self.members), default=1)
144+
return self.suite_width or max((_width(m) or 1 for m in self.members), default=1)
142145

143146
@property
144147
def ungated(self) -> bool:
@@ -149,7 +152,12 @@ def tests_only(self) -> "KeepGate":
149152
"""The suite alone: a checkpoint's (accuracy runs once, on the final tree)."""
150153
if self.ungated:
151154
return self
152-
return replace(self, members=(), skipped="accuracy runs once, on the final tree")
155+
return replace(
156+
self,
157+
members=(),
158+
skipped="accuracy runs once, on the final tree",
159+
suite_width=self.suite_devices,
160+
)
153161

154162
def accuracy_only(self) -> "KeepGate":
155163
"""The accuracy part alone: the final tree's, the suite having run at each checkpoint."""

‎agent-flow/tests/workflows/trtllm_modeling_v2/test_tune_stage.py‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,46 @@ def mute(tree):
624624
assert camp.state.checkpoint["retry_after"] == 4
625625

626626

627+
def test_a_checkpoints_suite_job_holds_as_many_devices_as_the_widest_member(tmp_path):
628+
"""The checkpoint's gate drops the members (accuracy runs on the final tree), not their width.
629+
630+
The target's suite carries multi-rank tests; on one device they fail at every checkpoint
631+
and every keep since the last one is rolled back.
632+
"""
633+
gates = FakeRunner(["g1"], "campg", _effect)
634+
asked: dict[str, str] = {}
635+
submit = gates.submit
636+
637+
def recording(spool, label, command, **kw):
638+
asked[label] = kw.get("gpus", "all")
639+
return submit(spool, label, command, **kw)
640+
641+
gates.submit = recording
642+
camp = _campaign(tmp_path, gates, [])
643+
assert camp.keep_gate.members == ("dep4",) and camp.keep_gate.suite_devices == 4
644+
suite = camp.keep_gate.tests_only()
645+
assert suite.members == () and not suite.ungated
646+
assert suite.suite_devices == 4 and suite.needs("tests")[0] == 4
647+
(ck,) = _run(camp)
648+
(label,) = [label for label in asked if label.startswith("gate-ckpt-")]
649+
assert label.endswith("-tests") and asked[label] == "4"
650+
assert ck["correctness"] == "PASS" and camp.state.kept == ["fast-path"]
651+
652+
653+
def test_the_suite_width_leaves_the_campaigns_evidence_inputs_as_they_were(tmp_path):
654+
"""The suite's width restates the members' width and changes nothing the gate judges.
655+
656+
It stays out of the evidence inputs, so a campaign resumed across a change of that field
657+
keeps its controls and measurements instead of measuring them all again.
658+
"""
659+
camp = _campaign(tmp_path, FakeRunner(["g1"], "campg", _effect), [])
660+
before = camp.state.inputs
661+
assert before
662+
camp.keep_gate = replace(camp.keep_gate, suite_width=camp.keep_gate.suite_devices)
663+
camp.refresh_inputs()
664+
assert camp.state.inputs == before
665+
666+
627667
HOUR = 3600.0
628668

629669

0 commit comments

Comments
 (0)