Repository navigation
⚡ Streamline QC/QCO conversion and builders - #2716
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
2cf5d43 to
ea8a87f
Compare
9f95e6c to
0dde327
Compare
f419fb6 to
9d929c5
Compare
9d929c5 to
c09c66a
Compare
Thread quantum state through ordinary rewrite patterns in an explicit source-order traversal. Retain source references until their users are lowered, preserving region ownership and function argument order. Keep folding and CSE during normalization without generic region cleanup. Cover interleaved calls, nested unitary calls, and folded register aliases. Leave QCO-to-QC and the base branch's verification policy unchanged. Assisted-by: OpenAI Codex
Append converted function arguments and erase the old prefix in bulk to avoid repeated shifting. Preserve argument order, attributes, locations, and source quantum identities until lowering finishes. Cover wide interleaved signatures and remapped register indices. Assisted-by: OpenAI Codex
🤖 *AI text below* 🤖 Avoid temporary string allocations in the wide-signature regression and separate historical performance evidence from current-main validation. Retain upstream conditional register-analysis reuse after rebasing. Assisted-by: Codex
🤖 *AI text below* 🤖 Combine the builder and iterator audit with source-order lowering. Own unfinished builder modules, enforce region and tensor-slot contracts, and preserve positional quantum state through mixed classical control flow. Release completed conversion state, avoid duplicate capture storage and validation, and traverse single-use consumers directly. Consolidate shared conversion fixtures while preserving the conversion and regression cases. Keep entry-block allocations, explicit quantum region arguments, and dynamic tensor-index equality as documented limits. Record measured memory improvements without claiming a general full-pipeline speedup. Assisted-by: GPT-6 via Codex
🤖 *AI text below* 🤖 Select the expected diagnostic for each tensor-slot rejection scenario. GoogleTest's Windows regex engine rejects grouping and alternation, so the shared matcher failed despite the builder emitting the correct error. Retain all three cases and check their specific diagnostics. Validate the matcher with GoogleTest's simple regex engine and the complete QCO IR suite. Assisted-by: GPT-6 via Codex
🤖 *AI text below* 🤖 Use operand positions for unitary wire traversal and restore the shared range in read-only consumers. Keep tail-first erasure explicit. Wide traversal now scales linearly while generic calls and unknown carriers remain boundaries. Keep structured capture order in one record, derive modifier yields from live block arguments, and replace unused type-conversion machinery with exact type helpers. Preserve graceful rejection of misplaced yields and cover it with a small regression. Record paired performance measurements and their limits. Assisted-by: GPT-6 via Codex
e63d939 to
1bebf32
Compare
There was a problem hiding this comment.
Thanks @simon1hofmann 🙏 I had codex combine the changes here with my local audit and optimized the resulting implementation a bit further.
Would you mind giving this another check?
This looks pretty good from my side.
Edit: Codex just had one more idea. I'll quickly explore that and push if it turns out to be useful.
Edit(2): ac30ce4 is the result. Should be good now.
🤖 *AI text below* 🤖 Erase converted source calls once their classical results are replaced, while retaining calls whose QC results still identify mapped state. Reuse register analysis when normalization leaves the IR unchanged, and let full CSE report constant merging reliably before deciding whether to rebuild that analysis. Avoid copied operand lists and single-qubit alias bookkeeping. Remove the redundant symbol lookup from wire-origin collection under its verified-input contract. Extend existing tests for chained classical calls and aliases exposed by folding or CSE without increasing the test count. Validate 4015 native tests plus one existing skip, all 178 conversion tests after the final fixture simplification, repository lint, whole-file C++ lint, and an independent Ponytail review. Nine paired runs across 115 built-in inputs preserve identical output. Cases taking at least 1 ms improve by 7-15%; the largest distillation case uses 6.4 MiB less peak RSS. Measurements use CPU affinity on a shared DGX Spark, not reserved cores. Assisted-by: GPT-6 via Codex
This one also looks good to me and should speed up the conversions quite substantially ⚡ |
Nice! Let's get it in! My local results across a couple of benchmark instances yielded 1.5-10x improvements for the conversion itself. ⚡ |
🤖 AI text below 🤖
Description
QC-to-QCO conversion used a general dialect-conversion driver to maintain mutable quantum state, while builders and wire traversal repeated work or relied on implicit ownership and positional assumptions. This combines the source-order converter with the QC/QCO audit and its follow-up simplifications.
WireIteratorand restoreWireRangein three read-only consumers. Use operand positions for unitary correspondence, making traversal across all wires of a wide operation linear rather than quadratic. Keep tail-first deletion explicit and preserve generic-call boundaries.API and supported inputs: QC/QCO builders own unfinished modules and are move-only. Borrowed contexts must outlive builders and IR. QC allocations remain restricted to function entry blocks; quantum region values preserve positional identity. QTensor scalars return to their original register slot, with equal dynamic extraction/insertion indices remaining a caller precondition. No new dependency is required.
Performance: Five paired rounds on shared DGX Spark hardware show 124×/45× faster forward traversal through an 8,192-wire barrier/unitary call. The isolated 32-wire call is 15% slower; this is not a universal speedup. Restoring ranges has no material cost in the measured QFT-18 and Ising-26 pipelines. Further converter cleanup saves 1.69 MiB (2.8%) of peak RSS for 2,000 sibling loops; flat and register-load conversion times are essentially unchanged. All 90 wire samples agree on traversal counts, and all 105 conversion/pipeline samples agree on IR hashes and gate counts. See the follow-up audit and its linked original comparison for pins, methods, and limits.
Validation: Rebased onto main
3f1ccfd69, preserving original authorship. Independent design and final Ponytail reviews are addressed. The full native build passes; 4,015 tests pass, including 2,910 MLIR tests, with one expectedScQDMIJobSpecificationTest.QueryJobIdskip. Repository lint, whole-file C++ lint for 20 selected files, MLIR reference generation, and output checks pass. Python/wheels, sanitizers, and native Windows execution were not rerun locally. The portable death-test fix remains included; hosted CI must validate this published head separately.Codex assisted with implementation, consolidation, measurement, review, and this description. Human review and acceptance remain outstanding.
Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).