Skip to content

[XPU][Attention] Enable per-sequence causal masking with FA2 - #57747

Draft
gc-fu wants to merge 1 commit into
vllm-project:mainfrom
gc-fu:feat/xpu-dynamic-causal-attention
Draft

gc-fu wants to merge 1 commit into
vllm-project:mainfrom
gc-fu:feat/xpu-dynamic-causal-attention

Conversation

@gc-fu

@gc-fu gc-fu commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Dependency and coordination

This PR depends on vllm-project/vllm-xpu-kernels#606 (or a release containing
that change), which adds the optional dynamic_causal FA2 argument.

Open PR #45774 overlaps the DiffusionGemma XPU startup portion but targets an
older tree and currently conflicts with main. It copies UVA inputs to XPU;
this change instead keeps the small sampler helpers eager and uses the current
mainline TP-local embedding matmul/all-reduce design.

Purpose

DiffusionGemma needs a per-sequence causal/bidirectional mask in one batch.
vLLM already builds int32[num_seqs] dynamic-causal metadata and symmetrizes a
causal sliding window for mixed batches, but the FlashAttention backend only
allowed this tensor with FA4 and the XPU wrapper did not forward it.

This change:

  • allows tensor causal metadata for XPU FA2 while retaining FA4 support;
  • forwards dynamic_causal through _xpu_ops.flash_attn_varlen_func to the
    kernel package and keeps the existing symmetric-window contract;
  • adds a standalone, non-default-CI GSM8K configuration for
    google/diffusiongemma-26B-A4B-it, runtime --quantization fp8, TP2,
    FLASH_ATTN, eager execution, and concurrency 2; and
  • keeps explicit DiffusionGemma sampler helpers eager on XPU and stores/casts
    self-conditioning state in the model dtype. These two current-main fixes are
    required for TP2 evaluation to reach attention: without them startup fails
    first on a Triton XPU pointer and then on an FP32/BF16 indexed assignment.

Test Plan

Focused unit tests:

.venv/bin/python -m pytest -q \
  tests/models/test_diffusion_gemma_xpu.py \
  tests/kernels/attention/test_xpu_dynamic_causal.py

Focused pre-commit:

pre-commit run --files \
  vllm/_xpu_ops.py \
  vllm/model_executor/models/diffusion_gemma.py \
  vllm/v1/attention/backends/flash_attn.py \
  tests/evals/gsm8k/configs/DiffusionGemma-26B-A4B-it-XPU-FA2-FP8.yaml \
  tests/kernels/attention/test_xpu_dynamic_causal.py \
  tests/models/test_diffusion_gemma_xpu.py

Full GSM8K qualification used a local mirror of the Google checkpoint and a
machine-local --gpu-memory-utilization 0.75 override; the committed YAML does
not include that machine-specific setting:

.venv/bin/python -m pytest -s -v \
  tests/evals/gsm8k/test_gsm8k_correctness.py \
  --config-list-file=/llm/artifacts/x07-dynamic-causal-20260920/gsm8k-full-final-list.txt

The upstream-style reproduction uses the committed config through a temporary
one-entry list:

printf '%s\n' \
  tests/evals/gsm8k/configs/DiffusionGemma-26B-A4B-it-XPU-FA2-FP8.yaml \
  > /tmp/diffusiongemma-xpu-gsm8k.txt
.venv/bin/python -m pytest -s -v \
  tests/evals/gsm8k/test_gsm8k_correctness.py \
  --config-list-file=/tmp/diffusiongemma-xpu-gsm8k.txt

Test Result

  • Focused unit tests: 5 passed.
  • Focused pre-commit: all applicable hooks passed.
  • Two-request smoke test: 2/2 questions, accuracy 1.0000, invalid rate 0,
    approximately 1.8 questions/s.
  • Full GSM8K: 1319/1319 valid responses, accuracy 0.9249, invalid rate 0,
    723.4 seconds, approximately 1.8 questions/s; acceptance floor is
    0.84 - 0.08 = 0.76.
  • The companion kernel correctness matrix passed 31 tests, including a mixed
    causal/bidirectional single launch and XPU graph replay.

pre-commit run --all-files was also attempted. Relevant code, formatting,
type, and metadata hooks passed. The overall command did not pass because
pip-compile-rocm regenerated requirements/test/rocm.txt with dependencies
from the shared XPU runtime (the generated change was restored), and
test-nonroot-entrypoint case 3 did not replace a read-only HOME with a
temporary home. These are environment-sensitive failures unrelated to the
changed files; they are not reported as passing.

An earlier full-run attempt used the harness default 600-second request
timeout. Because that timeout includes time waiting for the concurrency-2
connection pool, 224 queued requests timed out. That run was discarded and the
reported run changed only the request timeout to 1800 seconds.

Duplicate-work check

Repeated immediately before preparing this draft:

Limitations

Validation was performed on Intel Arc Pro B70 only, in the existing PyTorch
2.13.0+xpu environment. The companion kernel repository currently declares
PyTorch 2.14.0+xpu; that mismatch remains a validation limitation. The model
evaluation is intentionally not added to a default CI list.

AI assistance was used during implementation and validation. The human
submitter must review and understand every changed line before submission.

Signed-off-by: Guancheng Fu <guancheng.fu@intel.com>
@mergify mergify Bot added the intel-gpu Related to Intel GPU label Sep 20, 2026
@mergify

mergify Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @gc-fu.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

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

intel-gpu Related to Intel GPU needs-rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant