| 257 | |
| 258 | @control_action_decorator |
| 259 | def sleep(self, sleep_tags: List[str]): |
| 260 | if not self.llm_args.enable_sleep: |
| 261 | raise ValueError( |
| 262 | "Sleep feature is not enabled, please set enable_sleep=True in the LLM arguments." |
| 263 | ) |
| 264 | try: |
| 265 | tags = verify_sleep_wakeup_tags(sleep_tags) |
| 266 | logger.info(f"Sleep: {tags}") |
| 267 | torch.cuda.synchronize() |
| 268 | release_with_tag(*tags) |
| 269 | torch.cuda.synchronize() |
| 270 | gc.collect() |
| 271 | torch.cuda.empty_cache() |
| 272 | except Exception as e: |
| 273 | logger.error(f"Encountered an error in sleep: {e}") |
| 274 | raise e |
| 275 | |
| 276 | @control_action_decorator |
| 277 | def wakeup(self, wakeup_tags: List[str]): |