Fix: Prevent Runtime Crashes in MiniCPM-V/O Multimodal Inference on CUDA and XPU - #43760
weizhoublue wants to merge 2 commits into
Conversation
|
Hi @weizhoublue, the pre-commit checks have failed. Please run: uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-filesThen, commit the changes and push to your branch. For future commits, Tip Is
|
Signed-off-by: weizhoublue <weizhou.lan@daocloud.io>
ae01567 to
3789b74
Compare
|
This is a clean, complete fix for the device mismatch. I traced both sites:
I also grepped the module for other Minimal, surgical, and the device source is provably the right one. LGTM. (Optional: a one-line CUDA/XPU smoke test in CI asserting |
Signed-off-by: weizhoublue <weizhou.lan@daocloud.io>
sure, new unit tests were added |
|
nice, tests close the loop. lgtm. |
|
btw, failed buildkite/intel-ci jobs ( XPU V1 test and XPU example Test ) are unrelated to this PR. This PR only edits minicpmv.py and adds test in test_minicpmv_resampler.py. Changes do not modify DeepSeek-V4 files or touch cutlass imports maybe pr #43790 is trying to fix this CI issue |
|
This pull request has been automatically marked as stale because it has not had any activity within 90 days. It will be automatically closed if no further activity occurs within 30 days. Leave a comment if you feel this pull request should remain open. Thank you! |
Purpose
Trigger Scenario:
Running MiniCPM-V (2.5/2.6/4.0) or MiniCPM-O (4.5) image/video inference on non-CPU devices (CUDA/XPU) when positional embedding buffers stay on CPU.
Symptom:
PyTorch runtime error: Expected all tensors to be on the same device . Inference fails.
Expected Behavior:
Resampler performs tensor operations on same device, executing image/video inference successfully.
Root Cause:
Positional embedding buffers registered with persistent=False remain on CPU. Original code converted only tensor data type ( .to(dtype) ) without specifying target device, leading to device mismatch (CPU vs CUDA/XPU) during tensor addition.
Test Plan
Test Result
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.