Conversation
…sition) Workstream B of PLAN_primitives_016_refactor.md. CUDA-Q 0.16 fixed cudaq.control propagation through kernels that call other kernels, so the select_swap lookup no longer needs to be one flat spliced tape: - W is now the plain unary_iteration_kernels mint over the block index, used directly — its target view IS the block registers. The rebase loop (shifting the walk's address operands onto the high bits and rewriting the leaf body X into ladder-to-ladder CNOTs) is deleted along with the _ADDRESS_OPERANDS table. - S is a small dedicated routing kernel over (low address bits, blocks) applying the binary Fredkin network; its inverse is the same mint over the reversed swap list. - A minted parent kernel keeps the public (address, ladder, output) signature and num_ladder contract, carves the documented sub-views with qview slices, and composes W S C S_inv W (C is the b copy CNOTs, inline). Verified before restructuring: qview slicing (including on qview parameters) and cudaq.estimate_resources counting across sub-kernel calls both work on 0.15.1 and both 0.16 builds, so the resource tests keep pinning toffoli_count == the compiled ccx count of the composition. Deleted _OP_CX_LADDER_TARGET end to end (opcode, dispatch arms in all four interpreter variants, describe() template, interpreter-test spec): its only user was the spliced construction's copy stage. The 'flatness is load-bearing' claim in the walk module docstring now states the honest boundary: required through CUDA-Q 0.15, an inspectability/ factory-time-body design choice from 0.16. Support boundary: the composed lookup runs uncontrolled on 0.15.1 (kernels calling kernels was always legal; full QROM suite green), but external cudaq.control over the composition needs 0.16 — the new test pinning the controlled composition against the dense reference probes the capability and skips honestly on older CUDA-Q. Full primitives set: 152 passed on both 0.16 builds (release tip and with the #5280 fix). Signed-off-by: Scott Thornton <wsttiger@gmail.com>
Workstreams C and E of the 0.16 refactor plan: the package docstring now states the composition contract — minted kernels are building blocks to call from user kernels, and (CUDA-Q >= 0.16) cudaq.control over the whole composition yields the controlled operation, with controlled=True remaining the cheaper folded-into-the-walk option everywhere. Pinned by tests/python/test_primitives_composition.py: plain composition (walk then hand-written inverse inside a user kernel, valid on every supported CUDA-Q) and controlled composition against both the builtin controlled walk and the analytic state on a superposed control, capability-probed so pre-0.16 runs skip with an honest reason. The docstring truth sweep found no further stale flatness claims beyond those already rewritten. Signed-off-by: Scott Thornton <wsttiger@gmail.com>
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
Modernizes the primitives subpackage for the composition freedom CUDA-Q
0.16 unlocks:
cudaq.controlnow propagates through kernels that callother kernels, so factory-minted kernels no longer have to be flattened
to survive control-variant generation.
Two commits:
Rebuild the select_swap QROM as composed kernels. The old
construction spliced the walk, swap-network, and copy into one flat
interpreter tape, smuggling the block registers through the walk's
"ladder" view (the source of repeated reviewer confusion on Add unary-iteration and QROM primitives #40).
It is now a parent kernel composing three real sub-kernels — walk,
route, copy — with honest register names. The rebase machinery and
the
_OP_CX_LADDER_TARGETopcode are deleted end-to-end. Publicsignature and
num_ladderare unchanged (the alias-sampling PRdepends on them); the existing exhaustive QROM tests pass unmodified.
Promise composition as a supported surface. A documented
contract in the package docstring — minted kernels are building
blocks callable from user kernels, and
cudaq.controlover the wholecomposition yields the controlled operation — pinned by
tests/python/test_primitives_composition.py(plain composition onevery supported CUDA-Q; controlled composition three-way vs the
builtin controlled walk and an analytic reference, capability-probed
so it skips pre-0.16). This is the consumption model future
SELECT-style constructions (QROMChain, THC) build on.
Requires cudaq >= 0.16 for the controlled-composition path (probed and
skipped on 0.15); the plain construction and all existing behavior work
on both. Stacks naturally after the arithmetic/alias PRs (#47/#48).
Validation
Existing QROM tests pass unmodified; the new composition tests pass on
released cudaq 0.15.1 and on the 0.16.0 wheel (40/40 on the QROM +
composition files). Off-π/4 rotation lowering is unaffected.