fix(asr): repair ConvSubsampling forward paths missed by the MaskedConvSequential refactor - #16225
Open
ManoharPaturi wants to merge 1 commit into
Open
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #16223.
Three repairs to paths the MaskedConvSequential refactor (#13827) missed:
MaskedConvSequential.forwardtakes optionallengths; 1-D stacks without length-aware layers just pass them throughConvSubsampling.forwardnow forwardslengthstoself.conv(...)in the non-chunked / conv1d branch (theelsethat previously calledself.conv(x))_layer_paddinghandlesnn.MaxPool2dstoring int kernel/stride/padding (via a_pair_firsthelper) and accounts for the extra frameceil_mode=Truecan addsubsampling_conv_chunking_factor=-1verified 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.