You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/sleep_mode.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,9 @@ Key benefits:
13
13
!!! note
14
14
This feature is only supported on CUDA platform.
15
15
16
+
!!! note
17
+
For more information, see this [Blog Post](https://blog.vllm.ai/2025/10/26/sleep-mode.html).
18
+
16
19
## Sleep levels
17
20
18
21
Level 1 sleep will offload the model weights and discard the KV cache. The content of KV cache is forgotten. Level 1 sleep is good for sleeping and waking up the engine to run the same model again. The model weights are backed up in CPU memory. Please make sure there's enough CPU memory to store the model weights. Level 2 sleep will discard both the model weights and the KV cache (while the model's buffers are kept in CPU, like rope scaling tensors). The content of both the model weights and KV cache is forgotten. Level 2 sleep is good for sleeping and waking up the engine to run a different model or update the model, where previous model weights are not needed, e.g. RLHF weight update.
# Put the engine to sleep (level=1: offload weights to CPU RAM, discard KV cache)
35
39
llm.sleep(level=1)
36
40
37
41
# Wake up the engine (restore weights)
38
42
llm.wake_up()
39
43
```
40
44
45
+
```python
46
+
# Sleep level 2
47
+
# Put the engine to sleep (level=2: discard both weights and KV cache)
48
+
llm.sleep(level=2)
49
+
50
+
# Reallocate weights memory only
51
+
llm.wake_up(tags=["weights"])
52
+
53
+
# Load weights in-place
54
+
llm.collective_rpc("reload_weights")
55
+
56
+
# Reallocate KV cache
57
+
llm.wake_up(tags=["kv_cache"])
58
+
```
59
+
41
60
#### RLHF weight updates
42
61
43
62
During RLHF training, vLLM allows you to selectively wake up only the model weights or the KV cache using the tags argument in wake_up(). This fine-grained control is especially useful when updating model weights: by waking up just the weights (e.g., llm.wake_up(tags=["weights"])), you avoid allocating memory for the KV cache until after the weight update is complete. This approach helps prevent GPU out-of-memory (OOM) errors, particularly with large models, by minimizing peak memory usage during weight synchronization and update operations.
0 commit comments