Skip to content

Commit a8d1073

Browse files
committed
[None][feat] trtllm_modeling_v2 sessions: name what a queued job waits behind
A long-waiting job's `waiting` line said where it was queued and the scheduler's hold reason, which for a device wait reads only "waiting for 4 GPU(s); 0 free". On the Qwen3.8 FP8 run a tune step sat about 20 min behind a profiling job an analysis agent had launched on the same spool, and nothing said so. A queued job's line now also names the jobs running on its spool (MAX_AHEAD of them, the rest counted). Signed-off-by: Wanli Jiang <35160485+Wanli-Jiang@users.noreply.github.com>
1 parent 2ba75cc commit a8d1073

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ a container runtime, a shell). The run needs:
9494
`trtllm-modeling-v2 monitor status` shows each session, and raises `SESSION_ENDING` while one is in
9595
hand-over with no newer session on its spool. A gate, substrate or regression job the run has
9696
waited on for 15 minutes writes a `waiting` event: the job, its spool, queued or running and since
97-
when, and why the session holds it when its `status.json` says; then at most one every 15 minutes
98-
while the wait lasts. The tune campaign's jobs say the same in its `tune` events.
97+
when, why the session holds it when its `status.json` says, and for a queued job what runs on its
98+
spool meanwhile; then at most one every 15 minutes while the wait lasts. The tune campaign's jobs
99+
say the same in its `tune` events.
99100

100101
**While it runs**, you or the launching agent keep the sessions alive and leave the work to the run. Never cancel
101102
a job the run submitted (a gate, a worker's test) or run a replacement check beside it: a cancelled

‎agent-flow/agent_flow/workflows/trtllm_modeling_v2/infra/compute/spoolctl.py‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,25 +201,38 @@ def wait_for_job(
201201
time.sleep(poll_s)
202202

203203

204+
#: The most running jobs a queued job's :func:`waiting_line` names; the rest are counted.
205+
MAX_AHEAD = 3
206+
207+
204208
def waiting_line(spool: str | Path, name: str, now: float) -> str:
205209
"""Job ``name`` on ``spool``: queued or running and since when, and the scheduler's hold reason.
206210
211+
A queued job's line also names what runs on its spool meanwhile, which it waits behind.
207212
``""`` when the spool does not say (the job between states, an unreadable record).
208213
"""
209214
paths = _sched.SpoolPaths(spool)
215+
ahead: list[str] = []
210216
try:
211217
if (paths.running / f"{name}.sh").exists():
212218
meta = _files.read_json(paths.running / f"{name}.json") or {}
213219
state, since = "running", float(meta["started_epoch"])
214220
else:
215221
state, since = "queued", (paths.pending / f"{name}.sh").stat().st_mtime
222+
ahead = sorted(path.stem for path in paths.running.glob("*.sh"))
216223
pending = (_files.read_json(paths.snapshot) or {}).get("pending") or ()
217224
hold = next((str(job.get("reason") or "") for job in pending if job["name"] == name), "")
218225
except (OSError, KeyError, TypeError, ValueError, AttributeError):
219226
return ""
220227
minutes = (now - since) / 60
221228
line = f"{name} on {paths.root} {state} since {_sched.utc_iso(since)} ({minutes:.0f} min)"
222-
return line + (f"; held: {hold}" if hold else "")
229+
if hold:
230+
line += f"; held: {hold}"
231+
if ahead:
232+
more = len(ahead) - MAX_AHEAD
233+
line += "; running there: " + ", ".join(ahead[:MAX_AHEAD])
234+
line += f" and {more} more" if more > 0 else ""
235+
return line
223236

224237

225238
def left_in_spool(spool: str | Path, name: str) -> str:

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,22 @@ def test_a_long_wait_on_a_gate_job_is_said_once_per_period(tmp_path):
444444
assert spoolctl.waiting_line(gates, "gate-core", time.time()) == ""
445445

446446

447+
@pytest.mark.usefixtures("_no_ambient_spool")
448+
def test_a_queued_job_names_what_runs_ahead_of_it_on_its_spool(tmp_path):
449+
"""A tune step sat 20 min behind a profiling job an agent had launched, and nothing said so."""
450+
work = session(tmp_path, "work-1")
451+
hold = "waiting for the whole node to drain"
452+
_hold(work, "tune-t-sol", hold)
453+
running = SpoolPaths(work).running
454+
(running / "sol-profile.sh").write_text("true\n")
455+
line = spoolctl.waiting_line(work, "tune-t-sol", time.time())
456+
assert line.endswith(f"; held: {hold}; running there: sol-profile")
457+
for name in ("a", "b", "c"):
458+
(running / f"{name}.sh").write_text("true\n")
459+
line = spoolctl.waiting_line(work, "tune-t-sol", time.time())
460+
assert line.endswith("; running there: a, b, c and 1 more")
461+
462+
447463
@pytest.mark.usefixtures("_no_ambient_spool")
448464
def test_the_tune_runner_says_its_long_waits_at_most_once_per_period(tmp_path, monkeypatch):
449465
monkeypatch.setattr(spoolctl, "WAIT_NOTE_S", 0.2)

0 commit comments

Comments
 (0)