Skip to content

Fix failing integration tests on Intel XPU (Arc Pro B60) - #49846

Open
jiqing-feng wants to merge 7 commits into
huggingface:mainfrom
jiqing-feng:xpu-integration-test-fixes
Open

jiqing-feng wants to merge 7 commits into
huggingface:mainfrom
jiqing-feng:xpu-integration-test-fixes

Conversation

@jiqing-feng

@jiqing-feng jiqing-feng commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🤗 Transformers CI

Fixes 13 slow integration tests that were failing on Intel XPU. Verified on 8x Intel Arc Pro B60 (get_device_properties() returns ("xpu", 5)), torch 2.14.0+xpu: 22/22 pass, 9/22 before.

Expected values for XPU gen-5

These tests already had expectations for other devices (and in a few cases for gen-3 Arc, whose values differ from B60). Added an ("xpu", 5) entry; no existing key was modified, so no other device is affected.

  • emu3 — test_model_generation_batched (needs torch >= 2.16 nightly; on 2.14/2.15 the fp32 SDPA kernel hits a device-side fault at this sequence length)
  • ernie4_5_vl_moe — test_small_model_integration_test_batch
  • falcon_h1 — test_falcon_h1_hard
  • fast_vlm — test_model_integration
  • internvl — test_llama_small_model_integration_generate
  • kosmos2_5 — test_sdpa
  • llava — test_pixtral_batched
  • llava_next_video — test_small_model_integration_test_batch_matches_single
  • llava_onevision — test_small_model_integration_test_multi_image
  • qwen2_5_vl — test_small_model_integration_test_with_video
  • voxtral_realtime — test_batched_longform
  • phi4_multimodal — test_vision_text_generation: the existing ("xpu", 5) value was recorded on different XPU hardware and does not reproduce on B60; updated to the B60 output.

Non-deterministic tests

Two tests produced a different output on nearly every run on XPU. Added the existing @require_deterministic_for_xpu decorator (already used by higgs_audio_v2 and elsewhere in tests/) to make them reproducible, then recorded the resulting stable output.

  • gemma3n — test_model_4b_bf16: three runs without the decorator gave three different outputs; three runs with it gave identical output. Note that ROCm already expects turquoise here instead of CUDA's clear blue, so this token is a known cross-device divergence point rather than an XPU defect.
  • deepseek_v2 — test_batch_fa2: the model is sharded with device_map="auto" and the test asserted a single hardcoded list. Converted to Expectations and added the decorator.

deepseek_v3::test_eager_matches_sdpa_generate

This test overrides the common one with a strict torch.testing.assert_close on token ids. The tiny fp16 checkpoint produces exactly tied top-2 logits for one of the prompts (eager sees 17.0 vs 16.98438, sdpa sees 17.0 vs 17.0), so argmax tie-breaking is arbitrary even though both kernels agree to within a single fp16 ULP — over non-pad positions max|eager - sdpa| is 0.015625, exactly 1 ULP at that magnitude. One flipped token at position 14 then cascades through the remaining 30. The large raw difference seen before masking comes entirely from fully-masked pad rows, which never reach the output.

This is not a new relaxation: the common test_eager_matches_sdpa_generate in GenerationTesterMixin already compares with assert_similar_generate_outputs, which accepts a token mismatch when the scores at the first mismatch are numerically equivalent. The override had opted out of it. Switched back to the shared helper (return_dict_in_generate / output_scores are needed to give it the scores), with atol sized for fp16 rather than the fp32-oriented 1e-3 default — a genuine kernel discrepancy is far above that. Result: 8/8 passes, vs 3/6 before.

Testing

RUN_SLOW=1 pytest tests/models/{deepseek_v2,deepseek_v3,ernie4_5_vl_moe,falcon_h1,fast_vlm,gemma3n,internvl,kosmos2_5,llava,llava_next_video,llava_onevision,phi4_multimodal,qwen2_5_vl,voxtral_realtime}

@jiqing-feng
jiqing-feng marked this pull request as ready for review October 22, 2026 06:35
@github-actions
github-actions Bot requested a review from ydshieh October 22, 2026 06:35
- gemma3n test_model_4b_bf16: add @require_deterministic_for_xpu (3 runs
  without it gave 3 different outputs) and record the resulting deterministic
  B60 output. Note ROCm already expects 'turquoise' here, so this token is a
  known cross-device divergence point.
- llava_next_video batch_matches_single: record both XPU expectations.
test_eager_matches_sdpa_generate overrode the common test with a strict
torch.testing.assert_close on token ids. The tiny fp16 checkpoint produces
exactly tied top-2 logits for one prompt (eager: 17.0 vs 16.98438, sdpa:
17.0 vs 17.0), so argmax tie-breaking is arbitrary even though both kernels
agree to within a single fp16 ULP: over non-pad positions max|eager-sdpa|
is 0.015625, exactly 1 ULP at that magnitude.

Use assert_similar_generate_outputs (as the common test does), which allows
a token mismatch when the scores at the first mismatch are numerically
equivalent. atol is sized for fp16 rather than the 1e-3 default.

Verified on Intel Arc Pro B60: 8/8 passes, vs 3/6 before.
The test sharded the model with device_map="auto" and asserted a single
hardcoded string, which alternated between two outputs across runs on XPU.
Adding @require_deterministic_for_xpu makes it reproducible (4/4 identical
runs), and the stable XPU output is recorded via Expectations.
@jiqing-feng
jiqing-feng force-pushed the xpu-integration-test-fixes branch from 87c4db5 to 6725cd7 Compare October 27, 2026 01:31
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: deepseek_v2, deepseek_v3, emu3, ernie4_5_vl_moe, falcon_h1, fast_vlm, gemma3n, internvl, kosmos2_5, llava, llava_next_video, llava_onevision, phi4_multimodal, qwen2_5_vl, voxtral_realtime

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants