Skip to content

Implement custom dataset class for ASR benchmarking#41576

Merged
DarkLight1337 merged 23 commits into
vllm-project:mainfrom
ymoslem:custom-audio-dataset
May 12, 2026
Merged

Implement custom dataset class for ASR benchmarking#41576
DarkLight1337 merged 23 commits into
vllm-project:mainfrom
ymoslem:custom-audio-dataset

Conversation

@ymoslem
Copy link
Copy Markdown
Contributor

@ymoslem ymoslem commented May 3, 2026

Added a new function to process a custom audio dataset for ASR benchmarking.

Purpose

This PR adds support for benchmarking ASR (Automatic Speech Recognition) models using a custom local dataset. It introduces:

  • process_audio(): a utility function that normalizes audio inputs from:

    • file paths (via soundfile);
    • HuggingFace-style dicts {"array": ..., "sampling_rate": ...}; or
    • raw (array, sr) tuples.
  • CustomAudioDataset: a new dataset class extending CustomDataset that loads audio samples from a JSONL file (e.g., {"prompt": "", "audio": "/path/to/audio.wav"}), processes them via process_audio(), and constructs SampleRequest objects with the audio as multi_modal_data.

  • CLI support: custom_audio added as a valid --dataset-name choice, with a corresponding elif branch in get_samples().

Latest updates:

  • Added custom_audio to the --dataset-name choices, CustomAudioDataset class and process_audio function:
    • Support ASR models (Whisper tested)
    • Support Multimodal (text + audio) models requiring a chat template (Qwen2-Audio tested)
  • Changed custom_mm to custom_image and CustomMMDataset to CustomImageDataset:
    • For now, both custom_mm and custom_image are accepted to keep backward compatibility.

Test Plan 1 (Whisper)

Create a sample JSONL dataset

echo '{"prompt": "", "audio": "/path/to/test.wav"}' > whisper_dataset.jsonl

Start a server

vllm serve openai/whisper-tiny

Run the benchmark

Note: You might need to start another Terminal window, unless you use nohup when starting the server.

vllm bench serve \
  --model openai/whisper-tiny \
  --backend openai-audio \
  --endpoint /v1/audio/transcriptions \
  --dataset-name custom_audio \
  --dataset-path whisper_dataset.jsonl \
  --no-oversample \
  --save-result \
  --save-detailed \
  --result-filename whisper_bench.json

Test Plan 2 (Qwen2-Audio)

Create a sample JSONL dataset.

It is better to have a "prompt" with the required instruction.

echo '{"prompt": "Transcribe the audio.", "audio": "/path/to/test.wav"}' > qwen_dataset.jsonl

Start a server

vllm serve Qwen/Qwen2-Audio-7B-Instruct

Run the benchmark

Note: You might need to start another Terminal window, unless you use nohup when starting the server.

vllm bench serve \
  --model Qwen/Qwen2-Audio-7B-Instruct \
  --backend openai-chat \
  --endpoint /v1/chat/completions \
  --dataset-name custom_audio \
  --dataset-path qwen_dataset.jsonl \
  --no-oversample \
  --enable-multimodal-chat \
  --save-result \
  --save-detailed \
  --result-filename qwen_bench.json

Test Result

By the end of the run:

  • You should see "Serving Benchmark Result"
  • If you used the --save-result and --save-detailed options, the whisper_bench.json and qwen_bench.json files should include the results and outputs.

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Added audio processing functionality and a custom dataset class for ASR benchmarking. The new features support various audio input formats and allow for sampling from a JSONL dataset.

Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added the performance Performance-related issues label May 3, 2026
Copy link
Copy Markdown
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 introduces support for custom audio datasets in the benchmarking suite by adding a CustomAudioDataset class and a process_audio utility. The review feedback highlights a potential module-level failure due to the top-level import of soundfile without an ImportError check. Additionally, the feedback identifies several inconsistencies in the CustomAudioDataset.sample method, including missing support for the skip_chat_template flag, incorrect handling of null tokenizers, and the omission of logic for the output_tokens field.

Comment thread vllm/benchmarks/datasets/datasets.py Outdated
Comment thread vllm/benchmarks/datasets/datasets.py
Comment thread vllm/benchmarks/datasets/datasets.py
Copy link
Copy Markdown
Contributor Author

@ymoslem ymoslem left a comment

Choose a reason for hiding this comment

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

Automatic suggestions reviewed

@ymoslem
Copy link
Copy Markdown
Contributor Author

ymoslem commented May 3, 2026

@ywang96 Would you please review. Thanks!

Comment thread vllm/benchmarks/datasets/datasets.py Outdated
ymoslem and others added 3 commits May 4, 2026 00:28
The soundfile library is imported at the top level without an ImportError check. This will cause the entire datasets module to fail to load if soundfile is not installed, even for users running non-audio benchmarks. Please follow the existing pattern in this file (e.g., for pandas or datasets) by using a try...except block or placeholder module.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
The sample call for custom_audio is missing the skip_chat_template argument. This prevents the --skip-chat-template CLI flag from working correctly for this dataset type, which is inconsistent with the custom dataset implementation.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
The sample call for custom_audio is missing the skip_chat_template argument. This prevents the --skip-chat-template CLI flag from working correctly for this dataset type, which is inconsistent with the custom dataset implementation.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

@ymoslem ymoslem left a comment

Choose a reason for hiding this comment

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

Reviewing suggestions

Add try... except to the soundfile import, and add guards to the audio sample function

Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
Comment thread vllm/benchmarks/datasets/datasets.py
Copy link
Copy Markdown
Contributor Author

@ymoslem ymoslem left a comment

Choose a reason for hiding this comment

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

Fixed suggestions

@ymoslem ymoslem requested a review from ywang96 May 4, 2026 00:10
Comment thread vllm/benchmarks/datasets/datasets.py
@DarkLight1337 DarkLight1337 added the verified Run pre-commit for new contributors without triggering other tests label May 4, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 4, 2026

Hi @ymoslem, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 4, 2026

Hi @ymoslem, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 5, 2026

Hi @ymoslem, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 7, 2026

Hi @ymoslem, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 10, 2026

Hi @ymoslem, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10

- Adding "custom_audio" to the `--dataset-name` choices, CustomAudioDataset class and process_audio function:
  - Support ASR models (Whisper tested)
  - Support Multimodal (text + audio) models requiring a chat template (Qwen2-Audio tested)
- Change "custom_mm" to "custom_image" and CustomMMDataset to CustomImageDataset:
  - For now, both "custom_mm" and "custom_image" are accepted to keep backward compatibility.


Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 10, 2026

Hi @ymoslem, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10

Match changes in datasets.py

Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
ymoslem added 2 commits May 11, 2026 00:02
Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
Added a deprecation warning for 'custom_mm' dataset. Use '--dataset-name custom_image' instead

Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

@ymoslem ymoslem left a comment

Choose a reason for hiding this comment

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

Added a deprecation warning for custom_mm. Use --dataset-name custom_image instead.

@ymoslem ymoslem requested a review from DarkLight1337 May 10, 2026 23:20
Comment thread vllm/benchmarks/datasets/datasets.py Outdated
Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

@ymoslem ymoslem left a comment

Choose a reason for hiding this comment

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

Updated deprecation warning for custom_mm

Copy link
Copy Markdown
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

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

@DarkLight1337 DarkLight1337 added the ready ONLY add when PR is ready to merge/full CI is needed label May 11, 2026
ymoslem added 2 commits May 11, 2026 18:21
Updated the documentation to reflect changes in dataset naming and usage for image datasets.

Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
Comment thread docs/benchmarking/cli.md Outdated
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 11, 2026

Documentation preview: https://vllm--41576.org.readthedocs.build/en/41576/

@mergify mergify Bot added the documentation Improvements or additions to documentation label May 11, 2026
ymoslem added 2 commits May 11, 2026 23:05
Added instructions for benchmarking with CustomAudioDataset, including examples for Whisper and Qwen2-Audio models.

Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 11, 2026

Hi @ymoslem, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10

Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 11, 2026

Hi @ymoslem, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10

Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 11, 2026

Hi @ymoslem, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10

Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
@DarkLight1337
Copy link
Copy Markdown
Member

Thanks for your patience!

@DarkLight1337 DarkLight1337 merged commit 28ee78a into vllm-project:main May 12, 2026
39 checks passed
weifang231 pushed a commit to weifang231/eb-vllm that referenced this pull request May 13, 2026
Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
mfylcek pushed a commit to mfylcek/vllm that referenced this pull request May 19, 2026
Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
jhu960213 pushed a commit to jhu960213/vllm that referenced this pull request May 20, 2026
Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
h1t35h pushed a commit to h1t35h/vllm that referenced this pull request May 21, 2026
Signed-off-by: Yasmin Moslem <48152713+ymoslem@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation performance Performance-related issues ready ONLY add when PR is ready to merge/full CI is needed verified Run pre-commit for new contributors without triggering other tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants