Qiskit / qiskit-aer

Aer is a high performance simulator for quantum circuits that includes noise models
https://qiskit.github.io/qiskit-aer/
Apache License 2.0
480 stars 355 forks source link

Parameters for QuantumError class #1777

Closed jacobwatkins1 closed 1 year ago

jacobwatkins1 commented 1 year ago

What is the expected behavior?

The QuantumError class does not currently allow for passing a Parameter like how one does for parametrized circuits. If it did, and one could construct a parametrized NoiseModel, it would add versatility to what one could do. For example, I could construct a circuit with parametrized noise, then execute that circuit with various noise values to test its relation to performance.

I could not find such functionality currently, so it seems to me that you would need to define a different circuit for each noise value. While this is not terribly difficult, it still seems less natural than having an object possessing an intrinsic noise parameter.

itoko commented 1 year ago

Yeah, it might be a nice feature to have. Would you mind elaborating on a use case when the new feature is useful? IMO, using the current API, the code would looks like:

for pval in parameter_values:
    quantum_error = create QuantumError with pval
    noise_model = NoiseModel()
    noise_model.add_quantum_error(quantum_error, gate_name, qubits)
    AerSimulator.run(circuit, noise_model=noise_model)

If we have NoiseModel with parameterized QuantumErrors, we could do

param = Parameter("param")
quantum_error = create QuantumError with param
noise_model = NoiseModel()
noise_model.add_quantum_error(quantum_error, gate_name, qubits)
noisy_circuit = insert_noise(circuit, noise_model)
for pval in parameter_values:
    noisy_circuit = noisy_circuit.assign_parameters(pval)
    AerSimulator.run(noisy_circuit)

It doesn't seem to make that much difference. Am I missing your point? @jacobwatkins1

jacobwatkins1 commented 1 year ago

Hi Itoko,

Thanks for your thoughtful response. I am thinking now that you are correct. It seems that the versatility that Parameters allow for circuits is not as necessary for cycling through multiple noise models.

I will close this issue in a few days, but leave some time for others to chime in, in case I have missed something.

Thanks again for your consideration.

-Jacob


From: Toshinari Itoko @.> Sent: Wednesday, April 19, 2023 3:20 To: Qiskit/qiskit-aer @.> Cc: Jacob Watkins @.>; Author @.> Subject: Re: [Qiskit/qiskit-aer] Parameters for QuantumError class (Issue #1777)

Yeah, it might be a nice feature to have. Would you mind elaborating on a use case when the new feature is useful? IMO, using the current API, the code would looks like:

for pval in parameter_values: quantum_error = QuantumError with pval noise_model = NoiseModel noise_model.add_quantum_error(quantum_error, gate_name, qubits) AerSimulator.run(circuit, noise_model=noise_model)

If we have NoiseModel with parameterized QuantumErrors, we could do

param = Parameter("param") quantum_error = QuantumError with param noise_model = NoiseModel noise_model.add_quantum_error(quantum_error, gate_name, qubits) noisy_circuit = insert_noise(circuit, noise_model) for pval in parameter_values: noisy_circuit = noisy_circuit.assign_parameters(pval) AerSimulator.run(noisy_circuit)

It doesn't seem to make that much difference. Am I missing your point?

— Reply to this email directly, view it on GitHubhttps://github.com/Qiskit/qiskit-aer/issues/1777#issuecomment-1514251130, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHA3SNARAPVOC23DKAFGZMTXB6G3NANCNFSM6AAAAAAWW2WHVY. You are receiving this because you authored the thread.Message ID: @.***>

hhorii commented 1 year ago

@jacobwatkins1 Can we close this issue?