Skip to content

fix(asr): repair ConvSubsampling forward paths missed by the MaskedConvSequential refactor - #16225

Open
ManoharPaturi wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
ManoharPaturi:fix/convsampling-missing-lengths-arg
Open

fix(asr): repair ConvSubsampling forward paths missed by the MaskedConvSequential refactor#16225
ManoharPaturi wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
ManoharPaturi:fix/convsampling-missing-lengths-arg

Conversation

@ManoharPaturi

Copy link
Copy Markdown

Fixes #16223.

Three repairs to paths the MaskedConvSequential refactor (#13827) missed:

  • MaskedConvSequential.forward takes optional lengths; 1-D stacks without length-aware layers just pass them through
  • ConvSubsampling.forward now forwards lengths to self.conv(...) in the non-chunked / conv1d branch (the else that previously called self.conv(x))
  • _layer_padding handles nn.MaxPool2d storing int kernel/stride/padding (via a _pair_first helper) and accounts for the extra frame ceil_mode=True can add

subsampling_conv_chunking_factor=-1 verified bit-identical to the default path for striding/dw_striding/vggnet at factors 4 and 8. 14 new CPU tests — all fail on main, pass here.

…nvSequential refactor

The MaskedConvSequential refactor left three ConvSubsampling paths broken:

1. `subsampling_conv_chunking_factor=-1` (chunking disabled, documented in the
   class docstring) falls into `x, lengths = self.conv(x)`, which calls
   MaskedConvSequential.forward without the required `lengths` argument and
   raises TypeError for every conv2d stack (vggnet, striding, dw_striding).

2. The 1-D stacks (striding_conv1d, dw_striding_conv1d, conv2d_subsampling=False)
   always take that same branch regardless of the chunking factor, so both
   variants raise TypeError on every forward pass.

3. For vggnet, `_forward_torch` reads `layer.kernel_size[0]` / `layer.stride[0]`,
   but nn.MaxPool2d stores the int values passed in (kernel_size=2, stride=2),
   so every vggnet forward raises TypeError: 'int' object is not subscriptable.
   _layer_padding has the same problem with the int `padding`. Once the int
   access works, the length update must also honor MaxPool2d's ceil_mode=True,
   which calculate_conv_output_size's floor division ignores.

Fixes:
- ConvSubsampling.forward: pass `lengths` to the masked stack when chunking is
  disabled; run 1-D stacks as a plain sequential (MaskedConvSequential.forward
  accepts lengths=None for exactly this) and report the precomputed out_lengths.
- _forward_torch: read kernel/stride/padding via a _pair_first helper that
  tolerates int attributes, and add the ceil-mode remainder frame when a
  pooling layer runs with ceil_mode=True.

Adds CPU unit tests for all three paths; each fails with TypeError or wrong
lengths on the unfixed code. The chunking=-1 path is asserted to match the
default (chunked) path bit-for-bit, and conv1d/vggnet lengths are asserted
against calc_length references.

Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 7, 2026 07:11
@copy-pr-bot

copy-pr-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the ASR label Sep 7, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ASR community-request waiting-on-maintainers Waiting on maintainers to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ConvSubsampling forward broken: chunking=-1, striding_conv1d/dw_striding_conv1d, and vggnet all raise TypeError

3 participants