qunasys / quri-parts Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
I apply readout_mitigation
to the counts of different circuits, some of them work well, but some give empty counts after appling readout_mitigation
for example, I set:
counts_readout = next(readout_mitigation(counts, filter_matrix))
When the error happens, I print the length of counts_readout
and counts
, the number of the job (this shows how many time does readout_mitigation
work successfully before this job), and the circuit.
The print result:
len(counts_readout)=0
len(counts)=1
job number =1073
(QuantumGate(name='X', target_indices=(0,), control_indices=(), classical_indices=(), params=(), pauli_ids=(), unitary_matrix=()), QuantumGate(name='X', target_indices=(1,), control_indices=(), classical_indices=(), params=(), pauli_ids=(), unitary_matrix=()), QuantumGate(name='X', target_indices=(2,), control_indices=(), classical_indices=(), params=(), pauli_ids=(), unitary_matrix=()), QuantumGate(name='X', target_indices=(3,), control_indices=(), classical_indices=(), params=(), pauli_ids=(), unitary_matrix=()), QuantumGate(name='RZ', target_indices=(0,), control_indices=(), classical_indices=(), params=(1.5707963267948966,), pauli_ids=(), unitary_matrix=()), QuantumGate(name='SqrtX', target_indices=(0,), control_indices=(), classical_indices=(), params=(), pauli_ids=(), unitary_matrix=()), QuantumGate(name='RZ', target_indices=(0,), control_indices=(), classical_indices=(), params=(1.5707963267948966,), pauli_ids=(), unitary_matrix=()), QuantumGate(name='RZ', target_indices=(1,), control_indices=(), classical_indices=(), params=(0.0,), pauli_ids=(), unitary_matrix=()), QuantumGate(name='SqrtX', target_indices=(1,), control_indices=(), classical_indices=(), params=(), pauli_ids=(), unitary_matrix=()), QuantumGate(name='RZ', target_indices=(1,), control_indices=(), classical_indices=(), params=(1.5707963267948966,), pauli_ids=(), unitary_matrix=()), QuantumGate(name='RZ', target_indices=(7,), control_indices=(), classical_indices=(), params=(1.5707963267948966,), pauli_ids=(), unitary_matrix=()), QuantumGate(name='SqrtX', target_indices=(7,), control_indices=(), classical_indices=(), params=(), pauli_ids=(), unitary_matrix=()), QuantumGate(name='RZ', target_indices=(7,), control_indices=(), classical_indices=(), params=(1.5707963267948966,), pauli_ids=(), unitary_matrix=()), QuantumGate(name='RZ', target_indices=(5,), control_indices=(), classical_indices=(), params=(1.5707963267948966,), pauli_ids=(), unitary_matrix=()), QuantumGate(name='SqrtX', target_indices=(5,), control_indices=(), classical_indices=(), params=(), pauli_ids=(), unitary_matrix=()), QuantumGate(name='RZ', target_indices=(5,), control_indices=(), classical_indices=(), params=(1.5707963267948966,), pauli_ids=(), unitary_matrix=()), QuantumGate(name='RZ', target_indices=(2,), control_indices=(), classical_indices=(), params=(0.0,), pauli_ids=(), unitary_matrix=()), QuantumGate(name='SqrtX', target_indices=(2,), control_indices=(), classical_indices=(), params=(), pauli_ids=(), unitary_matrix=()), QuantumGate(name='RZ', target_indices=(2,), control_indices=(), classical_indices=(), params=(1.5707963267948966,), pauli_ids=(), unitary_matrix=()), QuantumGate(name='RZ', target_indices=(4,), control_indices=(), classical_indices=(), params=(1.5707963267948966,), pauli_ids=(), unitary_matrix=()), QuantumGate(name='SqrtX', target_indices=(4,), control_indices=(), classical_indices=(), params=(), pauli_ids=(), unitary_matrix=()), QuantumGate(name='RZ', target_indices=(4,), control_indices=(), classical_indices=(), params=(1.5707963267948966,), pauli_ids=(), unitary_matrix=()))
<class 'ValueError'>: No measurement counts supplied (counts is empty).
Dear quri-parts developers.
We would like to use Quri to create a UCC circuit in Qiskit and convert it to a circuit to quri. quri-parts-qiskit seems to be compatible with version 0.39.5 of qiskit, but the version of Qiskit is old and it seems that we cannot use the library Qiskit-Nature which contains the UCC method. Are there any plans to support the current version of Qiskit? Also, how can quri be used for quantum circuits for the UCC method?
Sincerely, Yukihiro Okuno.
Execute the following code.
from quri_parts.circuit import QuantumCircuit
from quri_parts.openqasm.circuit import convert_to_qasm_str
circuit = QuantumCircuit(2)
circuit.add_H_gate(0)
circuit.add_CNOT_gate(0, 1)
print(convert_to_qasm_str(circuit))
Then this code outputs OpenQASM strings.
OPENQASM 3;
include "stdgates.inc";
qubit[2] q;
h q[0];
cx q[0] q[1];
I think that there should be a comma between q[0] and q[1] in the last line.
cx q[0], q[1];
If my think is right, I will fix it.
Hi QunaSys devs,
Qiskit is moving away from the metapackage architecture and it is much more robust to depend on qiskit
directly instead of the subpackage qiskit-terra
.
Additionally, consider having a look at https://www.ibm.com/quantum/blog/transition-to-1 for how to transition to Qiskit 1.0
When I use parameter_shift_gradient_estimates
to create_parametric_estimator(some_estimator)
, it raises error.
Here is my code:
param_estimator = create_parametric_estimator(estimator)
grad = parameter_shift_gradient_estimates(
op, parametric_state, param_values, param_estimator
)
I tried different estimators and got the same error:
I'm sure the parametric state only contains 1 parameter, which matchs the error saying "parameter count(1)". The param_values
I used is [0.], but the error says "Passed value count (2)"
I also tried parametric estimator directly (so I don't need create_parametric_estimator
to transit it) with parameter_shift_gradient_estimates
, that works well on the same parametric state and param_values.
And create_parametric_estimator(some_estimator)
also works on the same parametric state and param_values.
It seems that create_parametric_estimator
and parameter_shift_gradient_estimates
together make errors.
This line sometimes throws a key error:
This one too
It seems kind of obvious in hindsight, but the self._sampling_counts.keys()
should be checked before requesting a specific count.
Dear Quri-parts developers.
I would like to use the backprop in Qulacs ParametricQuantumCircuit to speed up the calculation of optimize for VQE.
The circuit itself is configured using KUpCCGSD in quri_parts.openfermion.ansatz, which is later converted to Qulacs' QuantumCircuit using convert_circuit. It does not convert the circuit as a ParametricQuantumCircuit but QuantumCircuit of qulacs class, so I can't use backprop as it is. How can I convert a Circuit created with quri_parts.openfermion.ansatz into a Qulacs Circuit so that I can use backprop?
Sincerely,
Yukihiro Okuno.
ZNE only implemented mitigation for hermitian operator, can make it support non-hermitian operator also?
Importing Adam
from quri_parts.algo.optimizer
while using Python 3.11 currently produces this error:
ValueError: mutable default <class 'numpy.ndarray'> for field m is not allowed: use default_factory
However, running the same line in Python 3.10 produces no errors. The difference seems to be due to a change in the dataclasses
library.
In Python 3.10 we have (under Python310/Lib/dataclasses.py
, lines 811-814):
# For real fields, disallow mutable defaults for known types.
if f._field_type is _FIELD and isinstance(f.default, (list, dict, set)):
raise ValueError(f'mutable default {type(f.default)} for field '
f'{f.name} is not allowed: use default_factory')
Compared with Python 3.11 in which the same snippet is: (under Python311/Lib/dataclasses.py
, lines 811-816)
# For real fields, disallow mutable defaults. Use unhashable as a proxy
# indicator for mutability. Read the __hash__ attribute from the class,
# not the instance.
if f._field_type is _FIELD and f.default.__class__.__hash__ is None:
raise ValueError(f'mutable default {type(f.default)} for field '
f'{f.name} is not allowed: use default_factory')
As you can see, the criterion for immutability has changed, hence the new error. This should be relatively easy to fix by using default_factory
, as suggested by the error message. To be honest, this might be more of an issue with the Python 3.11 implementation than with quri-parts
, seeing how it flags a read-only view of a numpy
array as mutable, but there's not much we can do about that now.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.