Repository navigation
feat(cuda): evaluate two ADM viewing distances in one adm_cuda instance - #2647
Merged
Merged
Conversation
lusoris
force-pushed
the
port/upstream-cffd5b77-cuda
branch
3 times, most recently
from
October 9, 2026 08:09
ff741b5 to
10d0013
Compare
This was referenced Oct 9, 2026
…ce (#2647) * feat(cuda): evaluate two ADM viewing distances in one adm_cuda instance adm_cuda takes adm_norm_view_dist_extra and the merge callback: the scale-0 and scale-1..3 DWT run once per frame, and the denominator, CSF, contrast-masking and AIM kernels run once per distance into that distance's result block (tmp_res and results_host hold two). The host concludes each distance with its own CPU contexts and files the second under the <base>:nvde keys. Both distances return the CPU's bits (ADR-2795; test_adm_two_views_exact, test_adm_merged_registrations_exact). The merge callback and the second distance's names move into adm_view_dist.c, which reads the options by name at each descriptor's own offsets, so the CPU extractor, the Rust twin and adm_cuda share one implementation; integer_adm.c drops its copies. Signed-off-by: Lusoris <lusoris@proton.me>
13 of 27 tasks
lusoris
force-pushed
the
port/upstream-cffd5b77-cuda
branch
from
October 9, 2026 08:47
10d0013 to
8cc34b5
Compare
This was referenced Oct 9, 2026
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
The CUDA twin of integer ADM evaluates two viewing distances in one instance, the second step of the Q-298 stack (ADR-2795). This covers
adm_norm_view_dist_extraand two models such asvmaf_v1.0.16_3d0hand_5d0hon--backend cuda. The wavelet transform runs once per scale. The denominator, CSF, contrast-masking and AIM kernels run once per distance. Both distances return the CPU's scores bit for bit.The merge callback and the name dictionary move into a shared helper. It reads the options by name, so the CPU extractor,
adm_rustandadm_cudause one implementation (HISS-19). The SYCL, HIP and Metal twins will plug into it.Stacked on #2646 (C + Rust). This branch contains its commit; it rebases to one commit once #2646 lands.
Maintainer decision Q-298 (2026-10-08): "D4 nvde, cffd5b77d + 33e5f0aca: full scope — C + Rust mirror (ADR-1713) AND bit-identical on CUDA, SYCL, HIP and Metal now (no DEFAULT_ONLY). Stack it as needed (C+Rust first, then one PR per backend is fine), each with == parity tests and exact_twins entries; device runs under the locks; Metal evidence is outside hardware — mark pending with the tester path if no Mac is available."
What changed
core/src/feature/adm_view_dist.{c,h}(new):vmaf_adm_merge_view_dist(),vmaf_adm_extend_name_dict(),vmaf_adm_view_count(),vmaf_adm_view_dist()and the key tables.adm_norm_view_dist,adm_norm_view_dist_extra,debugandadm_skip_aimin the descriptor's option table.privcopy with the distance replaced renders the names.core/src/feature/integer_adm.c: drops its static copies of these and points.merge/.extend_name_dictat the helpers. The scores are unchanged.core/src/feature/cuda/integer_adm_cuda.c:adm_norm_view_dist_extra(nvde), the same table entry as the CPU's.adm_scale0_transform()/adm_scale123_transform()(DWT) andadm_scale0_weigh()/adm_scale123_weigh()(per distance, throughadm_view_buffer(), which swaps in the second block's result slots).tmp_resandresults_hosthold twoRES_BUFFER_SIZEblocks.adm_cm_scale_result(),adm_csf_den_scale_result(),adm_dlm_terms(),adm_aim_num()) take the distance as an argument. The CSF configuration is checked for every distance before device resources are claimed.write_scores()files each distance, the second under<base>:nvde, with no debug scores. Init extends the name dictionary through the helper.test_cuda_adm_parity.c: the recorded option gap is gone, andMAX_KEYSgoes to 32.test_adm_two_views_exactcovers 8-bit and 10-bit withdebug, and the model options at 3H/5H.test_adm_merged_registrations_exactregistersadm_cudatwice, as two models do, against one CPU context. Both compare with==.test_adm_view_merge.c:test_every_adm_descriptor_merges. A registered ADM descriptor must merge exactly when its row says so (adm,adm_cudayes; SYCL/HIP/Metal flip in their pull requests), and each merging descriptor folds nvd 5 into nvd 3 on its own option layout.test_adm_view_dist_contract.py: keys read from the helper. The non-feature-parameter option set is checked for every merging table (adm,adm_cuda).test_cuda_adm_exact_contract.py: the pinned denominator-context calls take the distance argumentnvdinstead ofs->adm_norm_view_dist. The launch and the result must still both use them.docs/metrics/adm.md: option row and backends.core/src/feature/AGENTS.d/adm-view-distance-merge.mdandcore/src/feature/cuda/AGENTS.d/adm.md.Evidence
test_cuda_adm_parityon the RTX 4090 (CUDA 13.4.92, the pinned release)==adm_cudawithout merge; every view's kernels at the first distance; second view writing the first view's slots; host DLM conclusion at the first distance; no second-distance namestest_cuda_adm_parityortest_adm_view_merge--precision max,vmaf_v1.0.16_3d0h+_5d0htogether vs each alone, 576x324 pair, 48 framesfeature_backends) of the two-model runadm_cuda(master registers twoadm)test_adm_view_merge,test_integer_adm_view_dist,test_adm_view_dist_contract.pyrust_twin_diff.py --feature adm, Netflix + checkerboard, threads 0 and 4GOLDEN_NINJA_JOBS=4)adm_view_dist.cinteger_adm.ctest_adm_view_merge.cinteger_adm_cuda.ctest_cuda_adm_parity.cbugprone-multi-level-implicit-pointer-conversionand one braces finding fixed)scripts/dev/preflight.sh --stage msvcismType
feat— new featurefix— bug fixperf— performance improvementrefactor— no behavior changedocs— documentation onlytest— test-onlybuild/ci— tooling / infraport— cherry-pick from upstream Netflix/vmafsycl/cuda/simd— backend-specificChecklist
git commit -s; fix a branch withgit rebase --signoff origin/master). See DCO sign-off.make format && make lintis green locally. Not run as one target. These are green: the commit hooks and tidy above.python3 scripts/ci/run_meson_test.py -- -C build. Fast suite, see Evidence./cross-backend-diffand the worst ULP is ≤ 2. 0 ULP: the twin's outputs equal the CPU's (==tests and the CLI comparison)..c/.cpp/.cu/.h/.hpp, it has the appropriate license header (seeCONTRIBUTING.md).!orBREAKING CHANGE:and the migration path is documented below. Not a breaking change.docs/adr/_index_fragments/<NNNN-slug>.mdand nothing else is touched for the index. No new ADR: ADR-2795 (port(upstream): libvmaf/adm: share computation across viewing distances (cffd5b77d + 33e5f0aca) #2646) decides the GPU twins' step.Bug-status hygiene (ADR-0165)
docs/state.mdupdated in this PR with a row in the appropriate section (Open / Recently closed / Confirmed not-affected / Deferred). Not needed — no state delta: a feature step of the upstream port; it opens and closes no bug.Netflix golden-data gate (ADR-0024)
assertAlmostEqual(...)score in the Netflix golden Python tests, except by porting Netflix's own updated assertion verbatim from upstream (value and places as upstream has them, measured against the fork's CPU build first; ADR-1828).Cross-backend numerical results
adm_cudaagainst the CPU, both distances: 0 differences. That holds intest_cuda_adm_parity(25 values withdebugat 8 and 10 bits, 14 values with the model options) and on the 48-frame CLI run (1352 values).adm.cudastays declared exact (scripts/ci/exact_twins.d/adm.cuda).Deep-dive deliverables (ADR-0108)
AGENTS.mdinvariant note —core/src/feature/cuda/AGENTS.d/adm.mdandcore/src/feature/AGENTS.d/adm-view-distance-merge.md.changelog.d/added/adm-cuda-shared-viewing-distances.md.docs/rebase-notes.d/adm-cuda-shared-viewing-distances.md.Reproducer
Known follow-ups
admtwins: one pull request each, stacked on this one.