[Tests][XPU] Limit Qwen2-VL generation length to avoid flaky numerical divergence (#54172)
Signed-off-by: Lin, Fanli <fanli.lin@intel.com> Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
Fanli Lin committed
Aug 31, 2026 at 22:59 UTC
82936c409d17321d5a791796296790508605aaed
1 file changed
+16
-8
tests/models/multimodal/generation/test_common.py
+16
-8
@@ -878,14 +878,22 @@ VLM_TEST_SETTINGS = {
878
multi_image_prompt="Picture 1: <vlm_image>\nPicture 2: <vlm_image>\nDescribe these two images with one paragraph respectively.", # noqa: E501
879
max_model_len=4096,
880
max_num_seqs=2,
881
- # torch 2.13 accumulates CPU numerical drift in the qwen2_vl multi-image
882
- # path: HF and vLLM agree for a long prefix (~69 tokens) then a token
883
- # flips outside vLLM's top-N only near the end of the generation. The
884
- # window is already at the max_logprobs=20 cap, so widening it further is
885
- # not possible. Treat this as acceptable drift and cap max_tokens on CPU
886
- # so the compared prefix stays before the divergence, keeping the
887
- # multi-image path under test. See pytorch/pytorch#187735.
888
- max_tokens=64 if current_platform.is_cpu() else 128,
881
+ # Qwen2-VL multi-image generation can accumulate backend-specific
882
+ # numerical drift during long autoregressive decoding.
883
+ #
884
+ # On CPU with torch 2.13, HF and vLLM agree for a long prefix before
885
+ # diverging near the end of generation. See pytorch/pytorch#187735.
886
+ #
887
+ # A similar late-generation divergence is observed on XPU with BF16
888
+ # ViT FlashAttention. The issue is not resolved by increasing
889
+ # num_logprobs from 10 to 20, while FP32 and BF16 with Triton ViT
890
+ # attention pass in local reproduction.
891
+ #
892
+ # Cap max_tokens on CPU and XPU to keep the correctness comparison
893
+ # before the numerically sensitive late-generation region.
894
+ max_tokens=64
895
+ if current_platform.is_cpu() or current_platform.is_xpu()
896
+ else 128,
897
num_logprobs=20 if current_platform.is_cpu() else 10,
898
auto_cls=AutoModelForImageTextToText,
899
vllm_output_post_proc=model_utils.qwen2_vllm_to_hf_output,