[Bugfix] Stop cancelled MiniMax-H3 requests at denoising boundaries (#7844)
Signed-off-by: Gao Han <hgaoaf@connect.ust.hk>
This commit is contained in:
1 parent
b308e196c9
commit
69de153f6e
12 files changed
+702
-13
No files matched your search
@@ -3494,3 +3494,48 @@ def test_long_video_shape_requires_explicit_opt_in(duration):
|
||||
assert frames >= duration * 24 and frames % 17 == 5
|
||||
assert video_t == (frames - 5) // 17 * 5 + 2
|
||||
assert audio_t == round(frames / 24 * 40)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("preencode", [False, True])
|
||||
@pytest.mark.parametrize("cancel_phase", ["before_prepare", "prepare", "diffuse"])
|
||||
def test_request_cancellation_at_prepare_and_decode_boundaries(preencode, cancel_phase, monkeypatch):
|
||||
from vllm_omni.diffusion.cancellation import RequestCancellationRegistry, request_cancellation_scope
|
||||
from vllm_omni.diffusion.data import DiffusionRequestAbortedError
|
||||
from vllm_omni.diffusion.models.minimax_h3 import MiniMaxH3Pipeline
|
||||
from vllm_omni.platforms import current_omni_platform
|
||||
|
||||
synchronize = Mock()
|
||||
monkeypatch.setattr(current_omni_platform, "synchronize", synchronize)
|
||||
pipeline = object.__new__(MiniMaxH3Pipeline)
|
||||
torch.nn.Module.__init__(pipeline)
|
||||
registry = RequestCancellationRegistry()
|
||||
signal = registry.create("request")
|
||||
|
||||
def prepare(*args):
|
||||
if cancel_phase == "prepare":
|
||||
registry.cancel(["request"])
|
||||
return {"num_outputs": 1, "seed": 1101, "preencode_mp4": preencode}
|
||||
|
||||
def diffuse(**kwargs):
|
||||
registry.cancel(["request"])
|
||||
return torch.zeros(1), torch.zeros(1)
|
||||
|
||||
pipeline._prepare_request_inputs = Mock(side_effect=prepare)
|
||||
pipeline._denoise_kwargs = Mock(return_value={})
|
||||
pipeline.diffuse = Mock(side_effect=diffuse)
|
||||
pipeline.decode = Mock()
|
||||
pipeline.decode_to_mp4 = Mock()
|
||||
try:
|
||||
if cancel_phase == "before_prepare":
|
||||
registry.cancel(["request"])
|
||||
with request_cancellation_scope([signal]), pytest.raises(DiffusionRequestAbortedError):
|
||||
pipeline.forward(_t2va_batch())
|
||||
synchronize.assert_called_once_with()
|
||||
if cancel_phase == "before_prepare":
|
||||
pipeline._prepare_request_inputs.assert_not_called()
|
||||
if cancel_phase != "diffuse":
|
||||
pipeline.diffuse.assert_not_called()
|
||||
pipeline.decode.assert_not_called()
|
||||
pipeline.decode_to_mp4.assert_not_called()
|
||||
finally:
|
||||
registry.close()
|
||||
@@ -171,6 +171,41 @@ def test_step_execution_matches_request_mode_denoise_loop(num_steps, mocker):
|
||||
torch.testing.assert_close(state.extra[mod._STEP_AUDIO_ROWS], reference_audio)
|
||||
|
||||
|
||||
def test_request_mode_cancellation_stops_before_next_denoise_step(monkeypatch):
|
||||
from vllm_omni.diffusion.cancellation import RequestCancellationRegistry, request_cancellation_scope
|
||||
from vllm_omni.diffusion.data import DiffusionRequestAbortedError
|
||||
from vllm_omni.diffusion.models.minimax_h3.denoise_loop import minimax_h3_denoise_loop
|
||||
from vllm_omni.platforms import current_omni_platform
|
||||
|
||||
# This test runs real packing/Euler updates on CPU with the small DiT above.
|
||||
monkeypatch.setattr(current_omni_platform, "synchronize", lambda: None)
|
||||
branch, video_rows, audio_rows = _make_branch(text_len=9, latent_t=2, latent_h=4, latent_w=6, audio_t=3, seed=5)
|
||||
registry = RequestCancellationRegistry()
|
||||
signal = registry.create("request")
|
||||
steps = []
|
||||
|
||||
def cancel_after_first_step(step, video, audio):
|
||||
steps.append(step)
|
||||
registry.cancel(["request"])
|
||||
|
||||
try:
|
||||
with request_cancellation_scope([signal]), pytest.raises(DiffusionRequestAbortedError):
|
||||
minimax_h3_denoise_loop(
|
||||
model=_SegmentMeanModel(),
|
||||
positive=branch,
|
||||
initial_video_rows=video_rows,
|
||||
initial_audio_rows=audio_rows,
|
||||
keyframe_cond_rows=None,
|
||||
sigmas_video=_sigmas(6, 12.0),
|
||||
sigmas_audio=_sigmas(6, 3.0),
|
||||
device=torch.device("cpu"),
|
||||
on_step=cancel_after_first_step,
|
||||
)
|
||||
finally:
|
||||
registry.close()
|
||||
assert steps == [0]
|
||||
|
||||
|
||||
def test_step_execution_matches_request_mode_with_latent_edits():
|
||||
"""Masked model rows, row timesteps, and scheduler math match both paths."""
|
||||
from vllm_omni.diffusion.models.minimax_h3 import pipeline_minimax_h3 as mod
|
||||
|
||||
Reference in new issue
Block a user