intel / intel/llm-scaler

[vLLM][XPU] torch.compile 预热后 LoRA 被静默跳过

Open
#634 0 comments 0 reactions 1 assignee Claimed by @liu-shaojun View on GitHub
Dominant language
C++
Stars
529
Forks
80
Avg merge
9h 7m
Merged PRs (30d)
38

Description

## 问题描述

在 Intel XPU 上使用 `intel/llm-scaler-vllm:0.21.0-b3.1` 部署
Qwen3-VL-8B 时,默认的 compiled execution path(`torch.compile`)会静默跳过
LoRA operations。

客户端通过 OpenAI-compatible API 的 `model` 字段明确请求已注册的 LoRA
adapter。adapter 能正常注册和选中,请求返回 HTTP 200,但返回内容仍呈现
base-model behavior,没有应用 LoRA delta。

`0.21.0-b1 + torch.compile` 和 `0.21.0-b3.1 + --enforce-eager` 均正常,只有
`0.21.0-b3.1 + torch.compile` 存在此 inference correctness regression。

## 受影响配置

- Regressed image:`intel/llm-scaler-vllm:0.21.0-b3.1`
- Working image:`intel/llm-scaler-vllm:0.21.0-b1`
- Base model:Qwen3-VL-8B
- Device:单张 Intel XPU
- Engine:vLLM V1,Tensor Parallel 1,XPU Graph disabled

两个镜像都基于上游 vLLM `v0.21.0` commit
`ad7125a431e176d4161099480a66f0169609a690`,但使用了不同版本的 llm-scaler
XPU patch。

## 最小复现

1. 使用 `0.21.0-b3.1` 启动 Qwen3-VL-8B,通过 `--enable-lora` 注册 adapter,
保持默认 `torch.compile` 开启。
2. 确认 adapter 已出现在 `/v1/models` 中。
3. 在请求的 `model` 字段中明确指定该 adapter。
4. 请求成功,但结果仍呈现 base-model behavior。
5. 使用 `--enforce-eager` 或切换到 `0.21.0-b1` 后,LoRA effect 恢复。

## 预期行为

当请求明确选择已注册的 adapter 时,eager execution path 和 compiled execution
path 都应正确应用 LoRA delta。

## 根因

PR #589 为 `PunicaWrapperXPU` 增加了 mutable host-side state:

```python
self.no_lora = not any(lora_id > 0 for lora_id in mapping.index_mapping)
```

并在五个 dense XPU Punica LoRA entry points 中增加 Python early return:

```python
if self.no_lora:
return
```

不含 adapter 的 profiling batch 使 compilation tracing 时
`self.no_lora=True`,因此 LoRA operations are pruned from the compiled graph。
后续请求即使正确更新 request-time mapping,也无法恢复已被移除的 operations。

## 对照验证

| Execution path | LoRA behavior |
|---|---|
| `0.21.0-b3.1 + torch.compile`(原始实现) | LoRA effect missing |
| `0.21.0-b3.1 + --enforce-eager` | LoRA effect present |
| `0.21.0-b3.1 + torch.compile`(应用建议修复后) | LoRA effect present |
| 应用建议修复后的 Base 请求 | Base-model behavior unchanged |

## 建议修复

保留 eager execution path 下的 no-adapter fast path,但在 compilation tracing
阶段避免基于 Python state 对 LoRA operations 做 graph pruning:

```python
def _should_skip_lora(self) -> bool:
return self.no_lora and not torch.compiler.is_compiling()
```

将五个 dense XPU Punica LoRA entry points 统一改为调用该 helper。

## 临时规避

使用 `--enforce-eager`,或继续使用 `intel/llm-scaler-vllm:0.21.0-b1`。

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.