Hmm, this is a practical infrastructure design question about GPU cluster management. The user wants a scheduling policy that balances three distinct workloads: interactive notebooks (low-latency human-in-the-loop), inference (predictable SLA delivery), and training (high-throughput batch).
Key constraints come to mind: notebooks need responsiveness but can't starve other queues, inference has strict latency SLAs but uses minimal GPU memory, training is resource-hungry but flexible on timing. Need to prevent common pitfalls like long training jobs blocking small inference requests or interactive users monopolizing resources.
The solution should prioritize by business impact - inference likely critical for product uptime, notebooks affect researcher productivity, training can be preemptible. But also need fairness mechanisms to prevent starvation. Resource-aware scheduling is crucial since training jobs might use 4 GPUs while inference needs just 0.1.
Multi-level queue hierarchy makes sense: strict priority for SLAs with preemption, time-slicing for fairness, backfilling to maximize utilization. Should include practical details like job profiling, monitoring, and cost allocation since real clusters need chargeback/showback.
Must emphasize this isn't just an algorithm but requires operational tooling (K8s/Slurm integration), job packaging standards, and continuous tuning. The "golden rules" at the end summarize the mindset shift needed from batch-only to mixed workload thinking.
Excellent question. Balancing interactive notebooks, inference, and training on a shared GPU cluster is a classic and critical challenge. The goal is to maximize overall cluster utility and business value while meeting the distinct SLAs (Service Level Agreements) of each workload.
Here is a comprehensive scheduling policy design, moving from principles to concrete rules.
1. Foundational Principles
SLA First: Inference (serving) typically has the strictest latency/availability SLAs. Notebooks need responsiveness for productivity. Training is the most flexible on timing.
Fairness & Isolation: Prevent "noisy neighbor" problems. A single large training job should not starve interactive users or violate inference deadlines.
Simplicity & Predictability: The policy must be understandable to users and produce predictable behavior for capacity planning.
Chargeback/Showback: Track resource consumption by workload type for cost allocation and to incentivize efficient usage.
This uses a hierarchical queue system with preemptive scheduling and gang-scheduling awareness.
Level 1: High-Level Queue Admission Control (Front Door)
Three logical queues:
inference-pri (Highest Priority) - For online/production model serving.
notebook-pri (Medium Priority) - For user interactive development.
training-batch (Low Priority, Preemptible) - For research/experiment jobs.
Admission Rule: Jobs enter their designated queue. No job from a lower-priority queue can start if a higher-priority queue haspending jobs that could run on available resources (simple priority blocking). This enforces strict priority for critical workloads.
Level 2: Within-Queue Scheduling & Preemption (The Engine)
The scheduler uses a time-shared, preemptive policy within each queue, with resource-based fairness.
inference-pri Queue:
Scheduling:Strict Deadline-Aware Scheduling. Jobs are admitted only if the scheduler predicts they can meet their SLA based on current load. Use Earliest Deadline First (EDF) or Minimum Expected Latency.
Preemption:Aggressive. Can preempt anynotebook or training job to start. Inference jobs have guaranteed minimum GPU reservations (e.g., 20% of cluster) if configured.
Isolation: Pin inference replicas to specific GPUs if needed for MPS (Multi-Process Service) or to avoid NVLink contention.
notebook-pri Queue:
Scheduling:Shortest Job First (SJF) Estimated or Round-Robin with time slices. Aim for quick turn-around for small exploratory jobs.
Preemption:Can be preempted by inference jobs. Can also preempttraining jobs. Time-slice: max 1-hour continuous run without re-queuing (to encourage checkpointing).
Fair Share: Implement per-user/user-group fairness (e.g., DRF - Dominant Resource Fairness) so one user can't monopolize notebook GPUs.
training-batch Queue:
Scheduling:Backfilling with Priority Boosts. Only runs on GPUs idle after reserving space for higher-priority queues. Use Conservative Backfilling: a job starts only if it won't delay the expected start time of any higher-priority job.
Preemption:Preemptible by both inference and notebook. Must support checkpoint/restart (e.g., via wandb, pytorch lightning, deepspeed).
Fairness: Long-running jobs get priority decay over time to prevent indefinite starvation. A job's effective priority = base_priority - elapsed_time * decay_rate.
Level 3: Gang Scheduling & Multi-GPU Jobs
All queues must support gang scheduling (all-or-nothing allocation for multi-GPU jobs).
The scheduler must reserve a contiguous block of GPUs (same node or across nodes with NVLink/InfiniBand) for a job's full lifetime.
This prevents a 4-GPU training job from starting on 4 fragmented GPUs, causing poor communication and wasted time.
4. Resource Allocation & Reservation Strategy
Virtual Clusters / Partitions:
inference-reserved: A hard reservation (e.g., 30% of GPUs) always available for inference-pri, managed by an autoscaling inference service (KServe/TorchServe). This is the ultimate SLA guarantee.
dynamic-pool: The remaining GPUs (70%) are shared among notebook-pri and training-batch via the backfilling policy.
GPU Memory & Compute Quotas:
Set per-queue GPU memory caps (e.g., notebook jobs max 16GB, training can use full 80GB).
Use MPS (NVIDIA Multi-Process Service) on nodes with inference jobs to allow safe sharing of a single GPU by multiple inference containers. Notebooks should generally get exclusive GPUs.
Preemption Targets:
Preemption order: training -> notebook (if notebook time-slice expired) -> nothing (inference is king).
Grace Period: Preempted training jobs get 60-120 seconds to checkpoint and exit. notebook jobs get 30 seconds.
5. Implementation & Tooling Stack
Component
Recommended Tool
Role
Scheduler
Slurm (with gang scheduling, preempt/requeue, QOS) or Kubernetes (with Kueue, Volcano, k8s scheduler-plugins)
Core resource allocation & preemption engine.
Inference Serving
KServe, TorchServe, NVIDIA Triton
Manages the inference-reserved partition, autoscales replicas.
Job Submission
Wrapper Scripts/CLI that auto-tag jobs (--queue=notebook, --preemptible) and enforce standards (checkpointing).
User interface, policy enforcement at submission.
Monitoring & Metadata
Prometheus/Grafana + ML Metadata Store (Weights & Biases, MLflow)
Track queue times, GPU utilization by workload type, SLA violations.
Dashboard
Ganglia, Slurm UI, K8s Dashboard, or custom Grafana panel
Show cluster heatmap: which GPUs run what, queue lengths, preemption count.
Example Slurm QOS Configuration (Conceptual):
bash
# QOS for inference (highest)
QOS inference-pri
Priority=1000
MaxTruncate=INFINITE # Never preempted
MaxJobsPerUser=INFINITE
MaxSubmitJobs=INFINITE
# QOS for notebook
QOS notebook-pri
Priority=500
MaxTruncate=3600 # Max 1 hour before requeue
MaxJobsPerUser=4 # Fairness
# QOS for training (preemptible)
QOS training-batch
Priority=100
MaxTruncate=INFINITE # Can run forever if not preempted
Preemptible=YES
GraceTime=120 # Seconds to checkpoint
6. Policy Tuning & Operational Rules
Dynamic Priority Boosts: A job in training-batch that has waited >48hrs gets a temporary priority boost to prevent absolute starvation.
Burstable Notebook Reservations: During off-hours (e.g., weekends), the dynamic-pool can be temporarily enlarged for large training runs, with a prior announcement to notebook users.
Inference SLA Monitoring: If inference-pri jobs consistently miss P99 latency, the size of the inference-reserved partition must be increased (capacity planning trigger).
Checkpoint Mandate:training-batch jobs must specify a checkpoint interval (e.g., --checkpoint-freq 30min). Jobs without it get the lowest priority within their queue.
Idle GPU Reclamation: If the dynamic-pool is fully utilized by training but some inference pods are pending, soft-reserve GPUs from the training pool for inference (with a 5-minute warning to training jobs to checkpoint).
7. "Golden Rules" for Users & Admins
For Notebook Users: Use notebook-pri. Expect preemption after 1 hour. Always checkpoint.
For ML Engineers (Training): Use training-batch. Must implement robust checkpointing. Design experiments to be resumable. Don't expect a job to run uninterrupted for days.
For Inference DevOps: Use inference-pri and the inference-reserved partition. Monitor cluster load; if reservation is constantly full, buy more GPUs.
For Admins: The cluster is for production inference > interactive development > batch training. Regularly review preemption logs and SLA reports. Adjust partition sizes quarterly.
Summary & Trade-offs
Aspect
Policy Choice
Trade-off
Priority
Inference > Notebook > Training
Training jobs may have long, unpredictable waits.
** Utilization**
High via backfilling & preemption
Complexity in scheduling; potential for thrashing if not tuned.
Predictability
Low for training, High for inference & notebooks (due to reservations)
Training users must adapt to preemption.
Admin Overhead
Medium-High (needs monitoring & tuning)
Requires good tooling and clear user communication.
This policy shifts the cluster from a batch-oriented system to an SLA-aware, mixed-workload service. The key is enforcing that training is preemptible by design and insulating inference with hard reservations, while giving interactive users a responsive, fair experience. Start with conservative reservations, measure actual usage, and iterate.