fix(test): row-pair leaf layout in merkle_root_parity GPU parity tests#745
Open
MauroToscano wants to merge 1 commit into
Open
fix(test): row-pair leaf layout in merkle_root_parity GPU parity tests#745MauroToscano wants to merge 1 commit into
MauroToscano wants to merge 1 commit into
Conversation
gpu_merkle_root / gpu_ext3_merkle_root called keccak_leaves_base/ext3 with rows_per_leaf=1 (per-row, num_rows leaves) but compare the resulting root against the CPU commit_rows_bit_reversed, which uses the row-pair layout (ROWS_PER_LEAF=2, num_rows/2 leaves, each hashing a bit-reversed row pair). Different leaf count and bytes => different root, so the two cases never matched main's row-pair commitment scheme. Pass rows_per_leaf=2 so the generic GPU keccak-leaves + Merkle path uses the same bit-reversed row-pair layout as the CPU reference. keccak_leaves.rs already proves keccak_leaves_base(.., 2) matches the CPU row-pair prover, and the production-pipeline parity cases (new_row_major_pipeline_*) already pass, so this only realigns the generic-helper cases with main. Test-only change; the proving path uses the fused row-pair pipeline and is unaffected. GPU tests don't run in CI (no nvcc) — to be confirmed on a GPU.
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.
What
Two GPU↔CPU root-parity cases in
crypto/math-cuda/tests/merkle_root_parity.rscompare against the wrong Merkle leaf layout onmain:gpu_and_cpu_row_major_merkle_roots_matchgpu_and_cpu_ext3_merkle_roots_matchTheir GPU helpers (
gpu_merkle_root/gpu_ext3_merkle_root) callkeccak_leaves_base/keccak_leaves_ext3withrows_per_leaf = 1(per-row →num_rowsleaves), but the CPU referencecommit_rows_bit_reverseduses the row-pair layout (ROWS_PER_LEAF = 2→num_rows / 2leaves, each hashing a bit-reversed row pair). Different leaf count and different leaf bytes ⇒ different root, so these two cases can never matchmain's row-pair commitment scheme.Fix
Pass
rows_per_leaf = 2at both call sites so the generic GPU keccak-leaves + Merkle path uses the same bit-reversed row-pair layout as the CPU commit. (Plus updated the now-inaccurate "per-row" comments.)Why this is a test fix, not a production bug
keccak_leaves_base/keccak_leaves_ext3have no production callers — the proving path uses the fusedcoset_lde_*_row_major_with_merkle_tree_keep, which is already row-pair. GPU/CPU proof parity was never affected, which is exactly why proofs verify with and without the GPU.tests/keccak_leaves.rs::keccak_leaves_base_row_pair_matches_cpu(and the ext3 equivalent) already verify thatkeccak_leaves_base(.., 2)matches the CPU row-pair prover helper.new_row_major_pipeline_base_root_matches_cpu/…_ext3_…exercise the real fused pipeline (row-pair on both sides) and are green.Background
These two cases were introduced in #715 (per-row GPU leaves). #735 ("unify & clean up the commitment layer") moved the scheme to row-pair — adding
ROWS_PER_LEAF = 2, the row-pair leaf kernels, and a row-paircommit_rows_bit_reversed— but left these two test calls at the oldrows_per_leaf = 1. This realigns them. The mismatch went unnoticed because GPU tests don't run in CI (nonvcc).Testing
Not run locally — no GPU/CUDA on the dev box, and
math-cudaonly builds under thecudafeature. To be confirmed on a GPU machine: all four cases inmerkle_root_parity.rsshould pass.rustfmtclean.