Closed sirgeorgesawcon closed 5 months ago
Thank you for the report.
It appears you are using the branch of PR #471 -- is that correct?
Ultimately, I expect we will expose only find_cuts
as a public API.
Yes, I am using that. In one of my earlier reported issues, I mentioned another problem with the same code as well. Now as I'm implementing a QAOA, I'm getting this error.
This was the previous error.
I updated my code to show that detail.
On Thu, Mar 21, 2024 at 11:46 PM Ibrahim Shehzad @.***> wrote:
Trying to reproduce this, I'm assuming networkx is imported as nx? Also, where is Maxcut imported from?
— Reply to this email directly, view it on GitHub https://github.com/Qiskit-Extensions/circuit-knitting-toolbox/issues/508#issuecomment-2012719354, or unsubscribe https://github.com/notifications/unsubscribe-auth/APBYKUSA6M7B3UC2BT5YNODYZL6GVAVCNFSM6AAAAABFA5EAPWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJSG4YTSMZVGQ . You are receiving this because you authored the thread.Message ID: @.*** com>
Hi, it does work, but in the code of DeviceConstraint
, we can only set the qubits_per_qpu
, is the functionality where we can also provide number of qpu's as an argument deprecated?
class DeviceConstraints:
"""Specify the constraints (qubits per QPU) that must be respected."""
qubits_per_qpu: int
def __post_init__(self):
"""Post-init method for data class."""
if self.qubits_per_qpu < 1:
raise ValueError("qubits_per_QPU must be a positive definite integer.")
def get_qpu_width(self) -> int:
"""Return the number of qubits supported on each individual QPU."""
return self.qubits_per_qpu
That was helpful, since we can get even less overhead sampling if we can divide it into three different subcircuits!
Thank you for your comment.
is the functionality where we can also provide number of qpu's as an argument deprecated?
Yes, in the way the code is desgined, that functionality is only relevant for LOCC, which is why it was taken out. We intend to clarify this further in the documentation but qubits_per_qpu
is actually equivalent to "qubits per subcircuit" and so that can be used to assert that the input circuit be divided up into a given number of subcircuits.
Follow up: this attribute has now been renamed to qubits_per_subcircuit
to avoid confusion.
Thanks @Ibrahim-Shehzad , that helped clear a lot of confusion.
Steps to Recreate
Do the necessary Imports
Create an QAOA ansatz with the help of a simple max cut instance:
Made Ising Hamiltonian
Make a QAOA Ansatz out of it
Transpile it and then look for best cuts
The top two results from these are :
---------- 6 Qubits per QPU, 3 QPUs ---------- Gamma = 64.0 , Min_gamma_reached = True [OneWireCutIdentifier(cut_action='CutLeftWire', wire_cut_location=WireCutLocation(instruction_id=22, gate_name='cx', input=1)), OneWireCutIdentifier(cut_action='CutLeftWire', wire_cut_location=WireCutLocation(instruction_id=30, gate_name='cx', input=1)), OneWireCutIdentifier(cut_action='CutRightWire', wire_cut_location=WireCutLocation(instruction_id=47, gate_name='cx', input=2))] Subcircuits: AAABAABBBAB
and
---------- 5 Qubits per QPU, 3 QPUs ---------- Gamma = 144.0 , Min_gamma_reached = True [CutIdentifier(cut_action='CutTwoQubitGate', gate_cut_location=GateCutLocation(instruction_id=10, gate_name='cx')), CutIdentifier(cut_action='CutTwoQubitGate', gate_cut_location=GateCutLocation(instruction_id=12, gate_name='cx')), OneWireCutIdentifier(cut_action='CutLeftWire', wire_cut_location=WireCutLocation(instruction_id=30, gate_name='cx', input=1)), OneWireCutIdentifier(cut_action='CutRightWire', wire_cut_location=WireCutLocation(instruction_id=47, gate_name='cx', input=2))] Subcircuits: AABAABBBAB
But then I make use of the following code:
It gives the following Error:
IndexError: tuple index out of range
It works fine for (6,3) case, but always shows error on the (5,3) case. Given the cut is possible, why is it still not giving the resultant circuit.
I also tried the latest verison of the code, i.e
It still gives the same error for
qubits_per_qpu=5
. It works fine for other numbers. My Quantum Circuit is an 8 qubit one, given the (5,3) format adds extra qubit, do I have to manually add extra qubits before passing it on the code?