Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Use BasisTranslator for unroll 3q or more #10776

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

mtreinish
Copy link
Member

Summary

This commit modifies the the preset pass manager construction to by default use the UnrollCustomDefinitions and BasisTranslator passes to perform the unrolling of operations that operate on >= 3 qubits. This is done by leveraging the min_qubits argument added to those passes in this commit which lets you set a minimum number of qubit arguments to translate operations for.

Previously, this was handled by the Unroll3qOrMore pass which works by iterating over the DAG and finding all operations with >= 3 qubits and recursively unrolling them until the output is all in terms of 1 or 2 qubit operations. This works fine, but has undesireable runtime performance characteristics because standard gates repeatedly have to build new DAGs to substitute in. For example, if you had a circuit with 50k CCXGates that would result in 50k new DAGs being created from scratch for each instance of CCXGate. A previous attempt was made to add a translation cache to that pass in #10703 but as was discussed in code review caching the circuit is unsound as it's possible for a custom gate object to be constructed such that it would be cached and return an invalid substitution circuit. By leveraging the basis translator we only build as many substition DAGs as needed.

Details and comments

This commit modifies the the preset pass manager construction to by
default use the UnrollCustomDefinitions and BasisTranslator passes to
perform the unrolling of operations that operate on >= 3 qubits. This is
done by leveraging the min_qubits argument added to those passes in this
commit which lets you set a minimum number of qubit arguments to
translate operations for.

Previously, this was handled by the Unroll3qOrMore pass which works by
iterating over the DAG and finding all operations with >= 3 qubits and
recursively unrolling them until the output is all in terms of 1 or 2
qubit operations. This works fine, but has undesireable runtime
performance characteristics because standard gates repeatedly have to
build new DAGs to substitute in. For example, if you had a circuit with
50k CCXGates that would result in 50k new DAGs being created from
scratch for each instance of CCXGate. A previous attempt was made to
add a translation cache to that pass in Qiskit#10703 but as was discussed in
code review caching the circuit is unsound as it's possible for a custom
gate object to be constructed such that it would be cached and return an
invalid substitution circuit. By leveraging the basis translator
we only build as many substition DAGs as needed.
@mtreinish mtreinish added performance Changelog: New Feature Include in the "Added" section of the changelog mod: transpiler Issues and PRs related to Transpiler labels Sep 5, 2023
@mtreinish mtreinish added this to the 0.45.0 milestone Sep 5, 2023
@mtreinish mtreinish requested a review from a team as a code owner September 5, 2023 21:12
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generally looks correct to me, though it makes me wonder if we'll see any performance regressions in present transpile that have very few custom operations or 3+q gates, since we're now going to run two passes rather than one. It probably shouldn't be very much if so.

This is totally beside the point, but the behaviour described by the release notes is actually still true even if min_qubits is set to zero haha.

@jakelishman
Copy link
Member

I left it untagged for merge in case we wanted to look at timings before merge - if not, I'm happy for somebody just to add it to the queue.

@mtreinish
Copy link
Member Author

Sure, I'll run some asv benchmarks to compare a bunch of different circuits and also do some manual testing with circuits that have large numbers of 3q gates just to get some data for the PR history.

@mtreinish
Copy link
Member Author

mtreinish commented Sep 6, 2023

I ran a subset of transpilation asv benchmarks and it was basically some showed a bit of a speed improvement, but one QV test showed a runtime regression (I'm not sure exactly what was going on there but it's also only a 14ms regression so it's not a huge deal from my perspective). The time_transpile_from_large_qasm_backend_with_prop benchmarks are a good example of where this would come up more because there is nothing to to translate.

Benchmarks that have improved:

       before           after         ratio
     [734e0618]       [dcc9a9dc]
     <cache-dag-sort-key~1>       <cache-dag-sort-key>
-         132±5ms        119±0.8ms     0.90  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(2, 'stochastic', 'sabre')

Benchmarks that have stayed the same:

       before           after         ratio
     [734e0618]       [dcc9a9dc]
     <cache-dag-sort-key~1>       <cache-dag-sort-key>
         209±20ms         224±20ms     1.07  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(8, 'synthesis')
       13.7±0.2ms       14.2±0.2ms     1.04  queko.QUEKOTranspilerBench.time_transpile_bigd(0, 'sabre')
         836±20ms         854±30ms     1.02  randomized_benchmarking.RandomizedBenchmarkingBenchmark.time_ibmq_backend_transpile([0, 1])
       77.7±0.5ms         79.1±2ms     1.02  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(1, 'sabre', 'noise_adaptive')
       94.6±0.6ms         96.3±1ms     1.02  queko.QUEKOTranspilerBench.time_transpile_bigd(3, 'sabre')
        123±0.6ms          126±4ms     1.02  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(2, 'stochastic', 'noise_adaptive')
         962±10ms         978±10ms     1.02  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(3, 'stochastic', 'dense')
      4.35±0.08ms       4.42±0.1ms     1.02  qft.QftTranspileBench.time_ibmq_backend_transpile(2)
      8.98±0.08ms       9.12±0.2ms     1.02  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(2, 'synthesis')
        134±0.6ms          136±3ms     1.02  transpiler_levels.TranspilerLevelBenchmarks.time_transpile_from_large_qasm(1)
          509±7ms         516±10ms     1.01  randomized_benchmarking.RandomizedBenchmarkingBenchmark.time_ibmq_backend_transpile([0])
       23.8±0.2ms       24.1±0.3ms     1.01  qft.QftTranspileBench.time_ibmq_backend_transpile(8)
          309±2ms          312±6ms     1.01  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(3, 'stochastic', 'sabre')
       66.2±0.3ms       66.9±0.7ms     1.01  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(0, 'sabre', 'dense')
         852±30ms         861±30ms     1.01  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(14, 'synthesis')
       74.4±0.4ms       75.1±0.1ms     1.01  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(1, 'sabre', 'dense')
        143±0.7ms          144±2ms     1.01  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(2, 'sabre', 'sabre')
          159±1ms        161±0.7ms     1.01  transpiler_levels.TranspilerLevelBenchmarks.time_transpile_from_large_qasm_backend_with_prop(0)
          290±3ms          292±5ms     1.01  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(2, 'stochastic', 'noise_adaptive')
          251±1ms         254±10ms     1.01  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(1, 'stochastic', 'sabre')
       12.6±0.1ms       12.7±0.1ms     1.01  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(2, 'translator')
       72.9±0.5ms       73.4±0.7ms     1.01  queko.QUEKOTranspilerBench.time_transpile_bntf(1, None)
          217±2ms          218±3ms     1.01  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(3, 'sabre', 'dense')
         904±10ms          909±6ms     1.01  transpiler_levels.TranspilerLevelBenchmarks.time_quantum_volume_transpile_50_x_20(1)
       3.13±0.03s       3.15±0.02s     1.01  transpiler_levels.TranspilerLevelBenchmarks.time_quantum_volume_transpile_50_x_20(3)
       2.17±0.02s       2.18±0.02s     1.00  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(20, 'synthesis')
        106±0.4ms          106±2ms     1.00  transpiler_levels.TranspilerLevelBenchmarks.time_transpile_from_large_qasm_backend_with_prop(3)
          292±3ms          294±4ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(2, 'stochastic', 'dense')
          2.00±0s       2.01±0.02s     1.00  transpiler_levels.TranspilerLevelBenchmarks.time_quantum_volume_transpile_50_x_20(2)
         65.9±1ms       66.1±0.5ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(0, 'sabre', 'sabre')
          225±2ms          226±1ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(3, 'sabre', 'noise_adaptive')
       1.45±0.01s       1.46±0.01s     1.00  randomized_benchmarking.RandomizedBenchmarkingBenchmark.time_ibmq_backend_transpile_single_thread([0])
       56.8±0.3ms       57.0±0.4ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(1, 'sabre', 'sabre')
        157±0.5ms        157±0.5ms     1.00  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(8, 'translator')
        101±0.7ms          101±1ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(0, 'stochastic', 'sabre')
          710±2ms          711±8ms     1.00  transpiler_levels.TranspilerLevelBenchmarks.time_transpile_qv_14_x_14(3)
          236±3ms          236±3ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(0, 'stochastic', 'sabre')
       53.3±0.3ms       53.4±0.4ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(0, 'sabre', 'noise_adaptive')
       68.7±0.3ms       68.8±0.4ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(0, 'sabre', 'noise_adaptive')
       23.3±0.1ms       23.4±0.2ms     1.00  queko.QUEKOTranspilerBench.time_transpile_bigd(2, None)
          218±1ms          219±1ms     1.00  queko.QUEKOTranspilerBench.time_transpile_bss(1, 'sabre')
          123±1ms          123±1ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(2, 'stochastic', 'dense')
          187±2ms          187±3ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(0, 'stochastic', 'noise_adaptive')
       31.9±0.3ms         31.9±2ms     1.00  queko.QUEKOTranspilerBench.time_transpile_bigd(0, None)
          106±1ms          106±1ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(1, 'stochastic', 'noise_adaptive')
          476±6ms          476±3ms     1.00  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(14, 'translator')
        216±0.5ms          216±2ms     1.00  transpiler_levels.TranspilerLevelBenchmarks.time_transpile_from_large_qasm_backend_with_prop(2)
       75.3±0.3ms       75.3±0.4ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(2, 'sabre', 'noise_adaptive')
          249±3ms          249±3ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(2, 'stochastic', 'sabre')
          782±1ms         782±10ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(3, 'stochastic', 'noise_adaptive')
          326±3ms          326±3ms     1.00  transpiler_levels.TranspilerLevelBenchmarks.time_schedule_qv_14_x_14(0)
        133±0.4ms          132±2ms     1.00  queko.QUEKOTranspilerBench.time_transpile_bss(1, None)
       51.6±0.3ms       51.6±0.4ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(0, 'sabre', 'dense')
        153±0.7ms          153±2ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(2, 'sabre', 'dense')
          102±4ms        101±0.9ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(1, 'stochastic', 'dense')
       53.3±0.3ms       53.2±0.5ms     1.00  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(5, 'translator')
        197±0.5ms        197±0.7ms     1.00  queko.QUEKOTranspilerBench.time_transpile_bntf(1, 'sabre')
         78.3±2ms         78.2±1ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(1, 'sabre', 'sabre')
       83.6±0.3ms       83.5±0.7ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(1, 'sabre', 'sabre')
       58.4±0.3ms       58.3±0.3ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(1, 'sabre', 'noise_adaptive')
       1.48±0.01s       1.48±0.01s     1.00  transpiler_levels.TranspilerLevelBenchmarks.time_quantum_volume_transpile_50_x_20(0)
       1.44±0.01s       1.43±0.01s     1.00  queko.QUEKOTranspilerBench.time_transpile_bntf(3, 'sabre')
          158±4ms          158±1ms     1.00  queko.QUEKOTranspilerBench.time_transpile_bss(0, 'sabre')
        141±0.3ms        141±0.6ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(2, 'sabre', 'sabre')
          200±5ms          199±5ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(1, 'stochastic', 'noise_adaptive')
          177±3ms          177±4ms     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(0, 'stochastic', 'sabre')
          547±2ms          545±2ms     1.00  queko.QUEKOTranspilerBench.time_transpile_bss(2, 'sabre')
          230±2ms          229±2ms     1.00  queko.QUEKOTranspilerBench.time_transpile_bss(2, None)
         67.5±1ms       67.2±0.7ms     1.00  transpiler_levels.TranspilerLevelBenchmarks.time_transpile_from_large_qasm(0)
       1.01±0.01s       1.00±0.01s     1.00  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(3, 'stochastic', 'sabre')
          255±3ms          254±1ms     0.99  queko.QUEKOTranspilerBench.time_transpile_bntf(0, None)
        214±0.8ms          213±1ms     0.99  transpiler_levels.TranspilerLevelBenchmarks.time_transpile_from_large_qasm(2)
          898±3ms         893±10ms     0.99  queko.QUEKOTranspilerBench.time_transpile_bss(3, None)
       1.51±0.01s       1.50±0.01s     0.99  queko.QUEKOTranspilerBench.time_transpile_bss(0, None)
        130±0.3ms        129±0.3ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(2, 'sabre', 'noise_adaptive')
       56.2±0.8ms       55.8±0.4ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(1, 'sabre', 'dense')
          137±1ms          136±1ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(2, 'sabre', 'dense')
       73.1±0.3ms       72.6±0.2ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(2, 'sabre', 'sabre')
          268±3ms          266±2ms     0.99  transpiler_levels.TranspilerLevelBenchmarks.time_transpile_qv_14_x_14(0)
          121±3ms          120±1ms     0.99  queko.QUEKOTranspilerBench.time_transpile_bntf(0, 'sabre')
          234±3ms          232±1ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(3, 'sabre', 'sabre')
       80.5±0.4ms       79.8±0.2ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(1, 'sabre', 'dense')
          104±2ms          103±1ms     0.99  transpiler_levels.TranspilerLevelBenchmarks.time_transpile_from_large_qasm(3)
          485±3ms          480±2ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(3, 'sabre', 'noise_adaptive')
          658±2ms          652±1ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(3, 'sabre', 'sabre')
       70.9±0.3ms       70.2±0.4ms     0.99  qft.QftTranspileBench.time_ibmq_backend_transpile(14)
          518±4ms          513±1ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(3, 'sabre', 'noise_adaptive')
        237±0.3ms          234±2ms     0.99  transpiler_levels.TranspilerLevelBenchmarks.time_transpile_from_large_qasm_backend_with_prop(1)
       73.5±0.4ms       72.8±0.5ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(2, 'sabre', 'dense')
      2.78±0.06ms      2.75±0.03ms     0.99  qft.QftTranspileBench.time_ibmq_backend_transpile(1)
       83.9±0.6ms       83.1±0.1ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(1, 'sabre', 'noise_adaptive')
       1.71±0.01s       1.69±0.01s     0.99  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(27, 'translator')
          269±2ms          266±2ms     0.99  transpiler_levels.TranspilerLevelBenchmarks.time_schedule_qv_14_x_14(1)
       92.4±0.6ms         91.3±1ms     0.99  queko.QUEKOTranspilerBench.time_transpile_bigd(3, None)
       4.32±0.04s       4.27±0.08s     0.99  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(27, 'synthesis')
          382±6ms          377±2ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(3, 'stochastic', 'noise_adaptive')
          444±4ms          438±1ms     0.99  queko.QUEKOTranspilerBench.time_transpile_bntf(2, 'sabre')
       4.18±0.04s       4.13±0.03s     0.99  randomized_benchmarking.RandomizedBenchmarkingBenchmark.time_ibmq_backend_transpile_single_thread([0, 1])
       18.5±0.5ms         18.3±1ms     0.99  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(3, 'translator')
          304±2ms          300±3ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(3, 'stochastic', 'dense')
         980±20ms         967±10ms     0.99  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(20, 'translator')
          456±3ms        450±0.9ms     0.99  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(3, 'sabre', 'sabre')
          238±1ms          235±1ms     0.99  transpiler_levels.TranspilerLevelBenchmarks.time_transpile_qv_14_x_14(1)
       13.8±0.2ms      13.6±0.08ms     0.98  queko.QUEKOTranspilerBench.time_transpile_bigd(1, None)
       11.4±0.2ms       11.3±0.2ms     0.98  qft.QftTranspileBench.time_ibmq_backend_transpile(5)
          1.06±0s       1.04±0.01s     0.98  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(3, 'stochastic', 'dense')
       1.08±0.01s          1.06±0s     0.98  queko.QUEKOTranspilerBench.time_transpile_bss(3, 'sabre')
          611±6ms          601±8ms     0.98  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(3, 'sabre', 'dense')
       70.3±0.7ms       69.0±0.2ms     0.98  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(0, 'sabre', 'sabre')
         466±10ms          457±4ms     0.98  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(3, 'sabre', 'dense')
          231±2ms          226±5ms     0.98  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(0, 'stochastic', 'noise_adaptive')
        121±0.5ms        119±0.4ms     0.98  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(2, 'sabre', 'noise_adaptive')
          400±2ms          393±1ms     0.98  transpiler_levels.TranspilerLevelBenchmarks.time_transpile_qv_14_x_14(2)
        123±0.6ms        121±0.4ms     0.98  queko.QUEKOTranspilerBench.time_transpile_bntf(2, None)
         991±10ms          972±6ms     0.98  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(3, 'stochastic', 'sabre')
          998±6ms          979±4ms     0.98  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(3, 'stochastic', 'noise_adaptive')
         62.4±1ms       61.1±0.1ms     0.98  qft.QftTranspileBench.time_ibmq_backend_transpile(13)
         52.0±1ms       50.9±0.4ms     0.98  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(0, 'sabre', 'sabre')
          611±5ms          598±3ms     0.98  queko.QUEKOTranspilerBench.time_transpile_bntf(3, None)
       75.6±0.7ms       73.9±0.3ms     0.98  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(0, 'sabre', 'noise_adaptive')
          286±5ms          279±2ms     0.98  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(2, 'stochastic', 'noise_adaptive')
          185±3ms        180±0.8ms     0.97  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(1, 'stochastic', 'sabre')
          277±7ms          270±1ms     0.97  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(2, 'stochastic', 'dense')
          245±1ms          239±6ms     0.97  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(1, 'stochastic', 'dense')
         17.1±1ms       16.6±0.8ms     0.97  queko.QUEKOTranspilerBench.time_transpile_bigd(1, 'sabre')
          108±3ms        104±0.5ms     0.97  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(1, 'stochastic', 'sabre')
          164±4ms          158±2ms     0.97  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(0, 'stochastic', 'dense')
         72.2±2ms       69.7±0.5ms     0.97  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(0, 'sabre', 'dense')
          102±1ms         98.5±1ms     0.96  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(0, 'stochastic', 'noise_adaptive')
          304±2ms          293±2ms     0.96  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(2, 'stochastic', 'sabre')
          231±4ms          222±2ms     0.96  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(0, 'stochastic', 'dense')
       24.9±0.4ms       23.9±0.2ms     0.96  queko.QUEKOTranspilerBench.time_transpile_bigd(2, 'sabre')
          248±2ms          235±1ms     0.95  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_180(1, 'stochastic', 'noise_adaptive')
       8.52±0.2ms      8.05±0.08ms     0.94  qft.QftTranspileBench.time_ibmq_backend_transpile(3)
      4.37±0.07ms       4.12±0.1ms     0.94  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(1, 'synthesis')
       2.67±0.1ms      2.51±0.02ms     0.94  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(1, 'translator')
          105±3ms         97.0±2ms     0.93  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_cnt3_5_179(0, 'stochastic', 'dense')
          188±3ms          173±1ms     0.92  transpiler_qualitative.TranspilerQualitativeBench.time_transpile_time_qft_16(1, 'stochastic', 'dense')
         63.1±5ms         57.6±8ms     0.91  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(5, 'synthesis')

Benchmarks that have got worse:

       before           after         ratio
     [734e0618]       [dcc9a9dc]
     <cache-dag-sort-key~1>       <cache-dag-sort-key>
+        14.8±2ms         22.8±3ms     1.54  quantum_volume.QuantumVolumeBenchmark.time_ibmq_backend_transpile(3, 'synthesis')

SOME BENCHMARKS HAVE CHANGED SIGNIFICANTLY.
PERFORMANCE DECREASED.

@mtreinish
Copy link
Member Author

As for a place where this makes a much bigger impact is running:

from qiskit.providers.fake_provider import FakeTorontoV2
from qiskit import transpile, QuantumCircuit

import time

backend = FakeTorontoV2()
start = time.perf_counter()
res = transpile(QuantumCircuit.from_qasm_file("bwt_n21.qasm"), backend, optimization_level=0, routing_method="sabre", layout_method="sabre")
stop = time.perf_counter()
print(stop - start)

with bwt_n21.qasm from QASMbench: https://github.com/pnnl/QASMBench/tree/master/medium/bwt_n21

On main this takes ~43.695 sec and with this PR it took ~31.078 sec.

@mtreinish mtreinish added this pull request to the merge queue Sep 6, 2023
Merged via the queue into Qiskit:main with commit 838bb38 Sep 6, 2023
14 checks passed
@mtreinish mtreinish deleted the min-qubits-basis-translator branch September 6, 2023 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog mod: transpiler Issues and PRs related to Transpiler performance
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants