Skip to content

[Bugfix][Hardware][Intel] MiniMax-H3: reuse the tiled-VAE gather buffer across requests on XPU - #6996

Closed
heyuanliu-intel wants to merge 1 commit into
vllm-project:mainfrom
heyuanliu-intel:pr/h3-klvae-gather-buffer-reuse
Closed

heyuanliu-intel wants to merge 1 commit into
vllm-project:mainfrom
heyuanliu-intel:pr/h3-klvae-gather-buffer-reuse

Conversation

@heyuanliu-intel

@heyuanliu-intel heyuanliu-intel commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Problem: the tiled video VAE gathers every rank's decoded tiles with a variable-shape all-gather whose output is allocated afresh each call. After the per-request empty_cache() the next gather lands at a new device address. On XPU the collective backend registers a device-side resource per new receive address and does not reclaim it, so device memory outside torch.xpu.memory_allocated() grows every request until the card is full. (Mechanism inferred from intervention experiments, not observed directly.)

Fix: keep one landing buffer per (shape, dtype, device) on the adapter and gather into it with all_gather_into_tensor; tiles are cloned out because the buffer is reused. Installed only when the adapter's device is XPU, bound on the checkpoint instance; other backends keep the checkpoint's own method. The buffer cache is uncapped on purpose: the key is the tile geometry, and evicting would re-register a new address.

Test Plan

Reproduce: 4 XPU cards, TP4/SP1, model-level offload on, send three identical t2va requests (1344x768, 209 frames, 2 steps) and sample each rank's non-PyTorch device memory between requests: it climbs monotonically while memory_allocated() stays flat.

pytest -q tests/diffusion/models/minimax_h3/test_minimax_h3_vae_gather_reuse.py

vLLM Version: as pinned by requirements/. vLLM-Omni Commit: rebased onto current main.

Test Result

CPU tests pass (XPU-only install, tile order for even and uneven shares, buffer reuse at same geometry, tiles survive the next gather). On the 4-card A/B, non-PyTorch peak growth from request 1 to 2 dropped from 6617.69 MiB to 4008.76 MiB per rank (-39.4%); worst-rank free memory at request 2 rose from 2.93 MiB to 1662.50 MiB. Growth is reduced, not eliminated.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@vllm-omni-review-bot

Copy link
Copy Markdown

This PR appears to be related to model: MinimaxH3.

Model owners: @david6666666

@heyuanliu-intel, please review your own changes and leave a short self-review comment describing what you checked. PRs without author self-review may not be assigned a reviewer.

Please take a look when you have a chance. If you would like an automated review, mention @vllm-omni-review-bot in a comment.

@vllm-omni-review-bot

vllm-omni-review-bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Omni ReviewBot triage note

Resolved as of 72fe1b623f72: the high-priority or low-quality signal noted on an earlier commit no longer applies.

…er across requests on XPU

## Purpose

**Problem:** the tiled video VAE gathers every rank's decoded tiles with a variable-shape all-gather whose output is allocated afresh each call. After the per-request `empty_cache()` the next gather lands at a new device address. On XPU the collective backend registers a device-side resource per new receive address and does not reclaim it, so device memory outside `torch.xpu.memory_allocated()` grows every request until the card is full. (Mechanism inferred from intervention experiments, not observed directly.)

**Fix:** keep one landing buffer per (shape, dtype, device) on the adapter and gather into it with `all_gather_into_tensor`; tiles are cloned out because the buffer is reused. Installed only when the adapter's device is XPU, bound on the checkpoint instance; other backends keep the checkpoint's own method. The buffer cache is uncapped on purpose: the key is the tile geometry, and evicting would re-register a new address.

## Test Plan

**Reproduce:** 4 XPU cards, TP4/SP1, model-level offload on, send three identical t2va requests (1344x768, 209 frames, 2 steps) and sample each rank's non-PyTorch device memory between requests: it climbs monotonically while `memory_allocated()` stays flat.

```bash
pytest -q tests/diffusion/models/minimax_h3/test_minimax_h3_vae_gather_reuse.py
```

**vLLM Version:** as pinned by `requirements/`. **vLLM-Omni Commit:** rebased onto current `main`.

## Test Result

CPU tests pass (XPU-only install, tile order for even and uneven shares, buffer reuse at same geometry, tiles survive the next gather). On the 4-card A/B, non-PyTorch peak growth from request 1 to 2 dropped from 6617.69 MiB to 4008.76 MiB per rank (-39.4%); worst-rank free memory at request 2 rose from 2.93 MiB to 1662.50 MiB. Growth is reduced, not eliminated.

Signed-off-by: heyuanliu-intel <heyuan.liu@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working diffusion codes related to diffusion models xpu PR related to XPU

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants