Enhance error handling in output processing for multimodal tensors
- Added logging for exceptions during tensor movement to CPU in OmniRequestState and MultimodalOutputProcessor. - Improved robustness by ensuring the output pipeline continues without crashing on errors. - Updated comments for clarity on error handling behavior.
This commit is contained in:
1 parent
b4fa09f756
commit
6b196dee24
1 file changed
+11
-11
@@ -91,13 +91,15 @@ class OmniRequestState(RequestState):
|
|||||||
try:
|
try:
|
||||||
t = t.to("cpu")
|
t = t.to("cpu")
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
# Best-effort CPU move; keep original device if conversion fails
|
||||||
|
logger.debug("Failed to move multimodal tensor to CPU", exc_info=True)
|
||||||
if self.mm_accumulated is None:
|
if self.mm_accumulated is None:
|
||||||
self.mm_accumulated = t
|
self.mm_accumulated = t
|
||||||
else:
|
else:
|
||||||
self.mm_accumulated = torch.cat([self.mm_accumulated, t], dim=0)
|
self.mm_accumulated = torch.cat([self.mm_accumulated, t], dim=0)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
# Log and continue without crashing the output pipeline
|
||||||
|
logger.exception("Error accumulating multimodal tensor")
|
||||||
|
|
||||||
# Override: do not route to pooling-only path; always create completion
|
# Override: do not route to pooling-only path; always create completion
|
||||||
# outputs, and attach pooling_result into the CompletionOutput.
|
# outputs, and attach pooling_result into the CompletionOutput.
|
||||||
@@ -153,14 +155,13 @@ class OmniRequestState(RequestState):
|
|||||||
try:
|
try:
|
||||||
tensor = tensor.detach().to("cpu")
|
tensor = tensor.detach().to("cpu")
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
logger.debug("Failed to move accumulated multimodal tensor to CPU", exc_info=True)
|
||||||
# Attach on the completion output for downstream consumers.
|
# Attach on the completion output for downstream consumers.
|
||||||
if not hasattr(base_output, "multimodal_output"):
|
if not hasattr(base_output, "multimodal_output"):
|
||||||
setattr(base_output, "multimodal_output", {})
|
setattr(base_output, "multimodal_output", {})
|
||||||
setattr(base_output, "multimodal_output", {self.mm_type: tensor})
|
setattr(base_output, "multimodal_output", {self.mm_type: tensor})
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning("Error in _new_completion_output", e)
|
logger.exception("Error in _new_completion_output")
|
||||||
pass
|
|
||||||
return base_output
|
return base_output
|
||||||
|
|
||||||
|
|
||||||
@@ -265,7 +266,7 @@ class MultimodalOutputProcessor(VLLMOutputProcessor):
|
|||||||
if pooling_output is not None and isinstance(req_state, OmniRequestState):
|
if pooling_output is not None and isinstance(req_state, OmniRequestState):
|
||||||
req_state.add_multimodal_tensor(pooling_output, mm_type)
|
req_state.add_multimodal_tensor(pooling_output, mm_type)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
logger.debug("Failed to accumulate multimodal tensor for request %s", req_id, exc_info=True)
|
||||||
|
|
||||||
# 3) Create RequestOutput objects, forcing combined mode to keep ids
|
# 3) Create RequestOutput objects, forcing combined mode to keep ids
|
||||||
pooling_for_make = pooling_output
|
pooling_for_make = pooling_output
|
||||||
@@ -285,9 +286,8 @@ class MultimodalOutputProcessor(VLLMOutputProcessor):
|
|||||||
if not hasattr(ro, "multimodal_output"):
|
if not hasattr(ro, "multimodal_output"):
|
||||||
setattr(ro, "multimodal_output", {})
|
setattr(ro, "multimodal_output", {})
|
||||||
ro.multimodal_output[mm_key] = req_state.mm_accumulated
|
ro.multimodal_output[mm_key] = req_state.mm_accumulated
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning("Error in process_outputs", e)
|
logger.exception("Error attaching multimodal payload in process_outputs")
|
||||||
pass
|
|
||||||
if req_state.queue is not None:
|
if req_state.queue is not None:
|
||||||
req_state.queue.put(ro)
|
req_state.queue.put(ro)
|
||||||
else:
|
else:
|
||||||
@@ -323,7 +323,7 @@ class MultimodalOutputProcessor(VLLMOutputProcessor):
|
|||||||
self.output_handlers[output_type](eco)
|
self.output_handlers[output_type](eco)
|
||||||
# Fall through to default fixups in case the handler left gaps
|
# Fall through to default fixups in case the handler left gaps
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
logger.exception("Error in custom output handler for %s", output_type)
|
||||||
|
|
||||||
if output_type == "image":
|
if output_type == "image":
|
||||||
self._process_image_output(eco)
|
self._process_image_output(eco)
|
||||||
|
|||||||
Reference in new issue
Block a user