Skip to content

fix(cuda): pass the plane index to the 16-bpc PSNR kernel - #1374

Draft
lusoris wants to merge 3 commits into
masterfrom
fix/cuda-psnr-16bpc-plane
Draft

fix(cuda): pass the plane index to the 16-bpc PSNR kernel#1374
lusoris wants to merge 3 commits into
masterfrom
fix/cuda-psnr-16bpc-plane

Conversation

@lusoris

@lusoris lusoris commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Summary

CUDA chroma PSNR above 8 bpc was a luma number. Found by the twin-drift sweep (ids 7, 80), confirmed by measurement before touching code.

Netflix 576x324 pair, frame 0:

psnr_y psnr_cb psnr_cr
CPU, 10 bpc 34.786288 39.255496 41.375212
CUDA, 10 bpc before 34.786288 34.358981 34.358981
CUDA, 12 bpc before 34.792654 34.365347 34.365347
CUDA, 10/12 bpc after identical to CPU on all three planes

psnr_cb == psnr_cr, both luma-like: the chroma dispatches were measuring a chroma-sized top-left window of the luma plane. psnr_cuda_dispatch has always passed plane as the sixth kernel argument for both bit depths; the 8-bpc kernel declares it and indexes data[plane], the 16-bpc kernel was declared without it and hard-coded index 0. cuLaunchKernel silently ignores the surplus argument, so nothing failed loudly. SYCL and HIP are correct (checked at 10 bpc).

Every PSNR parity fixture was 8-bit with flat chroma — both sides sit at the psnr_max sentinel, so a wrong-plane chroma read could never show. The fixture is now bit-depth generic (8-bit kept byte-identical, widened above 8 bpc with non-flat, ref/dist-different chroma) and registered again at 10 bpc.

  • test_cuda_psnr_parity 3/3, test_cuda_psnr_parity_10bit 3/3 on an RTX 4090.

Type

  • fix — bug fix
  • test — test-only (new gate)
  • sycl / cuda / simd — backend-specific (CUDA)

Checklist

  • Commits follow Conventional Commits.
  • make format && make lint is green locally (pre-commit run --files clean; check-state-md-rows OK; ADR index in sync).
  • Unit tests pass: meson test -C build — the touched targets on CUDA, listed above.
  • If I touched any SIMD/GPU code path, I ran /cross-backend-diff and the worst ULP is ≤ 2 — equivalent done directly: CPU vs CUDA identical to six decimals on all planes at 10 and 12 bpc.
  • If I touched a feature extractor with SIMD/GPU twins, I either updated every twin or listed the gap — only the CUDA 16-bpc kernel was wrong; SYCL and HIP verified correct at 10 bpc.
  • If I added a new .c / .h — no new source files.
  • If this is a breaking change — not breaking; the previous values were wrong.
  • If this PR adds an ADR, the row lives in docs/adr/_index_fragments/ — in sync.

Bug-status hygiene (ADR-0165)

  • docs/state.md updated — T-CUDA-PSNR-16BPC-CHROMA-READS-LUMA-2026-09-07 closed.

Netflix golden-data gate (ADR-0024)

  • I did not modify any assertAlmostEqual(...) score in the Netflix golden Python tests.
  • If I believe a golden value must change — none does; the golden gate is CPU-only and 8-bit.

Deep-dive deliverables (ADR-0108)

  • Research digest — no digest needed: one measurement and one signature diff, both recorded in ADR-1215's Context.
  • Decision matrix## Alternatives considered in ADR-1215.
  • AGENTS.md invariant note — added to core/src/cuda/AGENTS.md.
  • Reproducer / smoke-test command — below.
  • CHANGELOG fragmentchangelog.d/fixed/cuda-psnr-16bpc-plane-argument.md.
  • Rebase notedocs/rebase-notes.md, "ADR-1215 — per-plane CUDA kernels must take the plane index".

Reproducer

Y=python/test/resource/yuv
for f in psnr psnr_cuda; do
  vmaf -r $Y/src01_hrc00_576x324.yuv420p10le.yuv -d $Y/src01_hrc01_576x324.yuv420p10le.yuv \
       --width 576 --height 324 --pixel_format 420 --bitdepth 10 --frame_cnt 1 --no_prediction \
       --feature $f --output /dev/stdout --json | grep -oE '"psnr_c[br]": *[0-9.]+'
done
meson test -C build test_cuda_psnr_parity_10bit

On master the CUDA line prints psnr_cb = psnr_cr ≈ 34.36 against the CPU's 39.26 / 41.38; on this branch they match.

Known follow-ups

  • The sweep flagged (id 85, ids 31–33) that the psnr_hvs GPU round-trip scales 9- and 11-bit input by 16 in the kernel while the host divides by a different factor — an unusual-bit-depth defect, tracked separately.

🤖 Generated with Claude Code

lusoris pushed a commit that referenced this pull request Sep 6, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
lusoris pushed a commit that referenced this pull request Sep 7, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the fix/cuda-psnr-16bpc-plane branch from d5fd684 to 4214d4e Compare September 7, 2026 06:54
lusoris pushed a commit that referenced this pull request Sep 7, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the fix/cuda-psnr-16bpc-plane branch from 4214d4e to b2e8ab6 Compare September 7, 2026 09:15
lusoris pushed a commit that referenced this pull request Sep 7, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the fix/cuda-psnr-16bpc-plane branch from b2e8ab6 to 6b3edc0 Compare September 7, 2026 09:17
lusoris pushed a commit that referenced this pull request Sep 7, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the fix/cuda-psnr-16bpc-plane branch from 6b3edc0 to 49ff6de Compare September 7, 2026 10:18
lusoris pushed a commit that referenced this pull request Sep 7, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the fix/cuda-psnr-16bpc-plane branch from 49ff6de to ec8bf09 Compare September 7, 2026 12:16
lusoris pushed a commit that referenced this pull request Sep 7, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the fix/cuda-psnr-16bpc-plane branch from ec8bf09 to ebbd82f Compare September 7, 2026 16:08
Lusoris and others added 3 commits September 7, 2026 18:37
The host has always passed `plane` as the sixth kernel argument for both bit
depths, but calculate_psnr_kernel_16bpc had no parameter for it and read
data[0] / stride[0], so every high-bit-depth chroma dispatch measured a
chroma-sized top-left window of the LUMA plane. On the Netflix 576x324 pair at
10 bpc CUDA reported psnr_cb = psnr_cr = 34.358981 where the CPU reports
39.255496 / 41.375212; luma and all 8-bit results matched. SYCL and HIP are
correct. The psnr parity fixture is made bit-depth generic with non-flat,
ref/dist-different chroma above 8 bpc and registered again at 10 bpc
(ADR-1215).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the fix/cuda-psnr-16bpc-plane branch from ebbd82f to b6b8f66 Compare September 7, 2026 16:37
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