Skip to content

Conversation

@bbeckca
Copy link
Contributor

@bbeckca bbeckca commented Aug 24, 2025

Purpose

This PR migrates WhisperAudioInputs inputs from a TypedDict-based definition to a structured TensorSchema model with runtime shape validation. This brings it in line with recent changes to Phi3VImagePixelInputs, and is part of a broader effort to improve input contract enforcement and debug-ability across multi-modal models.

More details: #14764 (comment)

Test Plan

Confirm validation works via standalone tests in tests/standalone_test/test_tensor_schema.py and rely on CI to check integration.

Test Result

(venv) benjibeck@Benjis-MacBook-Pro vllm %  python3 -m pytest tests/utils_/test_tensor_schema.py -v --log-cli-level=DEBUG
====================================================================================================== test session starts ======================================================================================================
platform darwin -- Python 3.9.6, pytest-8.4.1, pluggy-1.6.0 -- /Users/benjibeck/Projects/vllm/venv/bin/python3
cachedir: .pytest_cache
rootdir: /Users/benjibeck/Projects/vllm
configfile: pyproject.toml
plugins: anyio-4.9.0
collected 19 items                                                                                                                                                                                                              

tests/utils_/test_tensor_schema.py::test_tensor_schema_valid_tensor PASSED                                                                                                                                                [  5%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_optional_fields PASSED                                                                                                                                             [ 10%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_constant_dim_failure PASSED                                                                                                                                        [ 15%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_invalid_types_in_list PASSED                                                                                                                                       [ 21%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_rank_mismatch PASSED                                                                                                                                               [ 26%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_missing_required_field PASSED                                                                                                                                      [ 31%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_symbolic_dim_mismatch PASSED                                                                                                                                       [ 36%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_list_tensor_valid PASSED                                                                                                                                           [ 42%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_variable_patch_counts_valid PASSED                                                                                                                                 [ 47%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_tuple_tensor_valid PASSED                                                                                                                                          [ 52%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_inconsistent_shapes_in_list PASSED                                                                                                                                 [ 57%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_empty_list PASSED                                                                                                                                                  [ 63%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_validation_disabled_skips_shape_check PASSED                                                                                                                       [ 68%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_with_valid_resolve_binding_dims PASSED                                                                                                                             [ 73%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_with_invalid_resolve_binding_dims PASSED                                                                                                                           [ 78%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_with_list_of_symbolic_dim PASSED                                                                                                                                   [ 84%]
tests/utils_/test_tensor_schema.py::test_tensor_schema_with_list_of_symbolic_dim_mismatch_in_length PASSED                                                                                                                [ 89%]
tests/utils_/test_tensor_schema.py::test_valid_tensor_schema_with_static_last_dim PASSED                                                                                                                                  [ 94%]
tests/utils_/test_tensor_schema.py::test_invalid_tensor_schema_with_static_last_dim PASSED                                                                                                                                [100%]

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully migrates WhisperAudioInputs from a TypedDict to TensorSchema, introducing runtime shape validation. This is a good improvement for input contract enforcement and debuggability, aligning with the project's goals. The changes are correct and well-implemented. I have no further comments.

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) August 25, 2025 02:42
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 25, 2025
@bbeckca
Copy link
Contributor Author

bbeckca commented Aug 25, 2025

Observing failing MM test similar to #23503:

[2025-08-25T04:02:55Z]     raise ValueError(f"{field_name} dim[{i}] expected "
[2025-08-25T04:02:55Z] ValueError: input_features dim[1] expected 128, got 80
[2025-08-25T04:02:55Z] FAILED
[2025-08-25T04:02:56Z] tests/models/multimodal/generation/test_whisper.py::test_models[openai/whisper-large-v3-turbo] Fork a new process to run a test 7898

Based on existing schema, this seems to be an issue with the inputs:
schema

auto-merge was automatically disabled September 1, 2025 00:00

Head branch was pushed to by a user without write access

@bbeckca
Copy link
Contributor Author

bbeckca commented Sep 1, 2025

Seeing test failures where _parse_and_validate_audio_input gets input_features=None. This line should be unreachable. @Isotr0py any idea where this is dropped upstream?

python -m pytest tests/models/multimodal/generation/test_whisper.py -k "openai/whisper-large-v3-turbo" -v

@mergify
Copy link

mergify bot commented Sep 1, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @bbeckca.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Sep 1, 2025
Signed-off-by: Benji Beck <benjibeck@meta.com>
Signed-off-by: Benji Beck <benjibeck@meta.com>
Signed-off-by: Benji Beck <benjibeck@meta.com>
input_features = torch.cat(
[feat.to(self.dtype) for feat in input_features])

if input_features.size(1) == 80:
Copy link
Member

@DarkLight1337 DarkLight1337 Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should avoid changing the dimensions like this since it may affect the output of the model. IMO only squeezing or flattening should be allowed. Better to update the shape definitions instead.

Signed-off-by: Benji Beck <benjibeck@meta.com>
@DarkLight1337 DarkLight1337 enabled auto-merge (squash) September 3, 2025 15:48
@DarkLight1337 DarkLight1337 merged commit 731a694 into vllm-project:main Sep 3, 2025
43 checks passed
eicherseiji pushed a commit to eicherseiji/vllm that referenced this pull request Sep 9, 2025
Signed-off-by: Benji Beck <benjibeck@meta.com>
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
Signed-off-by: Benji Beck <benjibeck@meta.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants