Put the engine to sleep. The engine should not process any requests. The caller should guarantee that no requests are being processed during the sleep period, before `wake_up` is called. Args: level: The sleep level. Level 1 sleep will offload the model
(self, level: int = 1)
| 1237 | return self.llm_engine.reset_prefix_cache(device) |
| 1238 | |
| 1239 | def sleep(self, level: int = 1): |
| 1240 | """ |
| 1241 | Put the engine to sleep. The engine should not process any requests. |
| 1242 | The caller should guarantee that no requests are being processed |
| 1243 | during the sleep period, before `wake_up` is called. |
| 1244 | |
| 1245 | Args: |
| 1246 | level: The sleep level. Level 1 sleep will offload the model |
| 1247 | weights and discard the kv cache. The content of kv cache |
| 1248 | is forgotten. Level 1 sleep is good for sleeping and waking |
| 1249 | up the engine to run the same model again. The model weights |
| 1250 | are backed up in CPU memory. Please make sure there's enough |
| 1251 | CPU memory to store the model weights. Level 2 sleep will |
| 1252 | discard both the model weights and the kv cache. The content |
| 1253 | of both the model weights and kv cache is forgotten. Level 2 |
| 1254 | sleep is good for sleeping and waking up the engine to run a |
| 1255 | different model or update the model, where previous model |
| 1256 | weights are not needed. It reduces CPU memory pressure. |
| 1257 | """ |
| 1258 | self.reset_prefix_cache() |
| 1259 | self.llm_engine.sleep(level=level) |
| 1260 | |
| 1261 | def wake_up(self, tags: Optional[list[str]] = None): |
| 1262 | """ |