Papers
Topics
Authors
Recent
Search
2000 character limit reached

MC-SF Scheduling: Memory-Constrained LLM Serving

Updated 18 November 2025
  • Memory-Constrained Shortest-First (MC-SF) is a scheduling heuristic that prioritizes jobs by their decode lengths while managing dynamically changing KV-cache memory during LLM serving.
  • The algorithm builds batches greedily by adding jobs in ascending decode order, ensuring that the cumulative memory usage remains within set limits for future processing steps.
  • MC-SF demonstrates a suboptimal competitive ratio of Ω(√M) under memory heterogeneity, which has motivated the development of improved strategies like the Sorted-F rule.

The memory-constrained Shortest-First (MC-SF) algorithm is a scheduling heuristic designed for online LLM serving with heterogeneous user requests. Each request consists of an input “prefill” phase (prompt tokens) and a sequential “decode” phase (output tokens), both of which consume dynamically changing key-value (KV) cache memory. MC-SF extends the classical Shortest-First (SF) principle to this modern, memory-bounded setting in which batching and memory utilization provide significant trade-offs. The approach, initially analyzed in the context of LLM-serving optimization by Jaillet et al. (2025), is notable for its suboptimality under memory heterogeneity and motivates robust alternatives based on more nuanced selection metrics (Wang et al., 8 Aug 2025).

1. Formal Model of Memory-Constrained LLM Scheduling

Consider nn jobs, all arriving at time $0$, each specified by a prefill length pip_i (input prompt tokens) and decode length did_i (number of sequential output tokens to be generated), for i{1,,n}i \in \{1, \dotsc, n\}. A single GPU worker provides limited KV-cache memory, MM. When any request ii has generated aia_i output tokens (0aidi0 \leq a_i \leq d_i), its KV-cache memory footprint is

memi(ai)=pi+ai.\mathrm{mem}_i(a_i) = p_i + a_i.

At each discrete time $0$0, a batch $0$1 of pending jobs can be started or continued—performing exactly one parallel decode step per job—subject to the requirement that, for all future $0$2, the total memory across all jobs (started and pending) does not exceed $0$3:

$0$4

where $0$5 is the set of already-started, unfinished jobs. Request $0$6 completes when its $0$7-th output token is generated; total end-to-end latency (TEL) is

$0$8

where $0$9 is the completion time of request pip_i0 under schedule pip_i1 (Wang et al., 8 Aug 2025).

2. The Memory-Constrained Shortest-First (MC-SF) Rule

The MC-SF scheduling rule prioritizes pending jobs in ascending order of decode length pip_i2, greedily filling each batch with the “shortest-decode” jobs as long as the cumulative worst-case memory across all jobs (current set plus candidate additions) remains feasible for all future steps. Specifically, at time pip_i3:

  • Define pip_i4 as the set of pending jobs.
  • Sort pip_i5 by pip_i6.
  • Iteratively add jobs to a candidate batch pip_i7 from this ordering until including another job would violate:

pip_i8

  • All jobs in pip_i9 are launched in parallel for one decode token, and completed jobs are removed; the process repeats at did_i0 (Wang et al., 8 Aug 2025).

3. Competitive Ratio Lower Bound for MC-SF

The competitive ratio (CR) of a scheduling heuristic is defined as the worst-case ratio over all instances of its total end-to-end latency (TEL) to that of the offline optimal. For MC-SF, the following holds:

did_i1

specifically demonstrated via a constructed instance with

did_i2

as did_i3 increases (Wang et al., 8 Aug 2025). Thus, MC-SF's relative inefficiency grows without bound in the memory-rich regime.

4. Construction and Analysis of the Ω(√M) Lower Bound

A worst-case scenario illustrating MC-SF’s suboptimality is constructed as follows:

  • Type 1 jobs: did_i4 requests with did_i5
  • Type 2 jobs: did_i6 requests with did_i7

Under MC-SF, all Type 1 jobs (with did_i8) run first, each requiring about did_i9 memory per request, so only i{1,,n}i \in \{1, \dotsc, n\}0 can run in parallel per batch, necessitating approximately i{1,,n}i \in \{1, \dotsc, n\}1 batches (waves) and producing total TEL i{1,,n}i \in \{1, \dotsc, n\}2. The subsequent Type 2 jobs (with i{1,,n}i \in \{1, \dotsc, n\}3) are processed in larger batches, with total TEL i{1,,n}i \in \{1, \dotsc, n\}4. In contrast, the optimal schedule reverses the order, with both job types processed in parallel batches of size i{1,,n}i \in \{1, \dotsc, n\}5, resulting in TEL i{1,,n}i \in \{1, \dotsc, n\}6 for all jobs—yielding a competitive ratio i{1,,n}i \in \{1, \dotsc, n\}7 (Wang et al., 8 Aug 2025).

5. Pseudocode Implementation and Computational Complexity

The MC-SF algorithm’s workflow and computational characteristics are as follows:

ii9 At each time step i{1,,n}i \in \{1, \dotsc, n\}8, up to i{1,,n}i \in \{1, \dotsc, n\}9 jobs are scanned and for each, an MM0 memory feasibility check is required, or equivalently an MM1 future-step search. The number of time steps is bounded by MM2, leading to a worst-case runtime of MM3, precluding practical use for MM4, MM5 in the thousands (Wang et al., 8 Aug 2025).

6. Regimes of Failure and Algorithmic Remedies

MC-SF fails when prompt sizes MM6 vary significantly compared to decode lengths MM7, as simply sorting by MM8 disregards substantial KV-cache occupancy by jobs with large MM9. The aforementioned lower bound exploits such heterogeneity. The principal remedies, as introduced in (Wang et al., 8 Aug 2025), include:

  1. Batch quality metric ii0: For any batch ii1, define

ii2

and at each time step, select the subset ii3 minimizing ii4 (subject to memory capacity). This “Sorted-F” rule balances prompt size and decode length.

  1. Constant competitive ratio: Sorted-F achieves a constant CR (ii5), independent of ii6.
  2. Accelerated approximations: Further speedups are enabled by dynamic programming, local search, quantile-greedy strategies, and LP-based heuristics.

The incorporation of both ii7 and ii8 in selection resolves MC-SF’s vulnerability, particularly under non-uniform prompt distributions (Wang et al., 8 Aug 2025).

7. Context and Significance

MC-SF formalizes a practical but fundamentally limited class of greedy scheduling policies for modern LLM service systems subject to severe KV-cache constraints. While effective for jobs with uniform or near-uniform prompt sizes, it demonstrates provable inefficiency under prompt heterogeneity, as established both analytically and with explicit lower bounds. These findings have prompted the adoption of more sophisticated metrics and batch selection strategies that incorporate both prefill and decode characteristics. The Sorted-F rule, as well as dynamically informed batch optimization, now represent the state-of-the-art in this scheduling regime, substantially outperforming MC-SF and related heuristics while retaining computational practicality (Wang et al., 8 Aug 2025).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Memory-Constrained Shortest-First Scheduling Algorithm (MC-SF).