Skip to content

Fix Triton median filtering for non-contiguous inputs - #2900

Open
0z5a wants to merge 1 commit into
openai:mainfrom
0z5a:codex/whisper-median-contiguous
Open

0z5a wants to merge 1 commit into
openai:mainfrom
0z5a:codex/whisper-median-contiguous

Conversation

@0z5a

@0z5a 0z5a commented Nov 4, 2026

Copy link
Copy Markdown

median_filter_cuda builds a contiguous copy to derive its output layout, but launches the Triton kernel with the original input. The kernel assumes contiguous rows and adjacent values along the last dimension, so channels-last or transposed inputs can produce incorrect medians and can cause reads beyond the input view's logical storage.

Keep the existing contiguous copy and pass it to the kernel. Contiguous inputs remain a no-op for contiguous(), and non-contiguous inputs are copied once as before.

The new regression covers channels-last and transposed inputs, float16 and float32, and filter widths 3, 7, and 13. It uses an oversized backing allocation to reproduce the incorrect addressing without reading outside the test's owned allocation.

Validation:

  • On a CUDA system: pytest -q tests/test_timing.py.
  • B300: not run.
  • GH200 (PyTorch 2.14.1+cu130, Triton 3.8.0): baseline code with the new regression tests applied produced 16 passed / 12 failed, with all failures in the new non-contiguous regression; candidate 28 passed. An additional 12 actual median_filter comparisons passed for channels-last and contiguous 3D inputs.
  • CPU timing tests: 8 passed on each host, with 20 CUDA-marked cases deselected.
  • Black 25.1.0, isort 6.0.0, Flake8 7.1.1, and git diff --check passed.

These are component tests; no full-model transcription or performance claim is made.

Copy link
Copy Markdown

Independent Linux CMP 170HX / SM80 validation of 2ed56950 with PyTorch 2.14.1+cu130 and Triton 3.8.0:

  • Unchanged tests/test_timing.py: 28 passed, 0 skipped (8 CPU and 20 CUDA cases).
  • Retaining those tests and replacing only whisper/triton_ops.py with base 86098128: 16 passed, 12 failed. All failures are the added channels-last/transposed, FP16/FP32, width 3/7/13 regression cases.

Native command: python -m pytest -q tests/test_timing.py. Could a maintainer review the contiguous-input handoff with this SM80 red/green evidence?

Commands, unchanged fixture, logs, source hashes and guard summary. The first session passed all candidate tests; a runner permission error before the control was corrected, and a fresh session ran only the control. Both outcomes are retained. No audio/model download, transcription or performance claim. This automated validation used Codex assistance.

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