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

Migrate asv benchmark suite from metapackage #10546

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e4d2e8f
Add asv benchmarks (Qiskit/qiskit-metapackage#30)
mtreinish Mar 1, 2019
6bc648e
Add depth tracking to random hex circuit benchmarks (Qiskit/qiskit-me…
mtreinish Apr 22, 2019
045a6f4
Remove randomness from random_hex_circuit_benchmark (Qiskit/qiskit-me…
mtreinish Apr 23, 2019
692006c
Update Copyrights (Qiskit/qiskit-metapackage#215)
nonhermitian Apr 30, 2019
fd5aa1b
Bump released package versions and set meta package version to 0.9.0 …
mtreinish May 3, 2019
7bec877
Update all benchmarks to work on Terra Master (Qiskit/qiskit-metapack…
ajavadia May 24, 2019
069d308
Avoid using FakeMelbourne from qiskit/test (Qiskit/qiskit-metapackage…
mtreinish May 24, 2019
7610733
Add first benchmarks for circuit construction and composition. (Qiski…
kdk Jun 21, 2019
68fb447
Random circuit hex less random (Qiskit/qiskit-metapackage#344)
kdk Jun 24, 2019
854b7a7
random_circuit_hex benchmark backwards compatility (Qiskit/qiskit-met…
kdk Jul 2, 2019
3bc9cd0
Added benchmarks for isometries (Qiskit/qiskit-metapackage#315)
rabaniten Jul 2, 2019
a2e9c97
Handle missing qi modules (Qiskit/qiskit-metapackage#368)
mtreinish Jul 12, 2019
2fe86fa
Randomize Benchmarking Performace Benchmark (Qiskit/qiskit-metapackag…
ShellyGarion Jul 21, 2019
052b340
Update state tomography benchmarks to use ignis (Qiskit/qiskit-metapa…
mtreinish Aug 13, 2019
d12dcb3
Add single-threaded versions of RB benchmarks. (Qiskit/qiskit-metapac…
kdk Aug 18, 2019
6ba27a8
Add timing benchmark for `import qiskit`. (Qiskit/qiskit-metapackage#…
kdk Aug 20, 2019
c2a01a0
Bump the ignis version in tomography and RB benchmarks (Qiskit/qiskit…
mtreinish Aug 26, 2019
50dcb25
Add a test to track mapper's performance on CNOT count (Qiskit/qiskit…
itoko Aug 27, 2019
83b178f
Add benchmarks for different transpiler levels (Qiskit/qiskit-metapac…
mtreinish Oct 2, 2019
826299b
Add benchmarks for converter functions (Qiskit/qiskit-metapackage#628)
mtreinish Oct 15, 2019
ceea743
Assemble circuits and transpiler peakmem benchmarks (Qiskit/qiskit-me…
kdk Oct 25, 2019
af652de
Add benchmarks for mapping passes (Qiskit/qiskit-metapackage#699)
mtreinish Nov 25, 2019
33548ba
Add benchmark for non-mapping passes (Qiskit/qiskit-metapackage#697)
mtreinish Nov 25, 2019
8ff4a42
Reorganize passes benchmarks (Qiskit/qiskit-metapackage#714)
mtreinish Dec 4, 2019
e573791
Reduce number of parameters on pass benchmarks (Qiskit/qiskit-metapac…
mtreinish Mar 3, 2020
db2f1c8
Add QuantumCircuit.copy() benchmark. (Qiskit/qiskit-metapackage#838)
mtreinish Mar 4, 2020
d3a36d4
Disable LookaheadSwap mapping benchmarks due to timeout. (Qiskit/qisk…
kdk Mar 13, 2020
0500a27
Add ripple adder construction and transpilation benchmarks. (Qiskit/q…
kdk Mar 13, 2020
6f1e9d4
Add disassemble benchmarks and more permutations to assemble (Qiskit/…
mtreinish Mar 17, 2020
f0118d5
Add Qiskit Pulse Benchmarks (Qiskit/qiskit-metapackage#848)
SooluThomas Apr 10, 2020
35e291c
Add benchmarks for bind_parameters (Qiskit/qiskit-metapackage#896)
mtreinish Apr 25, 2020
287135c
Fix typo in files under docs and test (Qiskit/qiskit-metapackage#751)
kiszk Apr 30, 2020
7df6636
Bump Meta (Qiskit/qiskit-metapackage#908)
qiskit-bot May 1, 2020
c7b132b
Bump Meta (Qiskit/qiskit-metapackage#998)
qiskit-bot Aug 10, 2020
3a559a1
Remove peakmem benchmarks from the benchmark suite (Qiskit/qiskit-met…
mtreinish Oct 21, 2020
24480ba
Qualitative transpiler benchmarks using different layouts, routing me…
adekusar-drl Oct 28, 2020
e7ebc48
Fix random_circuit_hex benchmarks (Qiskit/qiskit-metapackage#1129)
mtreinish Dec 7, 2020
881ae2e
Fix the Pulse schedule construction benchmarks (Qiskit/qiskit-metapac…
mtreinish Jan 29, 2021
4f83fb5
Add QUEKO benchmarks (Qiskit/qiskit-metapackage#1154)
mtreinish Feb 4, 2021
2aee971
Fix pulse schedule benchmarks. (Qiskit/qiskit-metapackage#1155)
taalexander Feb 8, 2021
b0d8145
Update QuantumVolume benchmark (Qiskit/qiskit-metapackage#1185)
mtreinish Mar 9, 2021
f18110f
Remove benchmarks that measure BasicAer as transpile target (Qiskit/q…
mtreinish Mar 9, 2021
87c1530
Add quantum_info benchmarks - Clifford & Cnot-Dihedral (Qiskit/qiskit…
eliarbel Jul 7, 2021
1d0815f
Update in Randomized_Benchmarking. Fix for Bug raised in issue Qiskit…
jessica-angel7 Sep 22, 2021
ee0fe3f
Actually bump ignis version in benchmarks (Qiskit/qiskit-metapackage#…
mtreinish Sep 22, 2021
404e3c7
Adding Pauli benchamrks (Qiskit/qiskit-metapackage#1317)
eliarbel Oct 8, 2021
8229c87
Drop track_* passes benchmarks and fix cxdirection benchmark (Qiskit/…
mtreinish Oct 14, 2021
543f5ea
Add benchmarks for missing passes (Qiskit/qiskit-metapackage#1346)
mtreinish Oct 18, 2021
a60e714
Add a benchmark of `SparsePauliOp.__add__` (Qiskit/qiskit-metapackage…
t-imamichi Oct 20, 2021
3419f98
Add seed to all transpiler benchmarks (Qiskit/qiskit-metapackage#1405)
jakelishman Jan 25, 2022
f24bbe8
Add benchmarks for circuit scheduling (Qiskit/qiskit-metapackage#1421)
itoko Feb 25, 2022
31a1882
Add overall transpilation time bench with scheduling (Qiskit/qiskit-m…
itoko Mar 11, 2022
61eaf36
Use Terra's FakeBackend in benchmarks (Qiskit/qiskit-metapackage#1480)
jakelishman Apr 21, 2022
85929a9
Replace ignis benchmarks with qiskit-experiments (Qiskit/qiskit-metap…
chriseclectic May 5, 2022
79ff6ec
Update pulse benchmarking suite (Qiskit/qiskit-metapackage#1607)
nkanazawa1989 Sep 26, 2022
8751800
Reduce number of permutations for assembler benchmarks (Qiskit/qiskit…
mtreinish Oct 26, 2022
b97e7df
Add benchmarks for Sabre on large QFT and QV circuits (Qiskit/qiskit-…
jakelishman Oct 28, 2022
f97b7b1
Upgrade Pylint to 2.16 (Qiskit/qiskit-metapackage#1672)
Eric-Arellano Feb 27, 2023
e781aff
Merge benchmark suite from Qiskit/qiskit-metapackage
jakelishman Aug 1, 2023
6721850
Run black on benchmark suite
jakelishman Aug 1, 2023
2530ca8
Fix Terra's lint complaints
jakelishman Aug 1, 2023
67a1412
Add Terra-specific ASV configuration
jakelishman Aug 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ celerybeat-schedule
.env

# virtualenv
.asv/
.venv
venv/
ENV/
Expand Down
25 changes: 25 additions & 0 deletions asv.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"version": 1,
"project": "qiskit",
"project_url": "https://qiskit.org",
"repo": ".",
"install_command": [
"in-dir={env_dir} python -mpip install {wheel_file}[all] python-constraint qiskit-experiments==0.3.0"
],
"uninstall_command": [
"return-code=any python -mpip uninstall -y {project}"
],
"build_command": [
"pip install -U setuptools-rust",
"python setup.py build_rust --release",
"PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}"
],
"branches": ["main"],
"dvcs": "git",
"environment_type": "virtualenv",
"show_commit_url": "http://github.com/Qiskit/qiskit-terra/commit/",
"pythons": ["3.8", "3.9", "3.10", "3.11"],
"benchmark_dir": "test/benchmarks",
"env_dir": ".asv/env",
"results_dir": ".asv/results"
}
11 changes: 11 additions & 0 deletions test/benchmarks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
49 changes: 49 additions & 0 deletions test/benchmarks/assembler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=no-member,invalid-name,missing-docstring,no-name-in-module
# pylint: disable=attribute-defined-outside-init,unsubscriptable-object

from qiskit.compiler import assemble
from qiskit.assembler import disassemble

from .utils import random_circuit


class AssemblerBenchmarks:
params = ([8], [4096], [1, 100])
param_names = ["n_qubits", "depth", "number of circuits"]
timeout = 600
version = 2

def setup(self, n_qubits, depth, number_of_circuits):
seed = 42
self.circuit = random_circuit(n_qubits, depth, measure=True, conditional=True, seed=seed)
self.circuits = [self.circuit] * number_of_circuits

def time_assemble_circuit(self, _, __, ___):
assemble(self.circuits)


class DisassemblerBenchmarks:
params = ([8], [4096], [1, 100])
param_names = ["n_qubits", "depth", "number of circuits"]
timeout = 600

def setup(self, n_qubits, depth, number_of_circuits):
seed = 424242
self.circuit = random_circuit(n_qubits, depth, measure=True, conditional=True, seed=seed)
self.circuits = [self.circuit] * number_of_circuits
self.qobj = assemble(self.circuits)

def time_disassemble_circuit(self, _, __, ___):
disassemble(self.qobj)
96 changes: 96 additions & 0 deletions test/benchmarks/circuit_construction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=missing-docstring,invalid-name,no-member
# pylint: disable=attribute-defined-outside-init

import itertools

from qiskit import QuantumRegister, QuantumCircuit
from qiskit.circuit import Parameter


def build_circuit(width, gates):
qr = QuantumRegister(width)
qc = QuantumCircuit(qr)

while len(qc) < gates:
for k in range(width):
qc.h(qr[k])
for k in range(width - 1):
qc.cx(qr[k], qr[k + 1])

return qc


class CircuitConstructionBench:
params = ([1, 2, 5, 8, 14, 20], [8, 128, 2048, 8192, 32768, 131072])
param_names = ["width", "gates"]
timeout = 600

def setup(self, width, gates):
self.empty_circuit = build_circuit(width, 0)
self.sample_circuit = build_circuit(width, gates)

def time_circuit_construction(self, width, gates):
build_circuit(width, gates)

def time_circuit_extend(self, _, __):
self.empty_circuit.extend(self.sample_circuit)

def time_circuit_copy(self, _, __):
self.sample_circuit.copy()


def build_parameterized_circuit(width, gates, param_count):
params = [Parameter("param-%s" % x) for x in range(param_count)]
param_iter = itertools.cycle(params)

qr = QuantumRegister(width)
qc = QuantumCircuit(qr)

while len(qc) < gates:
for k in range(width):
param = next(param_iter)
qc.u2(0, param, qr[k])
for k in range(width - 1):
param = next(param_iter)
qc.crx(param, qr[k], qr[k + 1])

return qc, params


class ParameterizedCircuitConstructionBench:
params = ([20], [8, 128, 2048, 8192, 32768, 131072], [8, 128, 2048, 8192, 32768, 131072])
param_names = ["width", "gates", "number of params"]
timeout = 600

def setup(self, _, gates, params):
if params > gates:
raise NotImplementedError

def time_build_parameterized_circuit(self, width, gates, params):
build_parameterized_circuit(width, gates, params)


class ParameterizedCircuitBindBench:
params = ([20], [8, 128, 2048, 8192, 32768, 131072], [8, 128, 2048, 8192, 32768, 131072])
param_names = ["width", "gates", "number of params"]
timeout = 600

def setup(self, width, gates, params):
if params > gates:
raise NotImplementedError
self.circuit, self.params = build_parameterized_circuit(width, gates, params)

def time_bind_params(self, _, __, ___):
self.circuit.bind_parameters({x: 3.14 for x in self.params})
53 changes: 53 additions & 0 deletions test/benchmarks/converters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=no-member,invalid-name,missing-docstring,no-name-in-module
# pylint: disable=attribute-defined-outside-init,unsubscriptable-object

from qiskit import converters
from qiskit import qasm

from .utils import random_circuit


class ConverterBenchmarks:
params = ([1, 2, 5, 8, 14, 20, 32, 53], [8, 128, 2048, 8192])
param_names = ["n_qubits", "depth"]
timeout = 600

def setup(self, n_qubits, depth):
seed = 42
# NOTE: Remove the benchmarks larger than 20x2048 and 14x8192, this is
# a tradeoff for speed of benchmarking, creating circuits this size
# takes more time than is worth it for benchmarks that take a couple
# seconds
if n_qubits >= 20:
if depth >= 2048:
raise NotImplementedError
elif n_qubits == 14:
if depth > 2048:
raise NotImplementedError
self.qc = random_circuit(n_qubits, depth, measure=True, conditional=True, seed=seed)
self.dag = converters.circuit_to_dag(self.qc)
self.qasm = qasm.Qasm(data=self.qc.qasm()).parse()

def time_circuit_to_dag(self, *_):
converters.circuit_to_dag(self.qc)

def time_circuit_to_instruction(self, *_):
converters.circuit_to_instruction(self.qc)

def time_dag_to_circuit(self, *_):
converters.dag_to_circuit(self.dag)

def time_ast_to_circuit(self, *_):
converters.ast_to_dag(self.qasm)
24 changes: 24 additions & 0 deletions test/benchmarks/import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=no-member,invalid-name,missing-docstring,no-name-in-module
# pylint: disable=attribute-defined-outside-init,unsubscriptable-object

"""Module for estimating import times."""

from sys import executable
from subprocess import call


class QiskitImport:
def time_qiskit_import(self):
call((executable, "-c", "import qiskit"))
66 changes: 66 additions & 0 deletions test/benchmarks/isometry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=missing-docstring,invalid-name,no-member
# pylint: disable=attribute-defined-outside-init
# pylint: disable=unused-argument

from qiskit import QuantumRegister, QuantumCircuit
from qiskit.compiler import transpile
from qiskit.quantum_info.random import random_unitary


class IsometryTranspileBench:
params = ([0, 1, 2, 3], [3, 4, 5, 6])
param_names = ["number of input qubits", "number of output qubits"]

def setup(self, m, n):
q = QuantumRegister(n)
qc = QuantumCircuit(q)
if not hasattr(qc, "iso"):
raise NotImplementedError
iso = random_unitary(2**n, seed=0).data[:, 0 : 2**m]
if len(iso.shape) == 1:
iso = iso.reshape((len(iso), 1))
qc.iso(iso, q[:m], q[m:])
self.circuit = qc

def track_cnot_counts_after_mapping_to_ibmq_16_melbourne(self, *unused):
coupling = [
[1, 0],
[1, 2],
[2, 3],
[4, 3],
[4, 10],
[5, 4],
[5, 6],
[5, 9],
[6, 8],
[7, 8],
[9, 8],
[9, 10],
[11, 3],
[11, 10],
[11, 12],
[12, 2],
[13, 1],
[13, 12],
]
circuit = transpile(
self.circuit,
basis_gates=["u1", "u3", "u2", "cx"],
coupling_map=coupling,
seed_transpiler=0,
)
counts = circuit.count_ops()
cnot_count = counts.get("cx", 0)
return cnot_count
Loading