Skip to content

Commit aa28708

Browse files
✅ add assertions for warmup mode context
Signed-off-by: Prashant Gupta <[email protected]>
1 parent 377895d commit aa28708

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

vllm_spyre/v1/worker/spyre_worker.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,21 @@
3333

3434
logger = init_logger(__name__)
3535

36+
# var to make sure we always warmup with the right context
37+
_inside_warmup_mode = False
38+
3639

3740
@contextlib.contextmanager
3841
def _maybe_warmup_context():
42+
global _inside_warmup_mode
3943
warmup_context = contextlib.nullcontext
4044
if envs_spyre.VLLM_SPYRE_DYNAMO_BACKEND == "sendnn":
4145
from torch_sendnn import warmup_mode
4246
warmup_context = warmup_mode
4347
with warmup_context():
48+
_inside_warmup_mode = True
4449
yield
50+
_inside_warmup_mode = False
4551

4652

4753
class SpyreWorker(WorkerBaseV1):
@@ -351,6 +357,8 @@ def _warmup_spyre_dynamic_size(self, special_token_ids):
351357
grammar_bitmask=None,
352358
)
353359
logger.info("[WARMUP] Prefill %d/%d...", i + 1, batch_size)
360+
assert _inside_warmup_mode, \
361+
"it looks like you are outside the warmup context for prefill"
354362
self.execute_model(scheduler_output)
355363

356364
# one decode iteration across all sequences
@@ -391,6 +399,8 @@ def _warmup_spyre_dynamic_size(self, special_token_ids):
391399
grammar_bitmask=None,
392400
)
393401
logger.info("[WARMUP] Decode...")
402+
assert _inside_warmup_mode, \
403+
"it looks like you are outside the warmup context for decode"
394404
self.execute_model(scheduler_output)
395405
self._cleanup_model_runner(request=dummy_requests)
396406

0 commit comments

Comments
 (0)