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

Re-organize files so QASM circuits live in a different directory than… #128

Merged
merged 19 commits into from
Dec 17, 2024

Conversation

jordandsullivan
Copy link
Collaborator

… the scripts that generate them

@jordandsullivan jordandsullivan linked an issue Dec 7, 2024 that may be closed by this pull request
@jordandsullivan jordandsullivan marked this pull request as ready for review December 10, 2024 03:31
@jordandsullivan
Copy link
Collaborator Author

jordandsullivan commented Dec 10, 2024

You can ignore the failed checks for now -- I'm doing some debugging on GitHub actions.

I went one direction with this @natestemen , but I'm open to other options, and Will may have a different intention in his original issue.

@natestemen natestemen mentioned this pull request Dec 11, 2024
@natestemen
Copy link
Member

natestemen commented Dec 11, 2024

@jordandsullivan there are a lot of seemingly unrelated changes here. I think commits from #124 got pulled into this PR. Can we separate those out before a review just to ensure everything is safe?

@jordandsullivan
Copy link
Collaborator Author

@natestemen Merged the delete old files branch. lmk if you have any more questions about changes here

@natestemen
Copy link
Member

You'll need to merge main into this branch for that to be reflected here. Or use any of the other myriad of git techniques to apply changes here.

Copy link
Collaborator Author

@jordandsullivan jordandsullivan left a comment

Choose a reason for hiding this comment

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

Adding explanatory comments for changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is just converting the old notebook version to a script

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updating imports because of moved modules and new script (vs. notebook) for generating the qasm code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Converted this to a script (see below).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updating import references for moved files. I could see an argument that it doesn't make sense to have the Qiskit and Cirq files inside the benchmarks/scripts module though

Copy link
Member

@natestemen natestemen left a comment

Choose a reason for hiding this comment

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

I think my biggest question regarding this PR is should benchmarks live inside ucc? It seems natural for someone to run something like this.

import ucc

circuit = ucc.benchmarks.xyz_circuit(...)
ucc.compile(circuit)

I also think it would be great to have a script that is able to be run to generate the exact qasm files that live in qasm_circuits. Right now we have generate_qasm.py but it's not clear what exactly it outputs, and it does not write to the qasm_circuits directory.

benchmarks/qasm_circuits/__init__.py Outdated Show resolved Hide resolved
benchmarks/results/gates_2024-12-12.csv Outdated Show resolved Hide resolved
benchmarks/scripts/generate_qasm.py Show resolved Hide resolved
@jordandsullivan
Copy link
Collaborator Author

I think my biggest question regarding this PR is should benchmarks live inside ucc? It seems natural for someone to run something like this.

import ucc

circuit = ucc.benchmarks.xyz_circuit(...)
ucc.compile(circuit)

I also think it would be great to have a script that is able to be run to generate the exact qasm files that live in qasm_circuits. Right now we have generate_qasm.py but it's not clear what exactly it outputs, and it does not write to the qasm_circuits directory.

I see, I think I can buy that. Having a way to import benchmarks in a runnable manner. Would you expect to need to specify which representation to load them in? I.e. cirq, Qiskit, etc?

@natestemen
Copy link
Member

Specifying the frontend definitely makes sense. It's what we do in Mitiq. E.g.:

def generate_qpe_circuit(
    evalue_reg: int,
    input_gate: cirq.Gate = cirq.T,
    return_type: Optional[str] = None, # <- qiskit, cirq, pyquil, etc
) -> QPROGRAM: ...

@jordandsullivan
Copy link
Collaborator Author

jordandsullivan commented Dec 16, 2024

Specifying the frontend definitely makes sense. It's what we do in Mitiq. E.g.:

def generate_qpe_circuit(
    evalue_reg: int,
    input_gate: cirq.Gate = cirq.T,
    return_type: Optional[str] = None, # <- qiskit, cirq, pyquil, etc
) -> QPROGRAM: ...

I'm fine with this, but I think it's beyond the scope of this issue. The ideas as I understand it is to separate the QASM files from the script that generates them. I honestly don't know what makes the most sense here.
If we want to move the scripts to ucc/ucc/scripts and keep the benchmarks as they are at ucc/benchmarks, I suppose that could work.

We could also move the entire benchmarks module into ucc/ucc/benchmarks to make them importable as you suggest above. It will be a bit of a pain to change all of the references to benchmarks in the benchmarks/scripts repo, and again I'm not sure it is in scope for this issue.

Copy link
Member

@natestemen natestemen left a comment

Choose a reason for hiding this comment

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

New comments

Just to check my understanding here, the main change in this PR is moving code from benchmarks/generate_qasm.ipynb to benchmarks/scripts/generate_qasm.py.

Re-reading #45, my question is, does benchmarks/scripts/generate_qasm.py generate everything under benchmarks/circuits?

Unfortunately there isn't a lot of detail in the original issue to go on so it's hard to know exactly what the original problem is, but I'm pretty sure this change satisfies it. Maybe @willzeng should also take a look at this PR as issue author.

Regarding moving code into ucc/

I'm fine with [specifying the frontend], but I think it's beyond the scope of this issue.

Agreed.

move the entire benchmarks module into ucc/benchmarks

This still makes sense to me, since it is likely code we want to support and probably(?) add tests for.

@@ -0,0 +1,55 @@
#!/usr/bin/env python
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this file needs to be an executable?

@jordandsullivan
Copy link
Collaborator Author

Just to check my understanding here, the main change in this PR is moving code from benchmarks/generate_qasm.ipynb to benchmarks/scripts/generate_qasm.py.

Yes that is correct.

The main question is, was this issue intended to move the benchmarks into a module within ucc, i.e. accessible by calling ucc.benchmarks import qaoa etc.?

Or was the intention to just separate the QASM files from the scripts that generate them into a different directory, as I have done in this PR?

@jordandsullivan jordandsullivan merged commit acb020a into main Dec 17, 2024
@jordandsullivan jordandsullivan deleted the 45-separate-qasm-benchmark-files branch December 17, 2024 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Separate qasm benchmark files from code to generate them
3 participants