fix(config): guard LlamaBidirectionalConfig against missing hf_config.pooling (#50536)
Signed-off-by: Chenglun Hu <chenglunhu@gmail.com>
hcl committed
Aug 27, 2026 at 18:56 UTC
42e7942ac94309ad749c0091b1275bb7d7b22aea
1 file changed
+12
-2
vllm/model_executor/models/config.py
+12
-2
@@ -549,9 +549,19 @@ class LlamaBidirectionalConfig(VerifyAndUpdateConfig):
549
"last": "LAST",
550
}
551
552
- pooling_type = pooling_type_map.get(hf_config.pooling)
552
+ pooling = getattr(hf_config, "pooling", None)
553
+ if pooling is None:
554
+ raise ValueError(
555
+ "This bidirectional model requires a 'pooling' field in its HF "
556
+ "config (one of 'avg', 'cls', 'last'), but none was found. "
557
+ "Unlike the VL variants, no default is assumed here because "
558
+ "silently picking a pooling for an embedding model can produce "
559
+ "wrong embeddings."
560
+ )
561
+
562
+ pooling_type = pooling_type_map.get(pooling)
563
if pooling_type is None:
554
- raise ValueError(f"pool_type {hf_config.pooling!r} not supported")
564
+ raise ValueError(f"pool_type {pooling!r} not supported")
565
566
assert model_config.pooler_config is not None
567
model_config.pooler_config.seq_pooling_type = pooling_type