A shared GPU cluster has slots identical slots. Tenants have weights; jobs are
{"id", "tenant", "arrival", "duration"}. Simulate weighted fair queuing:
duration / weight.Return [[job_id, start_time, slot], ...] in the order jobs start.
Implement schedule. Input: slots: int, weights: dict[str, float], jobs: list[dict]. Returns: list[list].
a1 starts first (tie on 0, 'a' < 'b'); a's vt becomes 4, b's grows by 2 per job, so b runs twice before a runs again.
def schedule(slots, weights, jobs):
out, t = [], 0
for i, job in enumerate(sorted(jobs, key=lambda j: j["arrival"])):
t = max(t, job["arrival"])
out.append([job["id"], t, i % slots])
return out
Run executes the public tests. Submit grades against public and hidden tests.
A shared GPU cluster has slots identical slots. Tenants have weights; jobs are
{"id", "tenant", "arrival", "duration"}. Simulate weighted fair queuing:
duration / weight.Return [[job_id, start_time, slot], ...] in the order jobs start.
Implement schedule. Input: slots: int, weights: dict[str, float], jobs: list[dict]. Returns: list[list].
a1 starts first (tie on 0, 'a' < 'b'); a's vt becomes 4, b's grows by 2 per job, so b runs twice before a runs again.
def schedule(slots, weights, jobs):
out, t = [], 0
for i, job in enumerate(sorted(jobs, key=lambda j: j["arrival"])):
t = max(t, job["arrival"])
out.append([job["id"], t, i % slots])
return out
Run executes the public tests. Submit grades against public and hidden tests.