0
$\begingroup$

I have a Quantum Circuit launched but I want to convert it into a qobj to use the function .run from qiskit, I've tried to use the function:

qobj = assemble(QuantumCircuit)

but it returns

'QuantumCircuit' object has no attribute 'config'

and I've failed to find the "config" needed on the qiskit instructions. Does anyone know's how do I convert it properly and fill's this configurations?

Here is a print of the qobj after assemble:

QASM Qobj: 3d6e9e20-290e-4c7d-a2e7-c0b5a8e38f2e:
Config: {'init_qubits': True,
 'memory': False,
 'memory_slots': 3,
 'n_qubits': 3,
 'parameter_binds': [],
 'shots': 1024}
Header: {}
Experiments:

QASM Experiment:
Header:
{'clbit_labels': [['c', 0], ['c', 1], ['c', 2]],
 'creg_sizes': [['c', 3]],
 'global_phase': 0.0,
 'memory_slots': 3,
 'n_qubits': 3,
 'name': 'circuit',
 'qreg_sizes': [['q', 3]],
 'qubit_labels': [['q', 0], ['q', 1], ['q', 2]]}
Config:
{'memory_slots': 3, 'n_qubits': 3}

    Instruction: ry
        params: [1.0]
        qubits: [0]

    Instruction: rz
        params: [2.0]
        qubits: [0]

    Instruction: h
        qubits: [0]

    Instruction: measure
        qubits: [0]
        memory: [0]

    Instruction: ry
        params: [1.0]
        qubits: [2]

    Instruction: rz
        params: [2.0]
        qubits: [2]

    Instruction: measure
        qubits: [2]
        memory: [2]

    Instruction: ry
        params: [1.0]
        qubits: [1]

    Instruction: rz
        params: [2.0]
        qubits: [1]

    Instruction: sdg
        qubits: [1]

    Instruction: h
        qubits: [1]

    Instruction: measure
        qubits: [1]
        memory: [1]

it still's return the same error.

$\endgroup$
1
$\begingroup$

The function assemble takes a QuantumCircuit instance, not the type:

qobj = assemble(QuantumCircuit())
type(qobj)
qiskit.qobj.qasm_qobj.QasmQobj

For example:

circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)

qobj = assemble(circuit)
print(qobj)
QASM Qobj: 2a18a692-be49-452e-8631-72865c890d05:
Config: {'init_qubits': True,
...
...
    Instruction: h
        qubits: [0]

    Instruction: cx
        qubits: [0, 1]
$\endgroup$
2
  • $\begingroup$ Yes I already have a 3 qubit 3 cr Quantum Circuit instance launched on my code, but when I try to use assemble on it, it returns the error that I said. $\endgroup$
    – Ziri
    Mar 9 at 15:45
  • $\begingroup$ I dont get it, sorry. assemble raise the error but creates the qobj anyway? Maybe share a minimal failing example... $\endgroup$
    – luciano
    Mar 13 at 19:42

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.