Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Integrating MQT bench into red-queen #45

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

archanaravindar
Copy link

Add MQT benchmarks to Red Queen framework: This is part of QAMP Fall 2022 project. This pull request is meant to be a preliminary sanity check of the structure of the files and the method.

Add MQT benchmarks to Red Queen framework
@CLAassistant
Copy link

CLAassistant commented Nov 9, 2022

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ archanaravindar
❌ Archana R


Archana R seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

I left a few inline comments, but the biggest question for me is how you want to call into mqt. Right now it looks like you're copying the benchmark code from mqt in a few places and calling one to generate the bencmark circuit. I think it would be easier if we just called mqt directly and add mqt.bench to the requirements list, the the actual benchmark test code is fairly simple and just about building up the parameterizations in pytest and pass the constructors to mqt to get the expected circuit.

@@ -0,0 +1,25 @@
OPENQASM 2.0;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the qasm files anymore if we're going straight from mqt -> QuantumCircuit?

Comment on lines 21 to 22
qasm_path = "/home/archana/qamp-fall-22/red-queen/red_queen/applications/games/qasm"
def set_qasm_output_path(new_path: str = "/home/archana/qamp-fall-22/red-queen/red_queen/applications/games/qasm"):
Copy link
Member

Choose a reason for hiding this comment

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

We should be using relative paths instead of an absolute path with your local home directory. Otherwise when I run this I'll get a filesystem error because this path doesn't exist.

Comment on lines 8 to 23
def create_circuit(num_qubits: int):
"""Returns a quantum circuit implementing Quantum Amplitude Estimation.
Keyword arguments:
num_qubits -- number of qubits of the returned quantum circuit
"""

ae = AmplitudeEstimation(
num_eval_qubits=num_qubits - 1, # -1 because of the to be estimated qubit
)
problem = utils.get_estimation_problem()

qc = ae.construct_circuit(problem)
qc.name = "ae"
qc.measure_all()

return qc
Copy link
Member

Choose a reason for hiding this comment

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

What ends up using this? I didn't see any callers elsewhere in the PR.

@pytest.mark.parametrize("optimization_level", [0, 1, 2, 3])
@pytest.mark.parametrize("backend", backends)
@pytest.mark.parametrize("method", ["normal"])

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

@pytest.mark.qiskit
@pytest.mark.parametrize("optimization_level", [0, 1, 2, 3])
@pytest.mark.parametrize("backend", backends)
@pytest.mark.parametrize("method", ["normal"])
Copy link
Member

Choose a reason for hiding this comment

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

I would just remove this parameter since there isn't a mid circuit measurement variant of an amplitude estimation circuit.

Comment on lines 41 to 43
if method == "normal":
benchmark.name = "Amplitude Estimation"
circ = build_ae_circuit(8,False)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of doing this couldn't you just call circ = mqt.bench.benchmarks.ae.create_circuit(num_qubits)? It also looks like there is a helper function get_one_benchmark() which can be used to generate the circuits from a single caller: https://github.com/cda-tum/MQTBench/blob/a6cb6f18eb08255eb44c1527ae4ee4d581a451ad/mqt/bench/benchmark_generator.py#L476


def bench_qiskit_ae(benchmark, optimization_level, backend, method):
shots = 65536
expected_counts = {"8": shots}
Copy link
Member

Choose a reason for hiding this comment

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

Is this correct? This isn't a valid counts string, it'd be "1000" to show 8. But also I didn't think the number of qubits would be the expected answer 100% of the time for an amplitude estimation problem.

@pytest.mark.parametrize("optimization_level", [0, 1, 2, 3])
@pytest.mark.parametrize("backend", backends)
@pytest.mark.parametrize("method", ["normal"])

Copy link
Member

Choose a reason for hiding this comment

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

It'd be really cool if we could add a parameterized sweep on the number of qubits to the benchmark here. Something like:

@pytest.mark.parameterize("num_qubits", np.logspace(0, 2, dtype=int))

and the build an amplitude estimation circuit with the variable size.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants