Reserve the nodes, then backfill what ends in time
A 64-GPU job needs 8 nodes. Here are 4 of the 8 that drain soonest, and the reservation starts at 90 minutes:
| Node | Busy until | Open to backfill |
|---|---|---|
| 1 | 90 min | no time left |
| 2 | 60 min | 60 to 90 min |
| 3 | 75 min | 75 to 90 min |
| 4 | free now | 0 to 90 min: a 45-minute trial fits, a 2-hour one doesn't |
The fix is a reservation plus backfill:
- When the big job reaches the head of its queue, or waits past a threshold, pick the nodes that will drain soonest. A node drains when the last job on it ends, judged by the jobs' declared time limits.
- Reserve those nodes from that time.
- New work may still start on them, but only if it will finish before the reservation begins. That's backfill.
- Everything else schedules as usual.
Say all 8 of the soonest-draining nodes drain within 90 minutes, as these four do. Then the reservation starts 90 minutes from now. A sweep trial with a 45-minute limit can start on node 4 now and end before the reservation. A trial with a 2-hour limit can't, so it goes elsewhere or waits.
Slurm, a cluster job scheduler, states the rule in one line: "Backfill scheduling will start lower priority jobs if doing so does not delay the expected start time of any higher priority jobs." A job that can't start now gets its resources reserved for its expected run time.
In the editor, write reservation_start(node_jobs, k) and can_backfill(now, limit, start). node_jobs holds one list per node: the minutes from now when each of its jobs ends.