Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
fe3b9372
Unverified
Commit
fe3b9372
authored
Oct 16, 2025
by
Nick Hill
Committed by
GitHub
Oct 17, 2025
Browse files
[Core] Change `execute_model_with_error_logging()` to be a ctx manager (#27060)
Signed-off-by:
Nick Hill
<
nhill@redhat.com
>
parent
bde9e227
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
+11
-15
vllm/v1/engine/core.py
vllm/v1/engine/core.py
+11
-15
No files found.
vllm/v1/engine/core.py
View file @
fe3b9372
...
@@ -290,14 +290,11 @@ class EngineCore:
...
@@ -290,14 +290,11 @@ class EngineCore:
# (i.e. client-aborted vs stop criteria met).
# (i.e. client-aborted vs stop criteria met).
self
.
scheduler
.
finish_requests
(
request_ids
,
RequestStatus
.
FINISHED_ABORTED
)
self
.
scheduler
.
finish_requests
(
request_ids
,
RequestStatus
.
FINISHED_ABORTED
)
def
execute_model_with_error_logging
(
@
contextmanager
self
,
def
log_error_detail
(
self
,
scheduler_output
:
SchedulerOutput
):
model_fn
:
Callable
[[
SchedulerOutput
],
ModelRunnerOutput
],
scheduler_output
:
SchedulerOutput
,
)
->
ModelRunnerOutput
:
"""Execute the model and log detailed info on failure."""
"""Execute the model and log detailed info on failure."""
try
:
try
:
return
model_fn
(
scheduler_output
)
yield
except
Exception
as
err
:
except
Exception
as
err
:
# We do not want to catch BaseException here since we're only
# We do not want to catch BaseException here since we're only
# interested in dumping info when the exception is due to an
# interested in dumping info when the exception is due to an
...
@@ -321,15 +318,16 @@ class EngineCore:
...
@@ -321,15 +318,16 @@ class EngineCore:
if
not
self
.
scheduler
.
has_requests
():
if
not
self
.
scheduler
.
has_requests
():
return
{},
False
return
{},
False
scheduler_output
=
self
.
scheduler
.
schedule
()
scheduler_output
=
self
.
scheduler
.
schedule
()
model_output
=
self
.
execute_model_with_error_logging
(
self
.
model_executor
.
execute_model
,
# type: ignore
with
self
.
log_error_detail
(
scheduler_output
):
scheduler_output
,
model_output
=
self
.
model_executor
.
execute_model
(
scheduler_output
)
)
assert
isinstance
(
model_output
,
ModelRunnerOutput
)
engine_core_outputs
=
self
.
scheduler
.
update_from_output
(
engine_core_outputs
=
self
.
scheduler
.
update_from_output
(
scheduler_output
,
model_output
scheduler_output
,
model_output
)
)
return
(
engine_core_outputs
,
scheduler_output
.
total_num_scheduled_tokens
>
0
)
return
engine_core_outputs
,
scheduler_output
.
total_num_scheduled_tokens
>
0
def
post_step
(
self
,
model_executed
:
bool
)
->
None
:
def
post_step
(
self
,
model_executed
:
bool
)
->
None
:
if
self
.
use_spec_decode
and
model_executed
:
if
self
.
use_spec_decode
and
model_executed
:
...
@@ -386,14 +384,12 @@ class EngineCore:
...
@@ -386,14 +384,12 @@ class EngineCore:
# Block until the next result is available.
# Block until the next result is available.
future
,
scheduler_output
=
batch_queue
.
pop
()
future
,
scheduler_output
=
batch_queue
.
pop
()
model_output
=
self
.
execute_model_with_error_logging
(
with
self
.
log_error_detail
(
scheduler_output
):
lambda
_
:
future
.
result
(),
scheduler_output
model_output
=
future
.
result
()
)
engine_core_outputs
=
self
.
scheduler
.
update_from_output
(
engine_core_outputs
=
self
.
scheduler
.
update_from_output
(
scheduler_output
,
model_output
scheduler_output
,
model_output
)
)
return
engine_core_outputs
,
model_executed
return
engine_core_outputs
,
model_executed
def
shutdown
(
self
):
def
shutdown
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment