Skip to content

TST scripted lfilter: float64 rounding instead of bit-equality on torchaudio < 2.11 (torch 2.6 floor) - #1527

Merged
bruAristimunha merged 1 commit into
braindecode:masterfrom
bruAristimunha:bd2deep/lfilter-test-torch26
Nov 2, 2026
Merged

bruAristimunha merged 1 commit into
braindecode:masterfrom
bruAristimunha:bd2deep/lfilter-test-torch26

Conversation

@bruAristimunha

Copy link
Copy Markdown
Collaborator

test_scripted_lfilter_equals_torchaudio (from #1501) fails on the supported floor, torch/torchaudio 2.6. The 2.0 release audit ran the suite against the installed wheel with every declared floor, and this test gave 2 failures. torchaudio 2.6 rounds its eager IIR recursion differently from the ops that its own scripted path runs, which braindecode's scripted lfilter reproduces. The outputs agree to float64 rounding.

The test keeps the bit-for-bit check on current torchaudio. Below torchaudio 2.11, it accepts torch.testing.assert_close. If a future torchaudio is no longer bit-equal, the assert says so. Library code is unchanged.

Verified in Voyager Jobs: pre-commit run --files exits 0. test_modules.py -k "lfilter or filter_bank" gives 145 passed on torch 2.15 / torchaudio 2.11.1, and 145 passed on torch 2.6.0 / torchaudio 2.6.0.

The same test change is in the prepared 1.8.2 backport branch.

Copilot AI balanced review requested due to automatic review settings November 2, 2026 17:01
bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Nov 2, 2026

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.

🟡 Changes recommended

The float64 assertion’s default tolerances could allow float32-level precision regressions to pass, so explicit tolerances calibrated to the observed discrepancies are needed.

1 open issue
What changed in this PR

This test-only change restores compatibility with the supported PyTorch/torchaudio 2.6 floor while retaining strict equality checks on current torchaudio. Library behavior is unchanged.

Changes:

  • Allow numerically close scripted filter outputs on torchaudio versions below 2.11.
  • Preserve bit-for-bit checks on newer versions and for the eager wrapper.
  • Document the compatibility adjustment in the changelog.
File Description
test/​unit_tests/​models/​test_modules.py Adds a version-aware comparison helper for scripted filter tests.
docs/​whats_new.rst Records the test compatibility fix for the PyTorch 2.6 floor.

Review effort: Balanced


version = tuple(int(p) for p in torchaudio.__version__.split("+")[0].split(".")[:2])
assert version < (2, 11), "scripted lfilter is no longer bit-equal to torchaudio"
torch.testing.assert_close(actual, expected)
…chaudio < 2.11

On the torch/torchaudio 2.6 floor, torchaudio's eager IIR recursion rounds
differently from the ops of its scripted path, so the bit-for-bit check
failed there (2 failures in the minimum-versions run). Current torchaudio
stays bit-for-bit.

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.

🟢 Approval recommended

There are no active review issues for the scripted-filter test compatibility adjustment.

1 open issue

Review effort: Balanced

@bruAristimunha
bruAristimunha merged commit b78e151 into braindecode:master Nov 2, 2026
7 checks passed
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.34%. Comparing base (535e058) to head (1e25a46).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1527   +/-   ##
=======================================
  Coverage   91.34%   91.34%           
=======================================
  Files         170      170           
  Lines       22105    22105           
=======================================
  Hits        20192    20192           
  Misses       1913     1913           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bruAristimunha bruAristimunha mentioned this pull request Nov 2, 2026
bruAristimunha added a commit that referenced this pull request Nov 2, 2026
Backports #1501 (TorchScript-safe lfilter/filtfilt in FilterBankLayer) and #1164 (MNE >= 1.13 montage names) to 1.8.x; scripted-lfilter test tolerance on torchaudio < 2.11 (as #1527); version 1.8.2 and whats_new.
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.

2 participants