[Perf]Boogu-Image Skip dense attention masks (#6871)

Signed-off-by: zhuhh97 <zhuhonghan@huawei.com>
This commit is contained in:
Honghan Zhu authored and GitHub committed 2026-09-08 00:53:20 -07:00
1 parent c704aeccae
commit c086554d1f
3 files changed
+62 -9

No files matched your search

@@ -0,0 +1,30 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
import pytest
import torch
from vllm_omni.diffusion.models.utils import make_attention_mask
pytestmark = [pytest.mark.core_model, pytest.mark.cpu, pytest.mark.diffusion]
@pytest.mark.parametrize("seq_lengths", [[16], [16, 16]])
def test_attention_mask_is_skipped_for_dense_batch(seq_lengths):
hidden_states = torch.empty(len(seq_lengths), 16, 64)
assert make_attention_mask(hidden_states, seq_lengths) is None
def test_attention_mask_preserves_variable_length_padding():
hidden_states = torch.empty(2, 16, 64)
attention_mask = make_attention_mask(hidden_states, [16, 12])
expected = torch.tensor(
[
[True] * 16,
[True] * 12 + [False] * 4,
]
)
torch.testing.assert_close(attention_mask, expected)