Repository navigation
perf(cuda): ms_ssim_vert_lcs + ms_ssim_horiz — __ldg + __launch_bounds (F3 fix #2, ADR-0757) - #99
Merged
Conversation
lusoris
marked this pull request as ready for review
May 29, 2026 09:37
…s (F3 fix #2, ADR-0757) Apply the F3 __ldg() / __restrict__ pointer-extraction pattern (first used in ADR-0754 for calculate_ssim_vert_combine, PR #93) to the two top ms_ssim audit candidates identified in PR #96: - ms_ssim_vert_lcs: extract 5 const float *__restrict__ pointers before K=11 loop; use __ldg() on all 5x11 = 55 inner-loop loads. - ms_ssim_horiz: extract 2 const float *__restrict__ pointers before K=11 loop; use __ldg() on all 2x11 = 22 inner-loop loads. - Both kernels: add __launch_bounds__(128) (actual launch is 16x8=128 threads). LDG.E.CONSTANT confirmed in sm_89 SASS via cuobjdump. Build: clean nvcc compile (zero warnings). Predicted -4 to -6% kernel duration at 1080p (memory-bound regime where combined intermediate footprint exceeds L2 capacity). Six deep-dive deliverables: ADR-0757, AGENTS.md invariant extended, changelog.d/perf/cuda-ms-ssim-vert-lcs-horiz-ldg.md, rebase-notes.md entry, state.md row, no user-discoverable surface change (perf-only). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lusoris
force-pushed
the
perf/cuda-ms-ssim-vert-lcs-horiz-ldg-20260529
branch
from
May 29, 2026 09:38
01cd110 to
898b8e1
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
__ldg()+const float *__restrict__pointer extraction to the twotop ms_ssim candidates from PR docs(cuda): ADR-0756 F3 struct-by-value audit — 20 kernels, top-5 dispatch #96's audit:
ms_ssim_vert_lcs(5×11 = 55loads) and
ms_ssim_horiz(2×11 = 22 loads). Mirrors the F3 patternestablished in PR perf(cuda): SSIM vert_combine — __ldg() + __launch_bounds__ + pinned-host leak fix (ADR-0754) #93 (ADR-0754) for
calculate_ssim_vert_combine.__launch_bounds__(128)to both kernels (actual launch is 16×8 = 128threads; consistent with ADR-0754 and ADR-0743 precedents).
LDG.E.CONSTANTconfirmed in sm_89 SASS viacuobjdump --dump-sass.intermediate footprint exceeds L2 at ≥1080p).
Files changed
core/src/feature/cuda/integer_ms_ssim/ms_ssim_score.cu— kernel edits (≈38LOC net)
docs/adr/0757-cuda-ms-ssim-vert-lcs-horiz-ldg.md— ADRdocs/adr/README.md— index rowcore/src/feature/cuda/AGENTS.md— F3 invariant extended (second application)changelog.d/perf/cuda-ms-ssim-vert-lcs-horiz-ldg.md— changelog fragmentdocs/rebase-notes.md— no rebase impact noteddocs/state.md— perf closure rowBuild / correctness verification
ncu command (reproducer)
docker exec vmaf-dev-mcp ncu \ --set basic \ --kernel-name ms_ssim_vert_lcs,ms_ssim_horiz \ /usr/local/bin/vmaf \ --feature ms_ssim --backend cuda \ --reference /workspace/python/test/resource/yuv/checkerboard_1920_1080_10_3_0_0.yuv \ --distorted /workspace/python/test/resource/yuv/checkerboard_1920_1080_10_3_1_0.yuv \ --width 1920 --height 1080 --pixel_format 420 --bitdepth 8Deep-dive deliverables checklist
## Alternatives consideredAGENTS.mdinvariant:__ldg() pattern for pass-2 read-only intermediate buffersextended (second application)changelog.d/perf/cuda-ms-ssim-vert-lcs-horiz-ldg.mddocs/rebase-notes.mdentry (no rebase impact: fork-local file)Per-surface docs
no user-discoverable surface change — perf-only kernel annotation; no API,
CLI flag, or metric output change.
state.md
Updated with T-CUDA-MS-SSIM-LDG-F3-20260529 closure row.
PR #93 precedent
ADR-0754 / PR #93 measured 0.00e+00 ULP diff on
calculate_ssim_vert_combineafter the same pattern. Expected identical result here (same Gaussian weight
table, no arithmetic change,
__ldg()only affects cache routing).🤖 Generated with Claude Code