2
$\begingroup$

I am attempting to code a feed-forward simulation of a QECC in Qiskit. Qiskit (to my knowledge) does not directly support feed-forward simulation, so I attempted a work-around. I call the simulator firstly:

    #c/q register
    self.qubits = QuantumRegister(9)
    self.round1 = ClassicalRegister(2)
    self.round2 = ClassicalRegister(3)
    self.decoded = ClassicalRegister(7)
    self.circuit = QuantumCircuit(self.qubits,self.round1,self.round2,self.decoded,name="circuit")

    #noise model
    self.noisy = NoiseModel()
    self.error_rate = self.error_rates
    self.error_two_qubit = errors.depolarizing_error(self.error_rate/15, 2)
    self.noisy.add_all_qubit_quantum_error(self.error_two_qubit, ['cx','cz','cy']

    #simulator backend
    self.simulator = Aer.get_backend('qasm_simulator',noise_model=self.noisy)

Next, I attempt to save the statevector after calling the first stabilizer operator:

    self.circuit.reset(self.qubits[7])
    self.circuit.reset(self.qubits[8])
    self.circuit.h(self.qubits[8])
    self.circuit.cx(self.qubits[8],self.qubits[7])
    self.circuit.cx(self.qubits[target1],self.qubits[7])
    self.circuit.cx(self.qubits[target2],self.qubits[8])
    self.circuit.cx(self.qubits[target3],self.qubits[7])
    self.circuit.cx(self.qubits[target4],self.qubits[8])
    self.circuit.cx(self.qubits[8],self.qubits[7])
    self.circuit.h(self.qubits[8])
    self.circuit.measure(self.qubits[7],self.round1[0])
    self.circuit.measure(self.qubits[8],self.round1[1])
    self.circuit.save_statevector()

I lastly then attempt to execute the code up to the save-point:

self.result = execute(self.circuit,self.simulator,shots=1).result()
self.statevector = self.result.get_statevector(self.circuit)

I am not entirely sure why the error I get is of the following form:

Traceback (most recent call last):
self.circuit.save_statevector()
AttributeError: 'QuantumCircuit' object has no attribute 'save_statevector'

I have looked at the answers from the following URLs:

  1. https://stackoverflow.com/questions/67362847/attributeerror-quantumcircuit-object-has-no-attribute-config
  2. https://githubmemory.com/repo/Qiskit/qiskit-terra/issues/6346?page=2 .

I still am not able to fix the issue. Help would be much appreciated.

$\endgroup$
2
  • $\begingroup$ What Qiskit version do you have? $\endgroup$ Aug 4 at 18:08
  • $\begingroup$ qiskit==0.24.1 qiskit-aer==0.7.6 qiskit-aqua==0.8.2 qiskit-ibmq-provider==0.12.2 qiskit-ignis==0.5.2 qiskit-terra==0.16.4 $\endgroup$ Aug 4 at 20:43
3
$\begingroup$

According to Qiskit's release notes, it seems that save_statevector is added in version 0.25 (Aer 0.8.0)

So, upgrading Qiskit should fix this issue.

$\endgroup$
1
  • $\begingroup$ ah-ha! thanks. easy fix. Greatly appreciated! $\endgroup$ Aug 4 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.