Qiskit-Extensions / circuit-knitting-toolbox

Tools for knitting quantum circuits with Qiskit
https://qiskit-extensions.github.io/circuit-knitting-toolbox/
Apache License 2.0
74 stars 25 forks source link

evaluate_subcircuits issue after the 1st march 2024 update #501

Closed sayali1711 closed 5 months ago

sayali1711 commented 6 months ago

Issue/Error:-

Sample code snippet:-

#qc is any circuit
cuts = cut_circuit_wires(
        circuit=qc, method="manual", subcircuit_vertices=list(...)
    )

--------------error is raised in below line------------------------

_subcircuit_instance_probabilities = evaluate_subcircuits(cuts, **kwargs)_
reconstructed_probabilities = reconstruct_full_distribution( qc, subcircuit_instance_probabilities, cuts, num_threads=1 )

(backend used is any real ibm hardware , and rest parameters are passed from the code)

After Cutting the circuit when we pass the subcircuits and its complete path map generated i.e(cuts) by cut_circuit_wires function , evaluate_subcircuits is throwing an error shown below

image

Reason for the Error:-

Update to Qiskit Runtime Primitives | IBM Quantum Platform As of 1 March 2024, circuits and observables need to be transformed to only use instructions supported by the system (referred to as instruction set architecture (ISA) circuits and observables) before being submitted to the Qiskit Runtime primitives.

Update Requested:-

Hence in evaluate_subcircuts function provided by cutting knitting toolbox , updates need to be done so that while running the circuits inside that function it won't throw the above error.

garrison commented 6 months ago

Thank you for the report. I do think this is worth fixing even though cutqc is the legacy interface (#494).

garrison commented 5 months ago

I opened #504 but am currently unsure how to fix the ValueError I am now seeing.

sayali1711 commented 5 months ago

I opened #504 but am currently unsure how to fix the ValueError I am now seeing.

Along with the above errror, Even I was facing value error issue for large circuits as numpy array's dimension is exceeding while calculating probability.

sayali1711 commented 5 months ago

I am still facing with the same issue even after the update:-

It gives the following error :-

line 92, in validate_isa_circuits raise IBMInputValueError( qiskit_ibm_runtime.exceptions.IBMInputValueError: 'The instruction h on qubits (5,) is not supported by the target system. Circuits that do not match the target hardware definition are no longer supported after March 4, 2024. See the transpilation documentation (https://docs.quantum.ibm.com/transpile) for instructions to transform circuits and the primitive examples (https://docs.quantum.ibm.com/run/primitives-examples) to see this coupled with operator transformations.'

garrison commented 5 months ago

I am still facing with the same issue even after the update:-

Could you provide a full code snippet, with any explicit circuit that triggers that error? Are you using the main version of ckt? (The PR that supposedly fixed this has not made it to a release yet.)

sayali1711 commented 5 months ago

I am still facing with the same issue even after the update:-

Could you provide a full code snippet, with any explicit circuit that triggers that error? Are you using the main version of ckt? (The PR that supposedly fixed this has not made it to a release yet.)

Thankyou for the clarification , I believed that release has been made but I will definitely wait for the release too, The code used is:-

from circuit_knitting.cutting.cutqc import verify,cut_circuit_wires,evaluate_subcircuits,reconstruct_full_distribution
#circuit_knitting version is 0.6.0

qc=QuantumCircuit.from_qasm_file('MQTBench_2023-12-18-09-22-43/ghz_indep_qiskit_9.qasm')
cuts = cut_circuit_wires(circuit=qc, method="manual", subcircuit_vertices=list(...))
subcircuit_instance_probabilities = evaluate_subcircuits(circuit_cut, **kwargs)
reconstructed_probabilities = `reconstruct_full_distribution(` circuit = qc, subcircuit_instance_probabilities =subcircuit_instance_probabilities, cuts = circuit_cut, num_threads=10 )

Can you please confirm if this issue will be solved after the release of circuit knitting toolbox or update will be expected in validate_isa_circuits function present in another file/library (as per the above error).

garrison commented 5 months ago

Can you please confirm if this issue will be solved after the release of circuit knitting toolbox or update will be expected in validate_isa_circuits function present in another file/library (as per the above error).

I don't think I have access to the qasm file that would allow me to test this code, but if you want to install the current development version of CKT and test for yourself, you can run pip install git+https://github.com/Qiskit-Extensions/circuit-knitting-toolbox.git.

sayali1711 commented 5 months ago

Can you please confirm if this issue will be solved after the release of circuit knitting toolbox or update will be expected in validate_isa_circuits function present in another file/library (as per the above error).

I don't think I have access to the qasm file that would allow me to test this code, but if you want to install the current development version of CKT and test for yourself, you can run pip install git+https://github.com/Qiskit-Extensions/circuit-knitting-toolbox.git.

Thanks I will try updating the library. Also to test the circuit you can download the above qasm circuit from https://www.cda.cit.tum.de/mqtbench/