A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 5, 02:15 UTC
[Bugfix] Fix audioflamingo test (#40052)
Signed-off-by: Roger Wang <hey@rogerw.io>
Roger Wang committed
Apr 16, 2026 at 11:53 UTC
3abb7560c0d6f8e8e84a5c65eca68b9aa0c71dbb
1 file changed
-85
tests/models/multimodal/processing/test_audioflamingo3.py
-85
@@ -140,88 +140,3 @@ def test_audio_token_count_matches_hf_processor_math():
140
_count_audio_tokens_from_mask(feature_attention_mask, chunk_counts, 0) == 1499
141
)
142
assert _count_audio_tokens_from_mask(feature_attention_mask, chunk_counts, 1) == 375
143
-
144
-
145
-def test_audio_feature_pipeline_matches_hf_small_config():
146
- from transformers.models.audioflamingo3 import (
147
- modeling_audioflamingo3 as hf_audioflamingo3_modeling,
148
- )
149
- from transformers.models.audioflamingo3.configuration_audioflamingo3 import (
150
- AudioFlamingo3Config,
151
- )
152
-
153
- from vllm.model_executor.models.audioflamingo3 import (
154
- AudioFlamingo3Encoder,
155
- AudioFlamingo3MultiModalProjector,
156
- _build_audio_encoder_attention_mask,
157
- _flatten_valid_audio_embeddings,
158
- )
159
-
160
- text_config = {
161
- "model_type": "qwen2",
162
- "intermediate_size": 64,
163
- "initializer_range": 0.02,
164
- "hidden_size": 32,
165
- "max_position_embeddings": 1024,
166
- "num_hidden_layers": 2,
167
- "num_attention_heads": 4,
168
- "num_key_value_heads": 2,
169
- "vocab_size": 128,
170
- "pad_token_id": 1,
171
- "use_mrope": False,
172
- }
173
- audio_config = {
174
- "hidden_size": 16,
175
- "num_attention_heads": 4,
176
- "intermediate_size": 32,
177
- "num_hidden_layers": 2,
178
- "num_mel_bins": 80,
179
- "max_source_positions": 1500,
180
- "dropout": 0.0,
181
- "attention_dropout": 0.0,
182
- "activation_dropout": 0.0,
183
- "encoder_layerdrop": 0.0,
184
- }
185
-
186
- torch.manual_seed(0)
187
- config = AudioFlamingo3Config(
188
- text_config=text_config,
189
- audio_config=audio_config,
190
- audio_token_id=0,
191
- )
192
- hf_model = hf_audioflamingo3_modeling.AudioFlamingo3ForConditionalGeneration(
193
- config
194
- ).eval()
195
-
196
- vllm_encoder = AudioFlamingo3Encoder(config.audio_config).eval()
197
- vllm_encoder.load_state_dict(hf_model.audio_tower.state_dict())
198
-
199
- vllm_projector = AudioFlamingo3MultiModalProjector(config).eval()
200
- vllm_projector.load_state_dict(hf_model.multi_modal_projector.state_dict())
201
-
202
- input_features = torch.randn(3, 80, 3000)
203
- feature_attention_mask = torch.zeros(3, 3000, dtype=torch.bool)
204
- feature_attention_mask[0, :3000] = True
205
- feature_attention_mask[1, :2500] = True
206
- feature_attention_mask[2, :1500] = True
207
-
208
- hf_output = hf_model.get_audio_features(
209
- input_features,
210
- feature_attention_mask,
211
- return_dict=True,
212
- ).pooler_output
213
- vllm_attention_mask = _build_audio_encoder_attention_mask(
214
- feature_attention_mask,
215
- dtype=vllm_encoder.conv1.weight.dtype,
216
- device=vllm_encoder.conv1.weight.device,
217
- )
218
- vllm_hidden_states = vllm_encoder(
219
- input_features,
220
- attention_mask=vllm_attention_mask,
221
- )
222
- vllm_output, _ = _flatten_valid_audio_embeddings(
223
- vllm_projector(vllm_hidden_states),
224
- feature_attention_mask,
225
- )
226
-
227
- torch.testing.assert_close(vllm_output, hf_output)