Skip to content

[rl] vLLM watermark as a VLLMEngine.Config field, default 0.1 - #5951

Merged
felipemello1 merged 1 commit into
mainfrom
felipemello1/vllm-watermark/1-engine-field
Nov 9, 2026
Merged

felipemello1 merged 1 commit into
mainfrom
felipemello1/vllm-watermark/1-engine-field

Conversation

@felipemello1

@felipemello1 felipemello1 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

If kv cache reaches 100%, any new request will case preemption, non stop. This crashes the generator. Watermark at 0.1 doesn't allow new requests to be added until kv cache < 90%.

Agent details

NOTE: measured on H100 only; needs retesting on Blackwell. The one Blackwell run we know of (last NOTE) is KV-full, and the effect of 0.1 there is unknown.

TLDR: VLLMEngine.Config.watermark exposes vLLM's KV admission reserve and defaults it to 0.1 (vLLM's default is 0.0). On one H100 9B engine that preempts a lot, 0.1 cuts preemptions 783 -> 11 and wall time 8.6%.

10,000 KV blocks, 500 free, a waiting request needs 100 (400 free after)
watermark=0.0    admitted                              main (vLLM's default)
watermark=0.1    waits (400 < 1,000 must stay free)    this PR: admit only while KV usage stays <= 90%
Running requests are not checked. With no request running, vLLM admits at any watermark.

Problem

  1. vLLM admits a waiting request whenever its KV blocks fit at that moment.
  2. Each running request then needs more blocks as it decodes.
  3. When no block is free, vLLM preempts a running request and later recomputes it.
  4. One H100, Qwen3.5-9B, KV pool cut to 992 blocks: 783 preemptions in a 149.7 s run.
  5. TorchTitan reaches vLLM's watermark only through extra_engine_args, and no recipe sets it.

Solution

  1. VLLMEngine.Config.watermark: float = 0.1, passed to EngineArgs by VLLMEngine and by generate.py.
  2. extra_engine_args={"watermark": ...} raises ValueError and names the field, like the other keys TorchTitan sets.
  3. Unchanged: every other engine argument. vLLM checks the range.

Results

One H100, Qwen3.5-9B TP1, vLLM 9f03b510c, token budget per step (`max_num_batched_tokens`) 2,048. Watermark values switched in one process on the
same seeded load; wall time, mean of 2 reps.
Single-turn math: groups of 16, 300-token prompt, output lognormal (median 768, cap 3,072),
768 sequences with 512 in flight, max_num_seqs 512, FULL graphs.

KV pool                        wm 0.0    wm 0.03            wm 0.1             preemptions (0 / 0.03 / 0.1)
992 blocks (pressured)         149.7 s   135.5 s (-9.5%)    136.9 s (-8.6%)    783 / 58 / 11
4,067 blocks (peak ~43% KV)    123.1 s   122.8 s (-0.2%)    not run            0 / 0
Multi-turn, 4-10 turns, FULL_DECODE_ONLY, 48 sessions, gpu_memory_limit 0.9:
                               180.9 s   181.7 s (+0.4%)    not run            0 / 0
  • 0.1 removes almost every preemption but runs fewer requests at once (6,319 engine steps vs 6,077 at 0.03), so it ends behind 0.03.
  • A CPU model of vLLM's scheduler (10 single-turn workloads) ranks 0.01-0.03 best and puts 0.1 below 0.0 in 8 of 10 workloads (worst: -11.1% vs the best value).

You may ask:

  • Why 0.1, not 0.03? 0.03 was ~1 point faster here, with 5x the preemptions (58 vs 11). 0.1 guards against preemption churn on shapes nobody measured, at the cost of up to ~10% fewer running requests when KV is full. A recipe that measures a better value sets its own, including 0.0.
  • Why a reserve by default? SGLang keeps one by default: its scheduler holds back an estimated share of each running request's remaining output (capped at 4,096 tokens per request).
  • Why a field, not extra_engine_args? A default needs a field.

NOTE: this changes engine admission for every RL recipe and for generate.py.
NOTE: 0.1 was not run on the unpressured or the multi-turn shape; only 0.03 was, with no change.
NOTE: with session_kv_holder on, the holder's free-block floor includes the watermark (session_kv_holder.py:84), so it releases held sessions earlier. No recipe turns the holder on.
NOTE: anything that sets watermark through extra_engine_args must move to the field, or it raises. No recipe in this repo does.
NOTE: Blackwell: a GB300 Qwen3.5-35B-A3B math run sat at 99% KV for hours (~355 running and ~150 waiting per engine, watermark 0.0). Its preemption count is unknown: vLLM's stat line resets the counter before printing it, so Preemptions: never shows. So 0.1 may help there (fewer preemptions) or cost (fewer running; the CPU model says 6-9%). Not measured.

Test plan

pytest -q tests/rl/unit_tests/cpu   # with the verifiers package installed: 625 passed, 1 skipped vs 624 / 1 on main
pre-commit run --files <changed files>
pyrefly check   # project mode, 0.45.1: 924 errors on main and here, none in the changed files
  • test_engine_config_reaches_engine_args: a 0.03 watermark and an extra engine argument both reach EngineArgs.
  • test_extra_engine_args_rejects_torchtitan_owned_keys[watermark].

@pytorch-bot pytorch-bot Bot added the ciflow/rl label Nov 8, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 8, 2026
@felipemello1
felipemello1 marked this pull request as ready for review November 8, 2026 23:55
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Nov 8, 2026
@github-actions
github-actions Bot requested a review from pzhan9 November 8, 2026 23:55
@felipemello1
felipemello1 merged commit eabd60d into main Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants