Skip to content

Clarify positional encoding length limit errors - #3085

Open
Con-Benksl wants to merge 1 commit into
speechbrain:developfrom
Con-Benksl:fix/positional-encoding-length-limit-0746-tools
Open

Con-Benksl wants to merge 1 commit into
speechbrain:developfrom
Con-Benksl:fix/positional-encoding-length-limit-0746-tools

Conversation

@Con-Benksl

Copy link
Copy Markdown

What does this PR do?

Related to #2071, specifically the requested diagnostic for inputs exceeding the positional encoding limit.

PositionalEncoding silently returns only max_len positions for a longer input. ASR callers then fail with a tensor-size mismatch that does not identify the configured limit. Raise ValueError in the shared module with both the input length and the maximum length, before returning an incomplete encoding.

The configured capacity and sinusoidal values stay unchanged. Inputs at the limit remain valid. This does not add support for transcribing arbitrarily long recordings.

Validation on CPU, Python 3.11.15 / PyTorch 2.6.0:

  • New tests cover empty/short/exact-limit sequences, float32/float64 module conversion, custom/default limits, and real small TransformerASR encode/source/target paths. Before the fix: 5 failed, 8 passed. Afterward: 13 passed.
  • New and related attention, conformer, streaming and mask tests, plus all Transformer doctests: 59 passed.
  • Separate baseline comparisons give identical normal ASR outputs, input gradients and checkpoint metadata. TorchScript retains valid-boundary behavior and reports the new error for over-limit inputs.
  • Full-repository and changed-file pre-commit checks and git diff --check pass.

The tests use synthetic features and a locally initialized small model. No pretrained models, datasets, GPU execution or full repository test suite were used. Existing mask-type deprecation and attention-test overflow warnings remain.

Implemented and tested autonomously with OpenAI Codex, with independent read-only review by another Codex agent.

Before submitting
  • Read the contributor guideline.
  • This PR does one thing.
  • Documented the new exception.
  • Added necessary regression tests.
  • Ran the new and related existing tests listed above.
  • Described the intentional change for over-limit input.
  • Code style checks pass.

PR review

Reviewer checklist
  • Ready for review.
  • Confirm the contributor checklist.
  • Review the title and description.
  • Add appropriate labels and milestones.
  • Confirm compatibility requirements.
  • Review the changes.

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