Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'QuantumCircuit' object has no attribute '_parameter_table' #1469

Closed
RunawayFancy opened this issue Sep 3, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@RunawayFancy
Copy link

Informations

  • Qiskit Experiments version: 0.7.0
  • Python version: 3.10.10
  • Operating system: Windows

What is the current behavior?

I set up a now environment with qiskit, qiskit-experiment and want to run the 1Q RB code. The import is godd, but the expdata1 = exp1.run(backend).block_for_results() raise up an AttributeError:

Code

import numpy as np
from qiskit_experiments.library import StandardRB, InterleavedRB
from qiskit_experiments.framework import ParallelExperiment, BatchExperiment
import qiskit.circuit.library as circuits

# For simulation
from qiskit_aer import AerSimulator
from qiskit_ibm_runtime.fake_provider import FakePerth

backend = AerSimulator.from_backend(FakePerth())

lengths = np.arange(1, 800, 200)
num_samples = 10
seed = 1010
qubits = [0]

# Run an RB experiment on qubit 0
exp1 = StandardRB(qubits, lengths, num_samples=num_samples, seed=seed)
expdata1 = exp1.run(backend).block_for_results()
results1 = expdata1.analysis_results()

# View result data
print("Gate error ratio: %s" % expdata1.experiment.analysis.options.gate_error_ratio)
display(expdata1.figure(0))
for result in results1:
    print(result)

Errors

{
	"name": "AttributeError",
	"message": "'QuantumCircuit' object has no attribute '_parameter_table'",
	"stack": "---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[2], line 8
      6 # Run an RB experiment on qubit 0
      7 exp1 = StandardRB(qubits, lengths, num_samples=num_samples, seed=seed)
----> 8 expdata1 = exp1.run(backend).block_for_results()
      9 results1 = expdata1.analysis_results()
     11 # View result data

File e:\\conda\\envs\\qiskit_prac\\lib\\site-packages\\qiskit_experiments\\framework\\base_experiment.py:245, in BaseExperiment.run(self, backend, analysis, timeout, **run_options)
    242 experiment._finalize()
    244 # Generate and transpile circuits
--> 245 transpiled_circuits = experiment._transpiled_circuits()
    247 # Initialize result container
    248 experiment_data = experiment._initialize_experiment_data()

File e:\\conda\\envs\\qiskit_prac\\lib\\site-packages\\qiskit_experiments\\library\\randomized_benchmarking\\standard_rb.py:381, in StandardRB._transpiled_circuits(self)
    379     transpiled = super()._transpiled_circuits()
    380 else:
--> 381     transpiled = [
    382         _transpile_clifford_circuit(circ, physical_qubits=self.physical_qubits)
    383         for circ in self.circuits()
    384     ]
    385     # Set custom calibrations provided in backend (excluding simulators)
    386     if isinstance(self.backend, BackendV2) and \"simulator\" not in self.backend.name:

File e:\\conda\\envs\\qiskit_prac\\lib\\site-packages\\qiskit_experiments\\library\\randomized_benchmarking\\standard_rb.py:382, in <listcomp>(.0)
    379     transpiled = super()._transpiled_circuits()
    380 else:
    381     transpiled = [
--> 382         _transpile_clifford_circuit(circ, physical_qubits=self.physical_qubits)
    383         for circ in self.circuits()
    384     ]
    385     # Set custom calibrations provided in backend (excluding simulators)
    386     if isinstance(self.backend, BackendV2) and \"simulator\" not in self.backend.name:

File e:\\conda\\envs\\qiskit_prac\\lib\\site-packages\\qiskit_experiments\\library\\randomized_benchmarking\\clifford_utils.py:55, in _transpile_clifford_circuit(circuit, physical_qubits)
     51 def _transpile_clifford_circuit(
     52     circuit: QuantumCircuit, physical_qubits: Sequence[int]
     53 ) -> QuantumCircuit:
     54     # Simplified transpile that only decomposes Clifford circuits and creates the layout.
---> 55     return _apply_qubit_layout(_decompose_clifford_ops(circuit), physical_qubits=physical_qubits)

File e:\\conda\\envs\\qiskit_prac\\lib\\site-packages\\qiskit_experiments\\library\\randomized_benchmarking\\clifford_utils.py:64, in _decompose_clifford_ops(circuit)
     58 def _decompose_clifford_ops(circuit: QuantumCircuit) -> QuantumCircuit:
     59     # Simplified QuantumCircuit.decompose, which decomposes only Clifford ops
     60     # Note that the resulting circuit depends on the input circuit,
     61     # that means the changes on the input circuit may affect the resulting circuit.
     62     # For example, the resulting circuit shares the parameter_table of the input circuit,
     63     res = circuit.copy_empty_like()
---> 64     res._parameter_table = circuit._parameter_table
     65     for inst in circuit:
     66         if inst.operation.name.startswith(\"Clifford\"):  # Decompose

AttributeError: 'QuantumCircuit' object has no attribute '_parameter_table'"
}

Steps to reproduce the problem

With the same environment, run

import numpy as np
from qiskit_experiments.library import StandardRB, InterleavedRB
from qiskit_experiments.framework import ParallelExperiment, BatchExperiment
import qiskit.circuit.library as circuits

# For simulation
from qiskit_aer import AerSimulator
from qiskit_ibm_runtime.fake_provider import FakePerth

backend = AerSimulator.from_backend(FakePerth())

lengths = np.arange(1, 800, 200)
num_samples = 10
seed = 1010
qubits = [0]

# Run an RB experiment on qubit 0
exp1 = StandardRB(qubits, lengths, num_samples=num_samples, seed=seed)
expdata1 = exp1.run(backend).block_for_results()
results1 = expdata1.analysis_results()

# View result data
print("Gate error ratio: %s" % expdata1.experiment.analysis.options.gate_error_ratio)
display(expdata1.figure(0))
for result in results1:
    print(result)

What is the expected behavior?

Same as https://qiskit-community.github.io/qiskit-experiments/manuals/verification/randomized_benchmarking.html shows.

Suggested solutions

No idea.

Appendix I: All packages

annotated-types==0.7.0
argon2-cffi==21.3.0
arraylias==0.1.1
asteval==1.0.2
asttokens==2.4.1
certifi==2024.8.30
cffi==1.17.0
charset-normalizer==3.3.2
clarabel==0.9.0
colorama==0.4.6
comm @ file:///home/conda/feedstock_root/build_artifacts/comm_1710320294760/work
contourpy==1.3.0
cryptography==43.0.1
cvxpy==1.5.3
cycler==0.12.1
debugpy @ file:///D:/bld/debugpy_1725269264841/work
decorator==5.1.1
dill==0.3.8
ecos==2.0.14
exceptiongroup==1.2.0
executing==2.0.1
fonttools==4.53.1
ibm-cloud-sdk-core==3.20.6
ibm-platform-services==0.56.0
idna==3.8
importlib_metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1724187233579/work
ipykernel @ file:///D:/bld/ipykernel_1719845595208/work
ipython @ file:///D:/bld/ipython_1725050320818/work
ipywidgets==7.6.5
isoduration==20.11.0
jedi==0.19.1
joblib==1.4.2
jupyter==1.0.0
jupyter-lsp==2.2.0
jupyter_client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1716472197302/work
jupyter_core @ file:///D:/bld/jupyter_core_1710257272359/work
jupyter_server_terminals==0.4.4
kiwisolver==1.4.6
lmfit==1.3.2
matplotlib==3.9.2
matplotlib-inline==0.1.6
mpmath==1.3.0
multiset==3.2.0
nest_asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1705850609492/work
notebook_shim==0.2.3
numpy==2.1.1
osqp==0.6.7.post1
packaging==24.0
pandas==2.2.2
parso==0.8.3
pbr==6.1.0
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work
pillow==10.4.0
platformdirs @ file:///home/conda/feedstock_root/build_artifacts/platformdirs_1715777629804/work
prompt-toolkit==3.0.43
psutil @ file:///D:/bld/psutil_1719274706785/work
pure-eval==0.2.2
pycparser==2.22
pydantic==2.8.2
pydantic_core==2.20.1
pydot==3.0.1
Pygments==2.17.2
PyJWT==2.9.0
pylatexenc==2.10
pyparsing==3.1.4
pyspnego==0.11.1
python-dateutil==2.9.0.post0
pytz==2024.1
pywin32==306
PyYAML==6.0.2
pyzmq==25.1.2
qdldl==0.1.7.post4
qiskit==1.2.0
qiskit-aer==0.15.0
qiskit-dynamics==0.5.1
qiskit-experiments==0.7.0
qiskit-ibm-experiment==0.4.7
qiskit-ibm-runtime==0.28.0
requests==2.32.3
requests_ntlm==1.3.0
rustworkx==0.15.1
scikit-learn==1.5.1
scipy==1.14.1
scs==3.2.7
seaborn==0.13.2
six==1.16.0
sspilib==0.1.0
stack-data==0.6.3
stevedore==5.3.0
symengine==0.11.0
sympy==1.13.2
threadpoolctl==3.5.0
tornado==6.4
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1713535121073/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1717802530399/work
tzdata==2024.1
uncertainties==3.2.2
urllib3==2.2.2
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1704731205417/work
websocket-client==1.8.0
widgetsnbextension==3.5.2
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1724730934107/work

@RunawayFancy RunawayFancy added the bug Something isn't working label Sep 3, 2024
@yaelbh
Copy link
Collaborator

yaelbh commented Sep 4, 2024

I think it was fixed in #1465 (probably not released yet).

@RunawayFancy
Copy link
Author

Thank you, that's helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants