SubsamplingReductionModule pooling returns wrong lengths (factor 4 -> [6,5], factor 8 -> [0,0])
Author: ManoharPaturiCreated Sep 7, 2026Updated Sep 18, 2026
Labelscommunity-requestwaiting-on-maintainers
Description
SubsamplingReductionModule(reduction='pooling') computes output lengths with repeat_num=log2(reduction_factor), but the module applies a single MaxPool1d(kernel_size=reduction_factor) pass. The lengths are therefore wrong for every factor except 2:
- input lengths [100, 90], factor 4 → returns [6, 5] (actual downsampled T is 25/22)
- factor 8 → returns [0, 0] (actual 12/11)
With lengths 0, the conformer attention mask drops every frame — anything consuming out_len sees an empty sequence.
Steps to reproduce
import torch
from nemo.collections.asr.parts.submodules.subsampling import SubsamplingReductionModule
m = SubsamplingReductionModule(reduction='pooling', d_model=32, reduction_factor=8)
out, out_len = m(torch.randn(2, 32, 100), torch.tensor([100, 90]))
print(out_len) # tensor([0, 0])Expected behavior
[25, 22] for factor 4, [12, 11] for factor 8 (one pooling pass divides T by the factor).
Actual behavior
calc_length(..., repeat_num=self._sampling_num) with _sampling_num = log2(reduction_factor) — that repeat count is for the striding variant (which applies log2 strided convs), not the pooling one.
Environment
NeMo main (de26b36), CPU, torch 2.14
Source: NVIDIA-NeMo/Speech