Skip to content

Commit 8b995f0

Browse files
committed
[None][feat] trtllm_modeling_v2 orchestrator: re-certify once, on the final tree, not after every landing
While required work is open, the orchestrator no longer re-runs stale checks on its own. A check runs when a task that claims it lands, when the planner adds a `check` task that names it, and in one final round: once no required task is open, every claimed check with no verdict on the target as it is runs again, the non-delivery tiers first and the delivery tier once everything else holds, and delivery proceeds as before. Re-certifying after every landing cost more than it caught. On the Qwen3.8 MV2 run three full rounds of 23 checks took 34.1 of 57.4 gate job-hours (59%); on the FP8 run 98 of 137 gate runs were re-runs across 10 commits. The checks a task claims still run as it lands: those caught premature UNIT_READY decisions on the step5 runs. The re-checks beside running work, the deferral of stale accuracy checks to milestones and the once-per-process delivery rehearsal go with it. A planner `check` task may now name delivery-tier checks, so the planner rehearses delivery when it wants to, and the contract standing it reads names, for each missing check, the commit of its last pass, the tree to diff a change from. The planner prompt says the rest. Signed-off-by: Wanli Jiang <35160485+Wanli-Jiang@users.noreply.github.com>
1 parent 39aec8b commit 8b995f0

7 files changed

Lines changed: 206 additions & 132 deletions

File tree

‎agent-flow/agent_flow/workflows/trtllm_modeling_v2/README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ must change before that.
122122
with it: the run never changes a shared entry, so other models are not disturbed mid-run.
123123
3. **Prove and deliver:** checks measure fixed-commit snapshots against framework-owned references.
124124
A verdict counts only on the tree it measured: the same gate-relevant files, native libraries
125-
and inputs. Missing engine facts stay unknown. Delivery requires the contract, tests and files
126-
to agree.
125+
and inputs. Checks run as the work that claims them lands and as the planner asks; once the
126+
required work is done, one final round re-runs every claimed check not measured on the final
127+
tree, the delivery tier last. Missing engine facts stay unknown. Delivery requires the
128+
contract, tests and files to agree.
127129
4. **Resume:** checkpoints, decision identities and task receipts recover completed work without
128130
adopting another attempt's answer. Compute sessions own resource allocation and safe cancellation;
129131
you or the launching agent handle cluster allocations and session renewal.

‎agent-flow/agent_flow/workflows/trtllm_modeling_v2/agents/decisions.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ class Decision:
116116
Decision(
117117
"DONE",
118118
"you believe every required check holds",
119-
"the orchestrator verifies, and delivers once full support holds",
119+
"the orchestrator re-runs each claimed check not measured on the final tree, the "
120+
"delivery tier last, and delivers once full support holds",
120121
),
121122
Decision(
122123
"ESCALATE",

‎agent-flow/agent_flow/workflows/trtllm_modeling_v2/agents/prompts/templates/planner.md.j2‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ read the run's state and write the next version of the task graph.
1717
perf configs, the constraints and the user's notes;
1818
- `contract.yaml` and `contract_status.jsonl`: every check the run must pass,
1919
and the latest verdict of each. The run is done when every required check
20-
passes on one tree. Nothing else counts as done;
20+
passes on one tree. Nothing else counts as done. A verdict counts only on
21+
the tree it measured, and the orchestrator does not re-run a stale check
22+
while work runs: after a change lands, read its diff from the commit each
23+
missing check last passed at and add `check` tasks for what it may have
24+
broken. Once the required tasks are done, a final round re-runs every check
25+
a finished task claimed that was not measured on the final tree, the
26+
delivery tier last;
2127
- the current graph, and the events the request lists since your last turn:
2228
which tasks finished, failed or reported something new, with their evidence;
2329
- `runtime_facts.yaml`, whose key numbers the request carries, and each
@@ -152,11 +158,12 @@ cell, the entry's spec keys with values read from the runtime facts.
152158

153159
A `check` task is contract checks and nothing else: re-certifying a member
154160
after a change lands, verifying a member nobody changed, running a stale
155-
check again. Once its dependencies are done the orchestrator sends its checks
156-
to the check pool itself, with no agent turn; it takes no task slot and no
157-
devices of its own (each check takes its own as it starts). It ends done when
158-
they pass; only a failure reaches you. Where a task's work would be "run these
159-
checks", make it a `check` task, not a worker's.
161+
check again, rehearsing a delivery-tier check before the final round. Once
162+
its dependencies are done the orchestrator sends its checks to the check pool
163+
itself, with no agent turn; it takes no task slot and no devices of its own
164+
(each check takes its own as it starts). It ends done when they pass; only a
165+
failure reaches you. Where a task's work would be "run these checks", make it
166+
a `check` task, not a worker's.
160167

161168
A `depends_on_soft` edge lets a task start beside a task it needs only where
162169
its own checks run: a one-line engine fix the forward does not write against,

‎agent-flow/agent_flow/workflows/trtllm_modeling_v2/run/orchestrator.py‎

Lines changed: 45 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@
7575
INFRA_RETRIES = 1
7676
#: A state write that fails with one of these waits for room instead of ending the run.
7777
STORAGE_FULL = frozenset({errno.EDQUOT, errno.ENOSPC})
78-
#: How many stale checks run again, in the contract's order, beside running work each
79-
#: time the target changes; the rest wait for the graph to run out of work.
80-
RECHECKS_WHILE_BUSY = 4
8178
#: Agent slots a campaign's turns may take at once while the onboarding has work open.
8279
CAMPAIGN_SLOTS_BESIDE_ONBOARDING = 2
8380
#: How long a task thread waiting on its soft dependencies sleeps between looks,
@@ -271,8 +268,6 @@ def __init__(
271268
) -> None:
272269
self.s = services
273270
self.contract = contract
274-
#: The full benchmarks, which run again at milestones only (:meth:`_settle`).
275-
self._accuracy_keys = {c.key for c in contract.checks if c.gate.startswith("accuracy[")}
276271
#: State writes a full filesystem refused, by what they write: each is tried
277272
#: again as the loop goes round, and nothing new starts until all have landed.
278273
self._unwritten: dict[str, Callable[[], None]] = {}
@@ -309,7 +304,7 @@ def __init__(
309304
#: How many worker runs one task gets (``graph.apply_revision``).
310305
self.max_attempts = max(1, max_attempts)
311306
self.max_parallel = max_parallel
312-
#: Checks running at once, across every task and the re-checks of an idle run.
307+
#: Checks running at once, across every task and the final round.
313308
self.max_parallel_checks = max(1, max_parallel_checks)
314309
#: How long the loop waits between looks while ready work waits for devices.
315310
self.poll_s = poll_s
@@ -383,11 +378,6 @@ def __init__(
383378
#: The delivery files that last kept a holding contract from full support, per
384379
#: marker, as the planner heard them.
385380
self._files_said: tuple[str, tuple[str, ...]] | None = None
386-
#: The target's marker and the landing the last re-checks beside running work
387-
#: were chosen on.
388-
self._rechecked_at: tuple[str, str] | None = None
389-
#: Delivery-tier checks rehearsed in this process.
390-
self._rehearsed: set[str] = set()
391381
#: The task threads in flight, by task id, as the loop drives them.
392382
self._running: dict[str, Future] = {}
393383
#: The campaign whose end the loop had not recorded when :meth:`run` returned the
@@ -415,12 +405,9 @@ def __init__(
415405
self._foreground_demand = 0
416406
#: When each ready task was first seen ready, for the order they start in.
417407
self._ready_since: dict[str, float] = {}
418-
#: Re-checks of an idle run in flight: what the planner is told if one fails, and the checks.
408+
#: The final round's checks in flight (:meth:`_settle`): what the planner is told if
409+
#: one fails, and the checks.
419410
self._settling: tuple[str, list[tuple[str, Future]]] | None = None
420-
#: The task whose change landed on the target last, in this process, and the
421-
#: target's marker just after it.
422-
self._landed: graph_mod.Task | None = None
423-
self._landed_marker = ""
424411
self._check_pool: ThreadPoolExecutor | None = None
425412
#: Checks passing on the target when progress was last measured.
426413
self._passed_seen = len(self._evaluated()[1].passed)
@@ -597,7 +584,7 @@ def _run_task(self, task: graph_mod.Task) -> tuple[str, list[str]]:
597584
return decision, self._run_checks(k for k in task.satisfies if k not in delivery)
598585
except ChecksRaised as exc:
599586
# The work stands and has landed; only these checks' outcome is unknown.
600-
# They are missing on the target, so they run again as re-checks.
587+
# They are missing on the target, so the final round runs them again.
601588
self._inconclusive[task.id] = str(exc)
602589
return decision, exc.failed
603590
finally:
@@ -650,10 +637,6 @@ def mark_integrated(self, task_id: str, attempt: int) -> None:
650637
"""``task_id``'s commits are on the target: the tasks that soft-depend on it may go on."""
651638
with self._ended:
652639
self._integrated[task_id] = attempt
653-
task = self.graph.by_id().get(task_id)
654-
if task is not None:
655-
# What landed last: stale checks run again beside the work once per landing.
656-
self._landed, self._landed_marker = task, self.s.marker()
657640
self._ended.notify_all()
658641

659642
def _evaluated(self) -> tuple[str, contract_mod.Evaluation]:
@@ -838,84 +821,40 @@ def _foreground(self, running: Mapping[str, Future]) -> list[str]:
838821
kinds = {t.id: t.kind for t in self.graph.tasks}
839822
return [task_id for task_id in running if kinds.get(task_id) not in BACKGROUND_KINDS]
840823

841-
def _settle(self, busy: bool = False) -> None:
842-
"""Keep the target verified as it changes; then, with no required task open, the delivery tier.
843-
844-
``busy``, with foreground work running: each time a change lands, the
845-
first :data:`RECHECKS_WHILE_BUSY` stale checks in the contract's order
846-
run again beside it, and the delivery tier of a member whose other
847-
checks all hold is rehearsed once (:meth:`_rehearsal`). Otherwise every
848-
stale check runs again; and once every other required check holds and
849-
no required task is open but a campaign, the delivery tier runs on the
850-
target as it is. Both run on the check pool; :meth:`_settled` reads the
851-
verdicts once they are all in, and tells the planner what failed.
852-
853-
A stale accuracy check runs again at a milestone only: once no required
854-
task is open, or for the bring-up before it was named. Until then the
855-
cheaper checks of each landing (the boots) stand watch.
824+
def _settle(self) -> None:
825+
"""Re-certify the final tree: once no required task is open, each claimed check stale on it.
826+
827+
While required work is open nothing runs here: a task's claimed checks
828+
run as it lands (:meth:`_run_task`), and the planner adds a ``check``
829+
task for whatever a change may have broken. Once no required task is
830+
open but a campaign (it changes nothing a check measures), every
831+
required check a done task claims and with no verdict on the target as
832+
it is runs again; then, once every other required check holds, the
833+
delivery tier runs on the target as it is. A check that failed on this
834+
very target stays failed until the target changes; running it again
835+
would measure the same thing. The checks run on the check pool;
836+
:meth:`_settled` reads the verdicts once they are all in, and tells the
837+
planner what failed.
856838
"""
839+
if self._required_open(campaign=False):
840+
return
857841
claimed = {k for t in self.graph.tasks if t.status == "done" for k in t.satisfies}
858842
delivery = self._delivery_keys()
859-
marker, evaluation = self._evaluated()
860-
stale = [c.key for c in evaluation.missing if c.key in claimed and c.key not in delivery]
861-
if self._required_open(campaign=False):
862-
bringup = (
863-
{c.key for c in contract_mod.bringup_checks(self.contract)}
864-
if contract_mod.bringup_milestone(self.workspace) is None
865-
else set()
866-
)
867-
stale = [k for k in stale if k not in self._accuracy_keys or k in bringup]
868-
if busy or (not stale and self._required_open(campaign=False)):
869-
keys: list[str] = []
870-
# Once per landing the loop knows made the target what it is.
871-
landed = (marker, self._landed.id if self._landed is not None else "")
872-
known = self._landed is not None and self._landed_marker == marker
873-
if stale and known and landed != self._rechecked_at:
874-
self._rechecked_at = landed
875-
keys = stale[:RECHECKS_WHILE_BUSY]
876-
keys += self._rehearsal(evaluation)
877-
what = "checks run beside the work in flight failed on the current target: "
878-
else:
879-
what, keys = (
880-
"checks that held before failed on the current target: ",
881-
stale,
882-
)
883-
if not stale:
884-
# A check that already failed on this very target stays failed until
885-
# the target changes; running it again would measure the same thing.
886-
missing = {c.key for c in evaluation.missing}
887-
failed_here = {c.key for c, _ in evaluation.failed}
888-
if not missing or not (missing | failed_here) <= delivery:
889-
return
890-
what, keys = "delivery checks failed: ", sorted(missing)
891-
submitted = self._submit_checks(self._check_pool, keys) if keys else []
843+
_, evaluation = self._evaluated()
844+
missing = {c.key for c in evaluation.missing}
845+
what, keys = (
846+
"checks re-run on the final tree failed: ",
847+
[c.key for c in evaluation.missing if c.key in claimed and c.key not in delivery],
848+
)
849+
if not keys:
850+
failed_here = {c.key for c, _ in evaluation.failed}
851+
if not missing or not (missing | failed_here) <= delivery:
852+
return
853+
what, keys = "delivery checks failed: ", sorted(missing)
854+
submitted = self._submit_checks(self._check_pool, keys)
892855
if submitted:
893856
self._settling = (what, submitted)
894857

895-
def _rehearsal(self, evaluation: contract_mod.Evaluation) -> list[str]:
896-
"""Delivery-tier checks to rehearse now, each once: those whose member is otherwise green.
897-
898-
A member whose every other required check passed on the target as it
899-
is gets its delivery-tier checks run once, ahead of the final tree,
900-
as advisory: a failure reaches the planner, and the final tree runs
901-
them again whatever they found.
902-
"""
903-
passed = {c.key for c in evaluation.passed}
904-
required = self.contract.required()
905-
due = []
906-
for check in self.contract.by_tier(contract_mod.TIER_DELIVERY):
907-
if check.key in self._rehearsed or check.key in passed:
908-
continue
909-
before = [
910-
c
911-
for c in required
912-
if c.member == check.member and c.tier != contract_mod.TIER_DELIVERY
913-
]
914-
if before and all(c.key in passed for c in before):
915-
self._rehearsed.add(check.key)
916-
due.append(check.key)
917-
return due
918-
919858
def _settled(self) -> None:
920859
what, submitted = self._settling
921860
self._settling = None
@@ -924,7 +863,7 @@ def _settled(self) -> None:
924863
except ChecksRaised as exc:
925864
# No verdict was recorded for these: they are still due and run again.
926865
failed = exc.failed
927-
self.s.log(f"[settle] re-checks raised, to run again: {exc}")
866+
self.s.log(f"[settle] final-round checks raised, to run again: {exc}")
928867
if failed:
929868
self._note(what + ", ".join(failed), urgent=True)
930869
self._save_events()
@@ -1226,7 +1165,6 @@ def _finish(self, task: graph_mod.Task, decision: str, failed: list[str]) -> Non
12261165
task.status = "failed" if failed else "done"
12271166
if task.kind in INTEGRATED_KINDS:
12281167
# Integrated before its checks ran, whatever they found.
1229-
self._landed, self._landed_marker = task, self.s.marker()
12301168
self._landings[task.id] = (time.time(), task.attempts)
12311169
unknown = self._inconclusive.pop(task.id, "")
12321170
self._note(
@@ -1235,7 +1173,8 @@ def _finish(self, task: graph_mod.Task, decision: str, failed: list[str]) -> Non
12351173
else f"task {task.id} ({task.kind}) {decision}; "
12361174
+ (f"checks failed: {', '.join(failed)}" if failed else "its checks passed")
12371175
+ (
1238-
f"; some checks could not run ({unknown}): they run again as re-checks"
1176+
f"; some checks could not run ({unknown}): a `check` task runs them, "
1177+
"or the final round does"
12391178
if unknown
12401179
else ""
12411180
),
@@ -1409,10 +1348,10 @@ def _start_check_task(self, task: graph_mod.Task) -> Future:
14091348
No agent turn runs and no task slot is taken: its checks wait for
14101349
devices on the check pool as every check does.
14111350
The future holds what a worker's thread returns, :data:`CHECKED` and
1412-
the keys that failed, once every check is in. Its delivery-tier checks
1413-
wait for the delivery tier, as any task's do. A regression check runs
1414-
the package tests instead (``Services.regression``), and what failed is
1415-
named the same way.
1351+
the keys that failed, once every check is in. A delivery-tier check it
1352+
names runs now too: the planner may rehearse delivery before the final
1353+
round. A regression check runs the package tests instead
1354+
(``Services.regression``), and what failed is named the same way.
14161355
"""
14171356
if task.regression:
14181357
outcome = Future()
@@ -1429,10 +1368,7 @@ def tests_in(done: Future) -> None:
14291368

14301369
ran.add_done_callback(tests_in)
14311370
return outcome
1432-
delivery = self._delivery_keys()
1433-
submitted = self._submit_checks(
1434-
self._check_pool, [k for k in task.satisfies if k not in delivery]
1435-
)
1371+
submitted = self._submit_checks(self._check_pool, task.satisfies)
14361372
outcome: Future = Future()
14371373
if not submitted:
14381374
outcome.set_result((CHECKED, []))
@@ -1906,11 +1842,9 @@ def _drive(self, tasks: ThreadPoolExecutor, planner: ThreadPoolExecutor) -> str:
19061842
]
19071843
)
19081844
)
1909-
# The target is kept verified as it changes: beside foreground work the
1910-
# riskiest stale checks and the delivery rehearsals, and once only a
1911-
# campaign runs (it changes nothing a check measures) the rest.
1845+
# Once no required task is open, the final tree is re-certified.
19121846
if self._settling is None:
1913-
self._settle(busy=bool(self._foreground(running)))
1847+
self._settle()
19141848
# Nothing in flight but a campaign is nothing in flight: the onboarding
19151849
# decides, delivers and escalates without waiting for one, which goes on
19161850
# past it as the tune stage (:attr:`campaign`).
@@ -2007,11 +1941,11 @@ def _wait(self, running: dict[str, Future], timeout: float | None) -> None:
20071941
wait([*in_flight, self._stop], timeout=timeout, return_when=FIRST_COMPLETED)
20081942

20091943
def _in_flight(self, running: dict[str, Future]) -> list[Future]:
2010-
"""The tasks, re-checks and planner turn in flight, as futures to wait on.
1944+
"""The tasks, the final round's checks and planner turn in flight, as futures to wait on.
20111945
20121946
A task or planner turn that ended since the loop looked
2013-
ends the wait at once, and is recorded. A batch of re-checks is read
2014-
once all of it is in, so until then only its members still out are
1947+
ends the wait at once, and is recorded. The final round's checks are
1948+
read once all of them are in, so until then only those still out are
20151949
waited on: one already in would end every wait at once.
20161950
"""
20171951
in_flight = list(running.values())

‎agent-flow/agent_flow/workflows/trtllm_modeling_v2/run/validation/check_runner.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ def _gate_until_verdict(self, run, log) -> "check_result.GateResult":
159159
160160
A gate whose job was cancelled through the spool measured nothing either,
161161
but its session is fine: it raises `_SessionLost` at once, so the check
162-
has no verdict (it is missing, not failed) and runs again later, as a
163-
re-check, not straight back into the queue it was taken out of.
162+
has no verdict (it is missing, not failed) and runs again later, in a
163+
`check` task or the final round, not straight back into the queue it was
164+
taken out of.
164165
"""
165166
lost_in_a_row = 0
166167
while True:

0 commit comments

Comments
 (0)