@@ -111,6 +111,10 @@ def _to_cpu(x):
111111 return x
112112
113113 if isinstance (payload , dict ):
114+ logger .info (
115+ f"[DEBUG add_multimodal_tensor] payload is dict with keys: { list (payload .keys ())} , "
116+ f"mm_type={ self .mm_type } "
117+ )
114118 incoming : Dict [str , Any ] = {}
115119 # Optional remap: if producer used "model_outputs" or "hidden", rename to mm_type
116120 # to keep a consistent key namespace per engine_core_output_type.
@@ -125,8 +129,10 @@ def _to_cpu(x):
125129 incoming [k ] = {str (sk ): _to_cpu (sv ) for sk , sv in v .items ()}
126130 else :
127131 incoming [k ] = _to_cpu (v )
132+ logger .info (f"[DEBUG add_multimodal_tensor] incoming dict has keys: { list (incoming .keys ())} " )
128133 else :
129134 key = self .mm_type or "hidden"
135+ logger .info (f"[DEBUG add_multimodal_tensor] payload is NOT dict, wrapping as: {{'{ key } ': payload}}" )
130136 incoming = {key : _to_cpu (payload )}
131137
132138 if self .mm_accumulated is None :
@@ -380,6 +386,14 @@ def process_outputs(
380386 # 2.5) Accumulate multimodal tensors in RequestState
381387 try :
382388 mm_type = (getattr (eco , "output_type" , self .engine_core_output_type ) or "" ).lower ()
389+ logger .info (
390+ f"[DEBUG process_outputs] req_id={ req_id } , mm_type={ mm_type } ,"
391+ f"pooling_output type: { type (pooling_output )} "
392+ )
393+ if isinstance (pooling_output , dict ):
394+ logger .info (
395+ f"[DEBUG process_outputs] pooling_output is dictwith keys: { list (pooling_output .keys ())} "
396+ )
383397 if pooling_output is not None and isinstance (req_state , OmniRequestState ):
384398 req_state .add_multimodal_tensor (pooling_output , mm_type )
385399 except Exception :
@@ -497,9 +511,27 @@ def _process_text_image_output(self, eco: EngineCoreOutput) -> None:
497511 def _process_latents_output (self , eco : EngineCoreOutput ) -> None :
498512 """Ensure latent tensors are surfaced via pooling_output."""
499513 if eco .pooling_output is None :
514+ # DEBUG: Log what we're processing
515+ mm = getattr (eco , "multimodal_outputs" , None )
516+ logger .info (f"[DEBUG _process_latents_output] multimodal_outputs type: { type (mm )} " )
517+ if isinstance (mm , dict ):
518+ logger .info (f"[DEBUG _process_latents_output] multimodal_outputs keys: { list (mm .keys ())} " )
519+
500520 tensor = self ._extract_from_multimodal_outputs (eco , keys = ("latent" , "latents" , "z" , "posterior" ))
521+ logger .info (
522+ f"[DEBUG _process_latents_output] extracted tensor type: { type (tensor )} , "
523+ f"is dict: { isinstance (tensor , dict )} "
524+ )
501525 if tensor is not None :
502526 eco .pooling_output = tensor
527+ logger .info ("[DEBUG _process_latents_output] set eco.pooling_output to extracted tensor" )
528+ else :
529+ # pooling_output already set (likely from scheduler with full dict)
530+ logger .info (f"[DEBUG _process_latents_output] pooling_output already set, type: { type (eco .pooling_output )} " )
531+ if isinstance (eco .pooling_output , dict ):
532+ logger .info (
533+ f"[DEBUG _process_latents_output] pooling_output dict keys: { list (eco .pooling_output .keys ())} "
534+ )
503535
504536 def _process_audio_output (self , eco : EngineCoreOutput ) -> None :
505537 """Ensure audio tensors are surfaced via pooling_output."""
@@ -532,9 +564,15 @@ def _extract_from_multimodal_outputs(self, eco: EngineCoreOutput, keys: tuple[st
532564 for k in keys :
533565 v = mm .get (k )
534566 if isinstance (v , torch .Tensor ):
567+ logger .info (f"[DEBUG _extract_from_multimodal_outputs] Found key '{ k } ' in multimodal_outputs" )
535568 return v
536569 # Try the first tensor in the dict as a fallback
537- for v in mm .values ():
570+ logger .info (f"[DEBUG _extract_from_multimodal_outputs] No matching keys { keys } , using fallback (first tensor)" )
571+ for k , v in mm .items ():
538572 if isinstance (v , torch .Tensor ):
573+ logger .info (
574+ f"[DEBUG _extract_from_multimodal_outputs] Fallback: extracted first"
575+ f" tensor with key '{ k } ', shape: { v .shape } "
576+ )
539577 return v
540578 return None
0 commit comments