Skip to content

Conversation

@anferico
Copy link
Contributor

@anferico anferico commented Nov 7, 2025

What does this PR do?

  1. Updates the misleading docstring in Qwen2AudioEncoder.forward stating that "Qwen2Audio does not support masking of the input_features", while in fact it does make use of it. This is likely a mistake made while copying the docstring over from Whisper
  2. Fixes a bug that causes the last "valid" (i.e. not masked) frame of the sequence coming out of the first two convolutional layers to be masked incorrectly when max_mel_seq_len is an odd number

Here's a more elaborate explanation for point 2:
max_seq_len represents the maximum sequence length after the first 2 convolutional layers, of which only the first one compresses the input sequences (due to stride=2). The compression applied by the first convolutional layer can be computed using this expression (cf. torch.nn.Conv1d):

output_length = (input_length + 2*padding - dilation * (kernel_size - 1) - 1) // stride + 1

which, given that:

  • padding = 1
  • dilation = 1
  • kernel_size = 3
  • stride = 2

can be simplified to:

output_length = (input_length - 1) // 2 + 1

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@ylacombe @amyeroberts @faychu

@anferico anferico force-pushed the bugfix/qwen2-audio-encoder branch from 6646ff2 to e55fff6 Compare November 10, 2025 08:34
@github-actions
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: qwen2_audio

@anferico
Copy link
Contributor Author

@ylacombe @amyeroberts @faychu any news?

@Rocketknight1
Copy link
Member

cc @eustlb @ebezzam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants