Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix parameter values for ModExp examples and add post init assertions for better error messages #1399

Merged
merged 2 commits into from
Sep 9, 2024

Conversation

tanujkhattar
Copy link
Collaborator

Fixes #1398

%%time
show_call_graph(_modexp_small.make())

now takes ~40seconds on my laptop. I'd say this is slow; cc #957

@tanujkhattar tanujkhattar merged commit 8a28307 into quantumlib:main Sep 9, 2024
8 checks passed
@mpharrigan
Copy link
Collaborator

Here's the logging output with timing information

INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for ModExp from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for |1> from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for |0> from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for |0> in 0.000582625 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for |1> from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for |1> in 0.000376084 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Join from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Join in 0.000468458 s
INFO:qualtran.resource_counting._costing:Computed qubit count for |1> in 0.272608 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Split from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Split in 0.000241083 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CModMulK from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Allocate from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Allocate in 0.000414625 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CtrlScaleModAdd from 1 callee(s)
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CModAddK from 1 callee(s)
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for AddK from 2 callee(s)
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CNOT from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for CNOT in 0.000380208 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Add from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Split from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Split in 0.0003765 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for And from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Allocate from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Allocate in 0.0003015 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for H from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for H in 0.000245542 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for T from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for T in 0.000242125 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for T† from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for T† in 0.000350458 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for S from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for S in 0.000470875 s
INFO:qualtran.resource_counting._costing:Computed qubit count for And in 0.00655462 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for And† from 1 callee(s)
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for ArbitraryClifford(n=2) from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for ArbitraryClifford(n=2) in 0.000244375 s
INFO:qualtran.resource_counting._costing:Computed qubit count for And† in 0.00190808 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Join from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Join in 0.000376041 s
INFO:qualtran.resource_counting._costing:Computed qubit count for Add in 29.2012 s
INFO:qualtran.resource_counting._costing:Computed qubit count for AddK in 29.2036 s
INFO:qualtran.resource_counting._costing:Computed qubit count for CModAddK in 29.2046 s
INFO:qualtran.resource_counting._costing:Computed qubit count for CtrlScaleModAdd in 29.2053 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CtrlScaleModAdd from 1 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for CtrlScaleModAdd in 0.000362334 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CSwap from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Split from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Split in 0.000501084 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for TwoBitCSwap from its decomposition
INFO:qualtran.resource_counting._costing:Computed qubit count for TwoBitCSwap in 0.00351121 s
INFO:qualtran.resource_counting._costing:Computed qubit count for CSwap in 0.996553 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Free from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Free in 0.000211375 s
INFO:qualtran.resource_counting._costing:Computed qubit count for CModMulK in 30.2055 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CModMulK from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CtrlScaleModAdd from 1 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for CtrlScaleModAdd in 0.000213542 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CtrlScaleModAdd from 1 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for CtrlScaleModAdd in 0.0002935 s
INFO:qualtran.resource_counting._costing:Computed qubit count for CModMulK in 0.00164363 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Join from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Join in 0.000405333 s
INFO:qualtran.resource_counting._costing:Computed qubit count for ModExp in 30.5083 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for ModExp from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for |1> from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for |0> from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for |0> in 0.000471792 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for |1> from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for |1> in 0.000335375 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Join from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Join in 0.000411792 s
INFO:qualtran.resource_counting._costing:Computed qubit count for |1> in 0.270344 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Split from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Split in 0.000309583 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CModMulK from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Allocate from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Allocate in 0.000251458 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CtrlScaleModAdd from 1 callee(s)
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CModAddK from 1 callee(s)
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for AddK from 2 callee(s)
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CNOT from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for CNOT in 0.000391083 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Add from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Split from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Split in 0.000415709 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for And from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Allocate from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Allocate in 0.000204541 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for H from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for H in 0.0002345 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for T from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for T in 0.000225459 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for T† from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for T† in 0.000271417 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for S from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for S in 0.000370583 s
INFO:qualtran.resource_counting._costing:Computed qubit count for And in 0.0055845 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for And† from 1 callee(s)
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for ArbitraryClifford(n=2) from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for ArbitraryClifford(n=2) in 0.000210667 s
INFO:qualtran.resource_counting._costing:Computed qubit count for And† in 0.00142725 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Join from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Join in 0.000389 s
INFO:qualtran.resource_counting._costing:Computed qubit count for Add in 30.1964 s
INFO:qualtran.resource_counting._costing:Computed qubit count for AddK in 30.1977 s
INFO:qualtran.resource_counting._costing:Computed qubit count for CModAddK in 30.1983 s
INFO:qualtran.resource_counting._costing:Computed qubit count for CtrlScaleModAdd in 30.1991 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CtrlScaleModAdd from 1 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for CtrlScaleModAdd in 0.000315458 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CSwap from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Split from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Split in 0.000411 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for TwoBitCSwap from its decomposition
INFO:qualtran.resource_counting._costing:Computed qubit count for TwoBitCSwap in 0.00306588 s
INFO:qualtran.resource_counting._costing:Computed qubit count for CSwap in 1.0064 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Free from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Free in 0.0002405 s
INFO:qualtran.resource_counting._costing:Computed qubit count for CModMulK in 31.2087 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CModMulK from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CtrlScaleModAdd from 1 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for CtrlScaleModAdd in 0.000198417 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CtrlScaleModAdd from 1 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for CtrlScaleModAdd in 0.000182208 s
INFO:qualtran.resource_counting._costing:Computed qubit count for CModMulK in 0.00129192 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Join from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Join in 0.000285292 s
INFO:qualtran.resource_counting._costing:Computed qubit count for ModExp in 31.4834 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for ModExp from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for |1> from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for |0> from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for |0> in 0.000369541 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for |1> from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for |1> in 0.000333083 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Join from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Join in 0.000234792 s
INFO:qualtran.resource_counting._costing:Computed qubit count for |1> in 0.289245 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Split from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Split in 0.000175416 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CModMulK from its decomposition
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for Allocate from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for Allocate in 0.000250541 s
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CtrlScaleModAdd from 1 callee(s)
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CModAddK from 1 callee(s)
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for AddK from 2 callee(s)
INFO:qualtran.resource_counting._qubit_counts:Computing qubit count for CNOT from 0 callee(s)
INFO:qualtran.resource_counting._costing:Computed qubit count for CNOT in 0.000327541 s

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

show_call_graph(_modexp_small) fails with an error "CModMulK: base is not invertible for the given modulus"
3 participants