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

Allow users to specify cut decompositions in terms of a native gate set #495

Closed
wants to merge 5 commits into from

Conversation

caleb-johnson
Copy link
Collaborator

@caleb-johnson caleb-johnson commented Feb 29, 2024

Fixes #492

This PR introduces an EagleEquivalenceLibrary and HeronEquivalenceLibrary for translating all the gates we use in cutting decompositions to the corresponding native gate set. This allows users to transpile their "Cut Circuit" one time, and when they generate_cutting_experiments all of their subexperiments will already be translated to the native gate set for the processor type they specified. If they don't specify, the "standard" gate set will be used. Heron single qubit native gates are the same as Eagle, so we get that equivalence library for free.

TODO:

  • Decide how to allow users to specify a native gate set. Probably a string from {"standard", "eagle", "heron"}, which defaults to "standard".
  • Clean up logic in qpd around parsing the target device and getting the right equivalence library
  • Tests for the library and tests for the new option in generate_cutting_experiments
  • Release note

@caleb-johnson caleb-johnson changed the title Add an equivalence library for Eagle devices Add an equivalence library for Eagle and Heron devices Feb 29, 2024
q = QuantumRegister(1, "q")
def_sxdg = QuantumCircuit(q)
for inst in [
RZGate(np.pi / 2),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The BasisTranslator returned this. Fairly certain we can collapse to one pi rotation on either side of the sxgate

@caleb-johnson caleb-johnson changed the title Add an equivalence library for Eagle and Heron devices Allow users to specify cut decompositions in terms of a native gate set Feb 29, 2024
PhaseGate,
)

_eagle_sel = HeronEquivalenceLibrary = EagleEquivalenceLibrary = EquivalenceLibrary()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should document that these libraries are for single-qubit operations only. Should also document that it is assumed that each input will produce, at most, one equivalence.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe the names of the classes should include SingleQubitEagle...

@@ -1143,7 +1144,13 @@ def _decompose_qpd_instructions(
for data in inst.operation.definition.data:
# Can ignore clbits here, as QPDGates don't use clbits directly
assert data.clbits == ()
tmp_data.append(CircuitInstruction(data.operation, qubits=[qubits[0]]))
try:
equiv = EagleEquivalenceLibrary.get_entry(data.operation)[0]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The equivalence libraries in CKT are guaranteed to only have, at most, a single equivalence defined for now.

q = QuantumRegister(1, "q")
def_ry = QuantumCircuit(q)
theta = Parameter("theta")
for inst in [SXGate(), RZGate(theta + np.pi), SXGate(), RZGate(3 * np.pi)]:
Copy link
Collaborator Author

@caleb-johnson caleb-johnson Feb 29, 2024

Choose a reason for hiding this comment

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

Another strange one from BasisTranslator I wasn't sure about. Can the 3*pi be simplified to just pi?

tmp_data.append(CircuitInstruction(data.operation, qubits=[qubits[0]]))
else:
# CKT equivalence libraries only define one mapping per input
for d in equiv[0].data:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should assert equiv is length-1 here

@garrison garrison added the cutting QPD-based circuit cutting code label Mar 4, 2024

_eagle_sel = HeronEquivalenceLibrary = EagleEquivalenceLibrary = EquivalenceLibrary()

########## Single-qubit Eagle native gate set: x, sx, rz, i ##########
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's better to delete the native gates from the equivalence library. Qiskit equivalence libraries don't return the gate itself, only alternate equivalences.

@coveralls
Copy link

coveralls commented Mar 27, 2024

Pull Request Test Coverage Report for Build 8474101661

Details

  • 91 of 91 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 93.824%

Totals Coverage Status
Change from base Build 8440700859: 0.2%
Covered Lines: 2461
Relevant Lines: 2623

💛 - Coveralls

@caleb-johnson
Copy link
Collaborator Author

Closing in favor of #517

@caleb-johnson caleb-johnson deleted the decomp-to-basis-set branch March 29, 2024 00:53
@caleb-johnson caleb-johnson restored the decomp-to-basis-set branch March 30, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cutting QPD-based circuit cutting code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow for translation into a hardware-native gate set during creation of subexperiments
3 participants