Skip to content

Add SELECT-COPY QROM, measured Restore, and retained lookup epochs - #65

Open
kvmto wants to merge 4 commits into
NVIDIA:mainfrom
kvmto:pr/qrom-select-copy
Open

kvmto wants to merge 4 commits into
NVIDIA:mainfrom
kvmto:pr/qrom-select-copy

Conversation

@kvmto

@kvmto kvmto commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Add SELECT-COPY QROM and sequential lookup APIs with coherent packets, measured Restore, and a bank retained across caller operations.

QROM(variant="select_copy") supports balanced alpha packets, fused packet transitions, clean or borrowed banks, and max_ancillas. Coherent auto-selection compares SELECT, SELECT-SWAP, and SELECT-COPY, so callers can set an explicit workspace budget. QROMChain supplies consecutive XOR-difference steps on a shared clean ladder. AliasSamplingPrepare accepts the coherent selection options and keeps its PREPARE/adjoint unitary.

The adaptive APIs provide:

  • MeasuredQROM(variant="select_copy") with balanced alpha or fixed packet_width packets, including a shorter remainder. Dirty-bank Restore uses a clean temporary AND, fanout, measurement, and feedback, with one separately budgeted scratch qubit. The borrowed bank is restored and never measured or reset.
  • RetainedQROMChain with begin_kernel, all difference-step kernels, and end_kernel. A full-word bank and offset cache stay live; resources include both endpoints and the cache. Address/control computational-basis values must stay fixed and the ladder untouched throughout. Arbitrary output operations preserve XOR-sequence equivalence; zero final output requires initially zero output and interleavings preserving the encoded word.
  • erase_kernel for a known clean-copy table image, with runtime parity correction and zero output required on inactive-control and padded branches. Independent erase_resources and clean/borrowed layouts require separate ladders or proven compatible views; the load budget does not bound erase workspace.
  • Adaptive selection that checks the complete clean-plus-borrowed load workspace before ranking candidates. Built-in controlled=True supplies coherent controls; automatic control/adjoint of measured kernels is outside the contract. Whole-cache measurement cleanup remains restricted to clean SELECT-SWAP banks.

The planners reuse #64's validation, geometry, operation/resource records, cache-erasure plumbing, and interpreter. Counts separate eligible temporary ANDs from generic Toffolis. The four-T model requires compatible synthesis; it does not establish native-backend synthesis or hardware costs. Guides and examples document the contracts and paper-accounting differences.

Validation: 299 host tests passed; 982 native tests passed, with three optional-dependency skips (OpenFermion/Psi4) and two SDK warnings. Independent channel, packet, retained-epoch, and resource tests passed, alongside CUDA-Q 0.16 qpp-cpu checks, examples, formatting, and Sphinx with warnings as errors.

Merge #64 first. These published branches currently have sibling histories based on main, and #65 includes the shared foundation. Update and revalidate #65 after #64 lands.

Port SELECT-COPY and balanced packet bank transitions onto the current
validated and pruned interpreter, preserving QROM.kernel as a property.
Validate chain inputs before XOR and forward packet/budget choices through
alias sampling. Add explicit coherent echoes for arbitrary borrowed banks
in forced SELECT-SWAP and SELECT-COPY with clean/dirty workspace counts.

Document the required inverse sector and chain interleaving contract;
provide independent complex-state, downstream consumer and resource tests
and a runnable controlled-rotation chain example.

Co-authored-by: Scott Thornton <wsttiger@gmail.com>
Signed-off-by: Kevin Mato <kmato@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Replace the per-address walk-count loop with its closed form, so the automatic strategy search is polynomial in the address width (a one-entry 26-bit table took 6.4 s, now milliseconds), filter candidates by the ancilla budget before pricing, keep the winning price and check it against the minted tape, and reject bools for alpha, max_ancillas and block_size.

QROMChain accepts any iterable table (numpy arrays included), validates the register widths once, wraps every option error with a chain-level prefix, requires a plain bool for fused, reuses the single lookup of a one-table chain, and builds its naive interior kernels as pair kernels over the step lookups instead of concatenated interpreters.

Restore the SELECT-COPY and chain tests from the experimental branch (exhaustive packet readouts, variant agreement, compiled counts for select_copy, the documented formulas and margins, per-step compiled counts, prefix readout, step self-inverse), pin the closed-form prices against the minted tapes for both blocked variants and both bank modes, and share the test helpers already in the suite.

Document that auto now returns select_copy for most shapes and may spend more workspace than the earlier default, with max_ancillas as the knob, state the budget and view-width contracts precisely, separate the chain's equivalence condition from its table-value invariant, and list the example and guide in the navigation.

Signed-off-by: Kevin Mato <kmato@nvidia.com>
@kvmto
kvmto force-pushed the pr/qrom-select-copy branch from 9ae4996 to 44644d5 Compare October 13, 2026 22:04
@kvmto
kvmto marked this pull request as ready for review October 13, 2026 22:14
Signed-off-by: Kevin Mato <kmato@nvidia.com>
@kvmto
kvmto requested a review from wsttiger October 13, 2026 23:21
Signed-off-by: Kevin Mato <kmato@nvidia.com>
@kvmto kvmto changed the title Add SELECT-COPY QROM, workspace budgets, and fused lookup chains Add SELECT-COPY QROM, measured Restore, and retained lookup epochs Oct 14, 2026
@kvmto

kvmto commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

@wsttiger Scott, the completion update is now pushed. In addition to the coherent implementation, this adds measurement-assisted SELECT-COPY, retained banks/cached offsets across caller operations, temporary-AND Restore, and known-image output erasure.

Could you review this as the follow-up to #64? It reuses #64's foundation; #64 should merge first, after which this branch will be updated against main and revalidated. Local validation on the pushed tree: 299 host tests passed; 982 native tests passed, with 3 optional-dependency skips. The updated description explains the retained-epoch preconditions and logical resource accounting.

@wsttiger wsttiger added enhancement New feature or request release - v0.2 Targeted for the v0.2 release release - v0.3 Targeted for the v0.3 release and removed release - v0.2 Targeted for the v0.2 release labels Oct 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request release - v0.3 Targeted for the v0.3 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants