GithubHelp home page GithubHelp logo

quri-parts's People

Contributors

ayakatoayaka avatar bogdanrajkov avatar dchung0741 avatar dependabot[bot] avatar hayatoyunoki avatar henryliao85 avatar kushargs avatar kwkbtr avatar lqtmirage avatar r-imai-quantum avatar rykojima avatar snuffkin avatar speed1313 avatar tanan avatar terasakisatoshi avatar thomasenqunasys avatar toru4838 avatar wakuwaku414 avatar y-yu avatar yasuo-ozu avatar zshan0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

quri-parts's Issues

readout_mitigation gives empty counts sometimes

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).

On the circuit convert from qiskit to quri

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.

[openqasm] two-qubit gates output by "convert_to_qasm_str" function have no comma

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.

parameter_shift_gradient_estimates and create_parametric_estimator conflict

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:
image
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.

Overlap estimator bug

This line sometimes throws a key error:

val = self._sampling_counts[0] / self._total_counts

This one too

p = self._sampling_counts[0] / self._total_counts

It seems kind of obvious in hindsight, but the self._sampling_counts.keys() should be checked before requesting a specific count.

How to use backprop of Qulacs ParametricQuantumCircuit in quri-parts?

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.

Adam optimiser seems incompatible with Python 3.11 dataclasses

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.