matrix: a node's harness timings in one exclusive job, and its re-times in one more
What: gpu_node times all of a node's GPU legs in ONE job that holds the node alone (--exclusive),
the legs in turn, each still timing its one GPU with nothing else running; the legs whose old
runtime spread past results.BASE_SPREAD are timed once more together in one more such job. retime
does the same for a Linux node's outlier legs (a Windows node's leg stays its own job). A job's
timeout is its leg count times one leg's: size() keeps a run's minutes per leg.
Why: the supervisor measured homelab GPU jobs waiting 8.6 job-hours an hour from 20:15 to 22:30,
29% of it behind exclusive runs (5% before). The matrix round at 1ae9003019 took 10 exclusive runs
of 2-6 min (ms01 3, um870 2, gem10 2, um790 2, the mini 1), and each drained its node first. One
exclusive job per node per round drains each node once.
Verified: scripts/matrix/test_matrix.py in a potluck job (see the landing note).
This commit is contained in:
1 parent
5bd17daf4b
commit
ef5b888c2f
2 files changed
+69
-55
No files matched your search
+34
-27
@@ -592,8 +592,9 @@ class Run:
|
||||
def setup(self, node):
|
||||
return self.cfg.get("setup", {}).get(node, "")
|
||||
|
||||
def size(self, kind, node):
|
||||
"""RAM and timeout from this kind's last measured runs on NODE. RAM: 1.3x the largest
|
||||
def size(self, kind, node, legs=1):
|
||||
"""RAM and timeout from this kind's last measured runs on NODE, for a job of LEGS legs run in
|
||||
turn: a run's minutes are kept per leg, and the timeout is LEGS times one leg's. RAM: 1.3x the largest
|
||||
peak of the last three that started in a fresh workspace (a run that peaked at its
|
||||
reservation keeps it; one that ended for want of RAM gets 2x), else the kind's default. For
|
||||
a kind that keeps a workspace that is a whole build: an incremental build's peak says
|
||||
@@ -609,9 +610,9 @@ class Run:
|
||||
for r in whole)
|
||||
if runs:
|
||||
minutes = max(minutes, math.ceil(1.5 * max(r["minutes"] for r in runs[-3:])))
|
||||
return max(ram, 2), minutes
|
||||
return max(ram, 2), minutes * legs
|
||||
|
||||
def job(self, kind, node, script, name, gpus=(), carries=(), space=None, exclusive=False, room=None):
|
||||
def job(self, kind, node, script, name, gpus=(), carries=(), space=None, exclusive=False, room=None, legs=1):
|
||||
"""Dispatch SCRIPT on NODE, wait for it, and return (exit code, output, job record).
|
||||
SPACE names a workspace kept for this kind on this node across runs (incremental builds,
|
||||
and no fresh checkout of the tree). A job that times anything is EXCLUSIVE. It is sized as
|
||||
@@ -623,7 +624,7 @@ class Run:
|
||||
key = f"{space}@{node}" if space else None
|
||||
with self.lock:
|
||||
ws = self.spaces.get(key) if key else None
|
||||
ram, minutes = self.size(kind, node)
|
||||
ram, minutes = self.size(kind, node, legs)
|
||||
if room:
|
||||
ram = room
|
||||
args = ["dispatch", "--json", "--priority", "5", "--kill-on-stall", "--label", "agent=matrix",
|
||||
@@ -671,7 +672,7 @@ class Run:
|
||||
killed = peak >= 0.95 * ram and (code == 137 or (code != 0 and bool(STARVED.search(out))))
|
||||
with self.lock:
|
||||
self.stats.setdefault(f"{kind}@{node}", []).append(
|
||||
dict(ram=ram, peak=round(peak, 2), minutes=round(took, 2), killed=killed,
|
||||
dict(ram=ram, peak=round(peak, 2), minutes=round(took / legs, 2), killed=killed,
|
||||
full=ws is None))
|
||||
self.stats[f"{kind}@{node}"] = self.stats[f"{kind}@{node}"][-6:]
|
||||
if key and rec.get("workspace"):
|
||||
@@ -681,7 +682,7 @@ class Run:
|
||||
if killed and ram < cap:
|
||||
log(f"{name}: wanted more than its {ram} GiB; again with {min(2 * ram, cap)} GiB")
|
||||
return self.job(kind, node, script, name, gpus, carries, space, exclusive,
|
||||
room=min(2 * ram, cap))
|
||||
room=min(2 * ram, cap), legs=legs)
|
||||
return w.returncode, out, rec
|
||||
|
||||
def record(self, jid):
|
||||
@@ -737,8 +738,10 @@ class Run:
|
||||
|
||||
def gpu_node(self, node, legs, ready):
|
||||
"""One node's GPU legs: their device tests in turn, in one job holding their GPUs, then
|
||||
each leg's harness in a job of its own that holds the node alone and times that one GPU.
|
||||
READY gives the carry."""
|
||||
their harnesses in turn, in ONE job that holds the node alone, so the node drains once for
|
||||
all its timings; each leg still times its one GPU with nothing else running. The legs whose
|
||||
old runtime spread past results.BASE_SPREAD are timed once more, together, in one more such
|
||||
job. READY gives the carry."""
|
||||
made, why = ready()
|
||||
if not made:
|
||||
return self.fail(legs, why)
|
||||
@@ -747,8 +750,7 @@ class Run:
|
||||
self.carried[node] = made
|
||||
for leg in legs:
|
||||
leg.started = time.time()
|
||||
jobs = [("rt", legs, f"rt-{node}")] + ([("harness", [leg], f"harness-{leg.id}") for leg in legs]
|
||||
if self.harness else [])
|
||||
jobs = [("rt", legs, f"rt-{node}")] + ([("harness", legs, f"harness-{node}")] if self.harness else [])
|
||||
while jobs:
|
||||
suite, these, name = jobs.pop(0)
|
||||
layer = self.layer if suite == "rt" else None
|
||||
@@ -757,10 +759,12 @@ class Run:
|
||||
code, out, rec = self.job("gpu" if suite == "rt" else "time", node, script, name,
|
||||
gpus=[leg.gpu for leg in these],
|
||||
carries=[carry] + ([layer[0]] if layer else []), space="gpu",
|
||||
exclusive=suite == "harness")
|
||||
exclusive=suite == "harness", legs=len(these) if suite == "harness" else 1)
|
||||
self.finish(these, code, out, rec, suite)
|
||||
if suite == "harness" and self.timed_again(these[0]):
|
||||
jobs.append((suite, these, f"{name}-again"))
|
||||
if suite == "harness":
|
||||
again = [leg for leg in these if leg.id not in self.failures and self.timed_again(leg)]
|
||||
if again:
|
||||
jobs.append((suite, again, f"{name}-again"))
|
||||
|
||||
def timed_again(self, leg):
|
||||
"""Whether LEG's harness, just timed, is timed once more, after the node's other jobs: the
|
||||
@@ -779,33 +783,36 @@ class Run:
|
||||
"""Each of LEGS's harness timed once more, after every leg is in: a leg whose one pass has
|
||||
a harness row's cross-GPU outlier (results.outliers_to_retime), which then fails it only
|
||||
where both passes agree (results.time_outliers). The second pass's records take the
|
||||
first's, as a timing's do in timed_again. A node's legs in turn, the nodes at once, each
|
||||
job holding its node alone as a timing does; a Linux node's job lays the tree out again
|
||||
and its last one tidies, as the node's last job had."""
|
||||
first's, as a timing's do in timed_again. A Linux node's legs in turn in ONE job holding the
|
||||
node alone, as a timing does, which lays the tree out again and tidies, as the node's last
|
||||
job had; a Windows node's leg in its own; the nodes at once."""
|
||||
by_node = {}
|
||||
for leg in legs:
|
||||
by_node.setdefault(leg.node, []).append(leg)
|
||||
|
||||
def chain(node, these):
|
||||
for leg in these:
|
||||
batches = ([[leg] for leg in these] if self.nodes[node]["os"] == "windows" else [these])
|
||||
for batch in batches:
|
||||
try:
|
||||
if self.nodes[node]["os"] == "windows":
|
||||
leg = batch[0]
|
||||
code, out, rec = self.job("wintime", node, winrun_script(leg, "harness"),
|
||||
f"winharness-{leg.id}-outlier", gpus=[leg.gpu], space="win",
|
||||
exclusive=True)
|
||||
elif node in self.carried:
|
||||
carry, mirror, rev = self.carried[node]
|
||||
script = gpu_script(self.short, self.setup(node), [leg], mirror, rev, "harness",
|
||||
leg is these[-1], None, self.nodes.get(node, {}).get("cpu_model"))
|
||||
code, out, rec = self.job("time", node, script, f"harness-{leg.id}-outlier",
|
||||
gpus=[leg.gpu], carries=[carry], space="gpu", exclusive=True)
|
||||
script = gpu_script(self.short, self.setup(node), batch, mirror, rev, "harness",
|
||||
True, None, self.nodes.get(node, {}).get("cpu_model"))
|
||||
code, out, rec = self.job("time", node, script, f"harness-{node}-outlier",
|
||||
gpus=[leg.gpu for leg in batch], carries=[carry], space="gpu",
|
||||
exclusive=True, legs=len(batch))
|
||||
else:
|
||||
self.fail([leg], f"its cross-GPU outlier's re-time found no carry on {node}")
|
||||
self.fail(batch, f"its cross-GPU outlier's re-time found no carry on {node}")
|
||||
continue
|
||||
self.finish([leg], code, out, rec, "harness")
|
||||
except Exception as error: # a re-time's own failure fails its leg, not the run
|
||||
log(f"retime {leg.id}: {error!r}")
|
||||
self.fail([leg], f"its cross-GPU outlier's re-time failed: {error!r}")
|
||||
self.finish(batch, code, out, rec, "harness")
|
||||
except Exception as error: # a re-time's own failure fails its legs, not the run
|
||||
log(f"retime {node}: {error!r}")
|
||||
self.fail(batch, f"its cross-GPU outlier's re-time failed: {error!r}")
|
||||
|
||||
threads = [threading.Thread(target=chain, args=(node, these)) for node, these in sorted(by_node.items())]
|
||||
for t in threads:
|
||||
|
||||
@@ -163,7 +163,7 @@ done
|
||||
|
||||
|
||||
class TimedAgainTests(unittest.TestCase):
|
||||
def test_a_harness_past_the_old_runtime_s_spread_is_timed_once_more_after_the_node_s_other_jobs(self):
|
||||
def test_a_node_s_harnesses_are_timed_in_one_job_and_a_spread_past_the_line_once_more_after_it(self):
|
||||
run = run_of({})
|
||||
run.harness, run.layer, run.cfg = True, None, {}
|
||||
legs = [matrix.Leg("1002:744c", "n", "0000:06:00.0", "radeon"),
|
||||
@@ -173,24 +173,31 @@ class TimedAgainTests(unittest.TestCase):
|
||||
asked = []
|
||||
|
||||
def job(kind, node, script, name, gpus=(), carries=(), space=None, exclusive=False, room=None,
|
||||
hold_line=False):
|
||||
asked.append((name, 'rm -rf "$S"' in script))
|
||||
legs=1):
|
||||
these = [leg for leg in legs_of if leg.gpu in gpus]
|
||||
asked.append((name, [leg.id for leg in these], exclusive, legs, 'rm -rf "$S"' in script))
|
||||
if name.startswith("rt-"):
|
||||
return 0, "".join(f"M2V-LEG {leg.id} begin\nM2V-SUITE {leg.id} rt exit 0\n" for leg in legs), {"id": name}
|
||||
leg_id = name.split("-", 1)[1].removesuffix("-again")
|
||||
lines = [f"M2V-LEG {leg_id} begin", "M2V-MATRIX time harness-old/alu 100.0",
|
||||
"M2V-MATRIX time harness-new/alu 110.0"]
|
||||
for pair, old in enumerate(olds[leg_id].pop(0), 1):
|
||||
lines += [f"M2V-MATRIX time harness-retime/alu/{pair}/old {old}",
|
||||
f"M2V-MATRIX time harness-retime/alu/{pair}/new {old * 1.1:.1f}"]
|
||||
return 0, "\n".join(lines + [f"M2V-SUITE {leg_id} harness exit 0"]) + "\n", {"id": name}
|
||||
return 0, "".join(f"M2V-LEG {leg.id} begin\nM2V-SUITE {leg.id} rt exit 0\n" for leg in these), {"id": name}
|
||||
lines = []
|
||||
for leg in these:
|
||||
lines += [f"M2V-LEG {leg.id} begin", "M2V-MATRIX time harness-old/alu 100.0",
|
||||
"M2V-MATRIX time harness-new/alu 110.0"]
|
||||
for pair, old in enumerate(olds[leg.id].pop(0), 1):
|
||||
lines += [f"M2V-MATRIX time harness-retime/alu/{pair}/old {old}",
|
||||
f"M2V-MATRIX time harness-retime/alu/{pair}/new {old * 1.1:.1f}"]
|
||||
lines.append(f"M2V-SUITE {leg.id} harness exit 0")
|
||||
return 0, "\n".join(lines) + "\n", {"id": name}
|
||||
|
||||
legs_of = legs
|
||||
|
||||
with mock.patch.object(run, "job", job, create=True), mock.patch.object(matrix, "log"):
|
||||
run.gpu_node("n", legs, lambda: (("carry", "mirror", "rev"), None))
|
||||
# The XTX's old runtime spread 15% in its first timing: it is timed once more, after the
|
||||
# 2080's, and that last job is the node's last, which tidies; once more only.
|
||||
self.assertEqual(asked, [("rt-n", False), ("harness-1002:744c", False), ("harness-10de:1e87", False),
|
||||
("harness-1002:744c-again", True)])
|
||||
# Both legs' harnesses are timed in ONE job holding the node alone, sized for two legs. The
|
||||
# XTX's old runtime spread 15% in its first timing: it alone is timed once more, in one more
|
||||
# such job, the node's last, which tidies; once more only.
|
||||
self.assertEqual(asked, [("rt-n", ["1002:744c", "10de:1e87"], False, 1, False),
|
||||
("harness-n", ["1002:744c", "10de:1e87"], True, 2, False),
|
||||
("harness-n-again", ["1002:744c"], True, 1, True)])
|
||||
self.assertEqual([(round(spread, 2), row) for spread, row in legs[0].timings], [(0.15, "alu"), (0.04, "alu")])
|
||||
self.assertEqual([(round(spread, 2), row) for spread, row in legs[1].timings], [(0.01, "alu")])
|
||||
self.assertEqual(run.carried, {"n": ("carry", "mirror", "rev")})
|
||||
@@ -210,23 +217,23 @@ class OutlierRetimeTests(unittest.TestCase):
|
||||
leg.parsed["suites"][matrix.HARNESS_SUITE] = {"records": {"time": {"harness-new/alu": 200.0}}}
|
||||
asked = []
|
||||
|
||||
def job(kind, node, script, name, gpus=(), carries=(), space=None, exclusive=False, room=None):
|
||||
asked.append((kind, node, name, list(gpus), list(carries), space, exclusive, 'rm -rf "$S"' in script))
|
||||
leg_id = name.split("-", 1)[1].removesuffix("-outlier")
|
||||
return 0, (f"M2V-LEG {leg_id} begin\nM2V-MATRIX time harness-old/alu 100.0\n"
|
||||
f"M2V-MATRIX time harness-new/alu 101.0\nM2V-SUITE {leg_id} harness exit 0\n"), {"id": name}
|
||||
def job(kind, node, script, name, gpus=(), carries=(), space=None, exclusive=False, room=None, legs=1):
|
||||
asked.append((kind, node, name, list(gpus), list(carries), space, exclusive, legs,
|
||||
'rm -rf "$S"' in script))
|
||||
return 0, "".join(f"M2V-LEG {leg.id} begin\nM2V-MATRIX time harness-old/alu 100.0\n"
|
||||
f"M2V-MATRIX time harness-new/alu 101.0\nM2V-SUITE {leg.id} harness exit 0\n"
|
||||
for leg in legs_of if leg.gpu in gpus), {"id": name}
|
||||
|
||||
legs_of = legs
|
||||
|
||||
with mock.patch.object(run, "job", job, create=True), mock.patch.object(matrix, "log"):
|
||||
run.retime(legs)
|
||||
# A Linux node's legs in turn with its carry, its last job tidying; the Windows leg in its
|
||||
# workspace; each holding its node alone. A node whose legs never started has no carry.
|
||||
# A Linux node's legs in turn in ONE job with its carry, holding the node alone and
|
||||
# tidying; the Windows leg in its workspace. A node whose legs never started has no carry.
|
||||
self.assertEqual(sorted(asked), [
|
||||
("time", "n", "harness-1002:744c-outlier", ["0000:06:00.0"], ["carry"], "gpu", True, False),
|
||||
("time", "n", "harness-10de:1e87-outlier", ["0000:09:00.0"], ["carry"], "gpu", True, True),
|
||||
("wintime", "w", "winharness-8086:3e9b-outlier", ["8086:3e9b"], [], "win", True, False)])
|
||||
self.assertEqual([name for _, node, name, *_ in asked if node == "n"],
|
||||
["harness-1002:744c-outlier", "harness-10de:1e87-outlier"])
|
||||
for leg, name in zip(legs, ("harness-1002:744c-outlier", "harness-10de:1e87-outlier",
|
||||
("time", "n", "harness-n-outlier", ["0000:06:00.0", "0000:09:00.0"], ["carry"], "gpu", True, 2, True),
|
||||
("wintime", "w", "winharness-8086:3e9b-outlier", ["8086:3e9b"], [], "win", True, 1, False)])
|
||||
for leg, name in zip(legs, ("harness-n-outlier", "harness-n-outlier",
|
||||
"winharness-8086:3e9b-outlier")):
|
||||
self.assertEqual(leg.parsed["suites"][matrix.HARNESS_SUITE]["records"]["time"],
|
||||
{"harness-old/alu": 100.0, "harness-new/alu": 101.0})
|
||||
|
||||
Reference in new issue
Block a user