Skip to content

perf(sycl,hip): compact nonzero terms before psnr_hvs readback (ADR-1397) - #1733

Merged
lusoris merged 1 commit into
masterfrom
perf/sycl-hip-psnr-hvs-tune
Oct 1, 2026
Merged

lusoris merged 1 commit into
masterfrom
perf/sycl-hip-psnr-hvs-tune

Conversation

@lusoris

@lusoris lusoris commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Compact nonzero terms directly on the device prior to host readback for both
psnr_hvs_sycl and psnr_hvs_hip. Because $x + 0.0\text{f} == x$ for all
floats in the running sum, zero error terms contribute nothing to plane scores.
Compaction shrinks readback buffer size by 94-97% (198.3 MB -> 11.0 MB at 4K)
and speeds up 4K throughput to 29.30 ms/frame on Arc A380 and 35.53 ms/frame on gfx1036.

Type

  • feat — new feature
  • fix — bug fix
  • perf — performance improvement
  • refactor — no behavior change
  • docs — documentation only
  • test — test-only
  • build / ci — tooling / infra
  • port — cherry-pick from upstream Netflix/vmaf
  • sycl / cuda / simd — backend-specific

Checklist

  • Commits follow Conventional Commits (the commit-msg hook enforces this).
  • make format && make lint is green locally.
  • Unit tests pass: python3 scripts/ci/run_meson_test.py -- -C build.
  • If I touched any SIMD/GPU code path, I ran /cross-backend-diff and the worst ULP is ≤ 2.
  • If I touched a feature extractor with SIMD/GPU twins, I either updated every twin or listed the gap under "Known follow-ups" below.
  • If I added a new .c / .cpp / .cu / .h / .hpp, it has the appropriate license header (see CONTRIBUTING.md).
  • If this is a breaking change, the commit message uses ! or BREAKING CHANGE: and the migration path is documented below.
  • If this PR adds an ADR, the ADR row lives in docs/adr/_index_fragments/<NNNN-slug>.md and the slug is appended to docs/adr/_index_fragments/_order.txt — do not edit docs/adr/README.md directly (regenerated by scripts/docs/concat-adr-index.sh; see ADR-0221).

Bug-status hygiene (ADR-0165)

  • docs/state.md updated in this PR with a row in the appropriate section (Open / Recently closed / Confirmed not-affected / Deferred), OR no state delta: REASON.

Updates T-SYCL-HIP-PSNR-HVS-EXACT-SUM-THROUGHPUT-2026-10-01.

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, I have explained why below AND pinged @lusoris for a CODEOWNERS exception.

Cross-backend numerical results

Bit-identical (diff 0.00e+00) across all 5 test sets against --backend cpu of the same binary at --precision max:

  • Netflix 576x324 8-bit (48 frames): 48/48 identical on SYCL and HIP
  • Netflix 576x324 10-bit (3 frames): 3/3 identical on SYCL and HIP
  • 1080p checkerboard 1px (3 frames): 3/3 identical on SYCL and HIP
  • 1080p checkerboard 10px (3 frames): 3/3 identical on SYCL and HIP
  • BBB 4K (200 frames): 200/200 identical on SYCL and HIP

Performance (if perf or feat)

ms/frame, median of 3 runs of (t(N) - t(2)) / (N - 2), before -> after:

  • SYCL (Intel Arc A380):
    • 576x324: 0.79 -> 0.60 ms
    • 1920x1080: 9.53 -> 7.46 ms
    • 3840x2160: 39.23 -> 29.30 ms
  • HIP (AMD gfx1036):
    • 576x324: 0.63 -> 0.77 ms
    • 1920x1080: 8.11 -> 7.69 ms
    • 3840x2160: 41.18 -> 35.53 ms

Readback size:

  • 576x324: 4.35 MB -> 0.21 MB (95% reduction)
  • 1920x1080: 49.38 MB -> 1.39 MB (97% reduction)
  • 3840x2160: 198.30 MB -> 11.01 MB (94.4% reduction)

Deep-dive deliverables (ADR-0108)

  • Research digest — no digest needed: follows ADR-1397 / ADR-1401 and Research-1401 directly.
  • Decision matrix — no alternatives: identity x + 0.0f == x only sound order-preserving compact.
  • AGENTS.md invariant note — no rebase-sensitive invariants.
  • Reproducer / smoke-test command — pasted below under "Reproducer".
  • CHANGELOG fragment — changelog.d/changed/perf-sycl-hip-psnr-hvs-device-compact.md
  • Rebase note — entry added to docs/rebase-notes.md under a new ID.

Reproducer

./build-sycl/test/test_psnr_hvs_score
python3 core/test/test_psnr_hvs_twin_exact_sum_contract.py

Known follow-ups

Row T-SYCL-HIP-PSNR-HVS-EXACT-SUM-THROUGHPUT-2026-10-01 remains open for remaining tuning (SYCL: 29.30 ms vs 22.4 ms pre-ADR-1401 baseline; HIP: 35.53 ms vs 18.3 ms baseline).

…397)

Compact nonzero terms directly on the device prior to host readback for
both psnr_hvs_sycl and psnr_hvs_hip. Because x + 0.0f == x for all floats
in the running sum, zero error terms contribute nothing to plane scores.

By computing 64-bit nonzero bitmasks per block and performing work-group
prefix scans, each frame compacts nonzero terms into contiguous device
buffers and reads back only nonzero terms.

Results:
- Readback shrinks by 94-97% across resolutions (4K drops from 198.3 MB
  to 11.0 MB).
- 4K throughput improves from 39.23 ms to 29.30 ms/frame on Arc A380
  and from 41.18 ms to 35.53 ms/frame on gfx1036.
- SYCL kernels remain completely scratch-free (0 private memory, 0 spills).
- All 5 test cases remain 100% bit-identical to CPU at --precision max.

Updates T-SYCL-HIP-PSNR-HVS-EXACT-SUM-THROUGHPUT-2026-10-01.
@lusoris
lusoris force-pushed the perf/sycl-hip-psnr-hvs-tune branch from 29f3279 to 8816294 Compare October 1, 2026 16:36
@lusoris
lusoris merged commit 2a3661c into master Oct 1, 2026
58 of 69 checks passed
@lusoris
lusoris deleted the perf/sycl-hip-psnr-hvs-tune branch October 1, 2026 16:36
@github-actions github-actions Bot added the type:perf Performance improvement label Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:perf Performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant