Skip to content

Fix causal convolution padding for even dilated kernels - #1950

Open
YaoxinHuang wants to merge 2 commits into
QwenAudio:mainfrom
YaoxinHuang:fix/causal-conv-dilated-padding
Open

YaoxinHuang wants to merge 2 commits into
QwenAudio:mainfrom
YaoxinHuang:fix/causal-conv-dilated-padding

Conversation

@YaoxinHuang

Copy link
Copy Markdown

CausalConv1d(kernel_size=4, dilation=2) pads seven frames although its receptive field needs six, so both left and right modes produce an extra frame and fail the length assertion. This also prevents a causal HiFT ResBlock from using an even kernel with an even dilation.

Use (kernel_size - 1) * dilation for the padding. CPU regressions cover left/right output alignment, explicit context, causal direction, existing odd-kernel/dilation-one cases, and a real ResBlock forward/backward pass.

Validation: python -m unittest discover -s tests -p test_causal_convolution.py -v — four methods pass on Python 3.10 / PyTorch 2.3.1 CPU; the original code reports 11 failures including subtests. Changed files pass the repository's flake8 settings. Full-repository flake8 reports the same 56 existing findings before and after the change; the workflow whitespace scans likewise match the baseline.

Prepared and tested with Codex.

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.

1 participant