Skip to content

Performance: Speed up quantum allocation combining - #5318

Open
taalexander wants to merge 2 commits into
NVIDIA:mainfrom
taalexander:perf/candidate-rooted-combine-quantum-alloc
Open

Performance: Speed up quantum allocation combining#5318
taalexander wants to merge 2 commits into
NVIDIA:mainfrom
taalexander:perf/candidate-rooted-combine-quantum-alloc

Conversation

@taalexander

Copy link
Copy Markdown
Collaborator

CombineQuantumAllocations currently adds every operation in a function to its
greedy rewrite worklist, even though its patterns only apply to quantum
allocations and the operations that form views of them.

This change builds the worklist from those operations instead. Newly created
operations remain eligible for rewriting, and nested candidates are included
because they can refer to an allocation from an enclosing region.

Performance

Each generated kernel started with 16 single-qubit allocations, which the pass
combined into one allocation. The number of gates was much larger than the
number of allocations, which is why avoiding a rewrite-worklist entry for every
gate matters here:

  • 16 allocations and 500,000 gates: 1.44 seconds to 0.19 seconds, about 7.5x
    faster.
  • 16 allocations and 1,500,000 gates: 4.86 seconds to 0.51 seconds, about 9.5x
    faster.

Peak memory was also lower in both cases.

Seed the greedy rewrite driver with the allocation and quantum-view operations it owns instead of every operation in the function. Keep generated operations eligible and include nested typed users so region-local allocation and fixed-point behavior remain unchanged while large gate-heavy kernels avoid the full worklist cost.

Verified with focused transform, scoped allocation, Python builder, atomic-region, and OpenQASM coverage. Final A/B runs through 1.5 million gates produced identical placement outputs and OpenQASM while reducing the isolated pass median by 9.46x at the largest size.

Signed-off-by: Thomas Alexander <talexander@nvidia.com>
Signed-off-by: Thomas Alexander <talexander@nvidia.com>
@taalexander taalexander added performance agentic-autoresearch Tracking automated development by agentic systems labels Aug 28, 2026
@taalexander taalexander changed the title Speed up quantum allocation combining Performance: Speed up quantum allocation combining Aug 28, 2026
@github-actions

Copy link
Copy Markdown

CI Summary (push) — ✅ passed

Run #33197338456 · ✅ 7 · ⏩ 7 · ❌ 0 · ⛔ 0

Top-level jobs (14)
Job Result
binaries ⏩ skipped
build_and_test ✅ success
changes ✅ success
config_devdeps ✅ success
config_source_build ⏩ skipped
config_wheeldeps ✅ success
devdeps ✅ success
docker_image ⏩ skipped
gen_code_coverage ⏩ skipped
metadata ✅ success
python_metapackages ⏩ skipped
python_wheels ⏩ skipped
source_build ⏩ skipped
wheeldeps ✅ success
⏩ Skipped jobs (7) — intentionally skipped on PR builds; run on merge_group / workflow_dispatch
Job
binaries
config_source_build
docker_image
gen_code_coverage
python_metapackages
python_wheels
source_build
All sub-jobs (43) — every matrix leg, with links
Job Status Link
Build and test (amd64, gcc12, openmpi) / Dev environment (Debug) ✅ success view
Build and test (amd64, gcc12, openmpi) / Dev environment (Python) ✅ success view
Build and test (amd64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (amd64, llvm, openmpi) / Dev environment (Python) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Python) ✅ success view
CI Summary ❔ in_progress view
Check for stable CUDA-Q changes ✅ success view
Configure build (devdeps) ✅ success view
Configure build (source_build) ⏩ skipped view
Configure build (wheeldeps) ✅ success view
Create CUDA Quantum installer ⏩ skipped view
Create Docker images ⏩ skipped view
Create Python metapackages ⏩ skipped view
Create Python wheels ⏩ skipped view
Gen code coverage ⏩ skipped view
Load dependencies (amd64, gcc12) / Caching ✅ success view
Load dependencies (amd64, gcc12) / Finalize ✅ success view
Load dependencies (amd64, gcc12) / Metadata ✅ success view
Load dependencies (amd64, llvm) / Caching ✅ success view
Load dependencies (amd64, llvm) / Finalize ✅ success view
Load dependencies (amd64, llvm) / Metadata ✅ success view
Load dependencies (arm64, gcc12) / Caching ✅ success view
Load dependencies (arm64, gcc12) / Finalize ✅ success view
Load dependencies (arm64, gcc12) / Metadata ✅ success view
Load dependencies (arm64, llvm) / Caching ✅ success view
Load dependencies (arm64, llvm) / Finalize ✅ success view
Load dependencies (arm64, llvm) / Metadata ✅ success view
Load source build cache ⏩ skipped view
Load wheel dependencies (amd64, 12.6) / Caching ✅ success view
Load wheel dependencies (amd64, 12.6) / Finalize ✅ success view
Load wheel dependencies (amd64, 12.6) / Metadata ✅ success view
Load wheel dependencies (amd64, 13.0) / Caching ✅ success view
Load wheel dependencies (amd64, 13.0) / Finalize ✅ success view
Load wheel dependencies (amd64, 13.0) / Metadata ✅ success view
Load wheel dependencies (arm64, 12.6) / Caching ✅ success view
Load wheel dependencies (arm64, 12.6) / Finalize ✅ success view
Load wheel dependencies (arm64, 12.6) / Metadata ✅ success view
Load wheel dependencies (arm64, 13.0) / Caching ✅ success view
Load wheel dependencies (arm64, 13.0) / Finalize ✅ success view
Load wheel dependencies (arm64, 13.0) / Metadata ✅ success view
Prepare cache clean-up ❔ in_progress view
Retrieve PR info ✅ success view
✅ Required checks (6/6) — declared in .github/required-checks.yml for push
Required check Status Link
Build and test (amd64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (amd64, llvm, openmpi) / Dev environment (Python) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Python) ✅ success view
Build and test (amd64, gcc12, openmpi) / Dev environment (Debug) ✅ success view
Build and test (amd64, gcc12, openmpi) / Dev environment (Python) ✅ success view

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

Labels

agentic-autoresearch Tracking automated development by agentic systems core compiler performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant