Skip to content

fix(cuda): integer_vif filter1d width guard + integer_adm CM operator-precedence x2 - #637

Merged
lusoris merged 1 commit into
masterfrom
fix/cuda-vif-filter1d-adm-cm-opprec
Jun 4, 2026
Merged

lusoris merged 1 commit into
masterfrom
fix/cuda-vif-filter1d-adm-cm-opprec

Conversation

@lusoris

@lusoris lusoris commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Three HIGH-severity CUDA kernel arithmetic bugs found in the r6-cuda-kernel audit:

  • filter1d.cu line 557 — 16-bit vertical rd-filter upper-bound guard wrote fwidth_rd - fwidth_rd (always 0) instead of fwidth - fwidth_rd. Tap window widened to cover all fwidth taps; vif_filt.filter[scale+1] indexed 1–4 entries past allocation — OOB reads, wrong VIF scores at scales 0–2.
  • adm_cm.cu lines 373 + 712 — x_sq = ... + add_shift_sq >> shift_sq parsed as + (add_shift_sq >> shift_sq) = + 0 (C++ operator precedence: >> binds tighter than +). Normalisation shift silently dropped; x_sq ~10^6 instead of ~0–1; int32 overflow; wrong ADM scale-0 and AIM scores.

Files changed

  • core/src/feature/cuda/integer_vif/filter1d.cu — fix upper-bound guard typo
  • core/src/feature/cuda/integer_adm/adm_cm.cu — add parentheses to two x_sq expressions

ADR-0108 deliverables checklist

  • Research digest: no digest needed: targeted bug-fix
  • Decision matrix: no alternatives: only-one-way fix
  • AGENTS.md invariant: two new rebase-sensitive invariant notes added to core/src/feature/cuda/AGENTS.md
  • Reproducer: meson test -C build-cuda --suite=fast + scripts/dev/cross_backend_diff.py CPU vs CUDA for VIF + ADM (expected: convergence within existing tolerance)
  • CHANGELOG fragment: changelog.d/fixed/cuda-vif-filter1d-adm-cm-kernel-fixes.md
  • Rebase note: docs/rebase-notes.md (top entry)
  • state.md update: T-R6-CUDA-VIF-FILTER1D-WIDTH-GUARD-2026-06-04 and T-R6-CUDA-ADM-CM-OPERATOR-PRECEDENCE-2026-06-04 added to Recently closed

Smoke test

meson test -C build --suite=fast (CPU build): 50/50 OK. CUDA-specific smoke requires build-cuda (CUDA device not available in this environment — CI will surface).

No docs update required

This PR does not change any user-discoverable surface (no CLI flags, public C API, meson options, or output schema changes). Internal kernel arithmetic fix only.

🤖 Generated with Claude Code

…-precedence x2

Rebased onto master (post-PR#638, #641, #642 squash) — resolved UNION
conflicts in docs/rebase-notes.md and docs/state.md only; no code conflicts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the fix/cuda-vif-filter1d-adm-cm-opprec branch from 8ea24db to 95bdbdc Compare June 4, 2026 04:25
@lusoris
lusoris marked this pull request as ready for review June 4, 2026 04:25
Copilot AI review requested due to automatic review settings June 4, 2026 04:25
@lusoris
lusoris merged commit cb63b7c into master Jun 4, 2026
69 of 106 checks passed
@lusoris
lusoris deleted the fix/cuda-vif-filter1d-adm-cm-opprec branch June 4, 2026 04:26
lusoris added a commit that referenced this pull request Jun 4, 2026
…V queue sync (ADR-1034)

Rebased onto master (post-PR#638, #641, #642, #637 squash) — resolved UNION
conflicts in docs/adr/README.md, docs/rebase-notes.md, docs/state.md only;
no code conflicts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lusoris added a commit that referenced this pull request Jun 4, 2026
…V queue sync (ADR-1034) (#640)

Rebased onto master (post-PR#638, #641, #642, #637 squash) — resolved UNION
conflicts in docs/adr/README.md, docs/rebase-notes.md, docs/state.md only;
no code conflicts.

Co-authored-by: Lusoris <lusoris@pm.me>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
lusoris added a commit that referenced this pull request Jun 4, 2026
…tion vertical halo (ADR-1030)

Rebased onto master (post-PR#638, #641, #642, #637, #640 squash) — resolved
UNION conflicts in docs/adr/README.md, docs/rebase-notes.md, docs/state.md;
no code conflicts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lusoris added a commit that referenced this pull request Jun 4, 2026
…tion vertical halo (ADR-1030) (#639)

Rebased onto master (post-PR#638, #641, #642, #637, #640 squash) — resolved
UNION conflicts in docs/adr/README.md, docs/rebase-notes.md, docs/state.md;
no code conflicts.

Co-authored-by: Lusoris <lusoris@pm.me>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@lusoris
lusoris removed the request for review from Copilot June 4, 2026 04:47
@lusoris lusoris added this to the 1.0.0 — First release milestone Sep 4, 2026
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