Qiskit 0.6 release notes
0.6
Terra 0.6
Highlights
This release includes a redesign of internal components centered around a new, formal communication format (Qobj), along with long awaited features to improve the user experience as a whole. The highlights, compared to the 0.5 release, are:
- Improvements for inter-operability (based on the Qobj specification) and extensibility (facilities for extending Qiskit with new backends in a seamless way)
- New options for handling credentials and authentication for the IBM Q backends, aimed at simplifying the process and supporting automatic loading of user credentials
- A revamp of the visualization utilities: stylish interactive visualizations are now available for Jupyter users, along with refinements for the circuit drawer (including a matplotlib-based version)
- Performance improvements centered around circuit transpilation: the basis for a more flexible and modular architecture have been set, including parallelization of the circuit compilation and numerous optimizations
Compatibility Considerations
Please note that some backwards-incompatible changes have been introduced during this release – the following notes contain information on how to adapt to the new changes.
Removal of QuantumProgram
As hinted during the 0.5 release, the deprecation of the QuantumProgram
class has now been completed and is no longer available, in favor of working with the individual components (BaseJob
, QuantumCircuit
, ClassicalRegister
, QuantumRegister
, qiskit
) directly.
Please check the 0.5 release notes and the examples for details about the transition:
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import Aer, execute
q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q, c)
qc.h(q[0])
qc.cx(q[0], q[1])
qc.measure(q, c)
backend = get_backend('qasm_simulator')
job_sim = execute(qc, backend)
sim_result = job_sim.result()
print("simulation: ", sim_result)
print(sim_result.get_counts(qc))
IBM Q Authentication and Qconfig.py
The managing of credentials for authenticating when using the IBM Q backends has been expanded, and there are new options that can be used for convenience:
-
save your credentials in disk once, and automatically load them in future sessions. This provides a one-off mechanism:
from qiskit import IBMQ IBMQ.save_account('MY_API_TOKEN', 'MY_API_URL')
afterwards, your credentials can be automatically loaded from disk by invoking
load_accounts()
:from qiskit import IBMQ IBMQ.load_accounts()
or you can load only specific accounts if you only want to use those in a session:
IBMQ.load_accounts(project='MY_PROJECT')
-
use environment variables. If
QE_TOKEN
andQE_URL
is set, theIBMQ.load_accounts()
call will automatically load the credentials from them.
Additionally, the previous method of having a Qconfig.py
file in the program folder and passing the credentials explicitly is still supported.
Working with backends
A new mechanism has been introduced in Terra 0.6 as the recommended way for obtaining a backend, allowing for more powerful and unified filtering and integrated with the new credentials system. The previous top-level methods register()
, available_backends()
and get_backend()
are still supported, but will deprecated in upcoming versions in favor of using the qiskit.IBMQ and qiskit.Aer objects directly, which allow for more complex filtering.
For example, to list and use a local backend:
from qiskit import Aer
all_local_backends = Aer.backends(local=True) # returns a list of instances
qasm_simulator = Aer.backends('qasm_simulator')
And for listing and using remote backends:
from qiskit import IBMQ
IBMQ.enable_account('MY_API_TOKEN')
5_qubit_devices = IBMQ.backends(simulator=True, n_qubits=5)
ibmqx4 = IBMQ.get_backend('ibmqx4')
Please note as well that the names of the local simulators have been simplified. The previous names can still be used, but it is encouraged to use the new, shorter names:
Qiskit Terra 0.5 | Qiskit Terra 0.6 |
---|---|
‘local_qasm_simulator’ | ‘qasm_simulator’ |
‘local_statevector_simulator’ | ‘statevector_simulator’ |
‘local_unitary_simulator_py’ | ‘unitary_simulator’ |
Backend and Job API changes
-
Jobs submitted to IBM Q backends have improved capabilities. It is possible to cancel them and replenish credits (
job.cancel()
), and to retrieve previous jobs executed on a specific backend either by job id (backend.retrieve_job(job_id)
) or in batch of latest jobs (backend.jobs(limit)
) -
Properties for checking each individual job status (
queued
,running
,validating
,done
andcancelled
) no longer exist. If you want to check the job status, use the identity comparison againstjob.status
:from qiskit.backends import JobStatus job = execute(circuit, backend) if job.status() is JobStatus.RUNNING: handle_job(job)
Please consult the new documentation of the IBMQJob
class to get further insight in how to use the simplified API.
-
A number of members of
BaseBackend
andBaseJob
are no longer properties, but methods, and as a result they need to be invoked as functions.Qiskit Terra 0.5 Qiskit Terra 0.6 backend.name backend.name() backend.status backend.status() backend.configuration backend.configuration() backend.calibration backend.properties() backend.parameters backend.jobs() backend.retrieve_job(job_id) job.status job.status() job.cancelled job.queue_position() job.running job.cancel() job.queued job.done
Better Jupyter tools
The new release contains improvements to the user experience while using Jupyter notebooks.
First, new interactive visualizations of counts histograms and quantum states are provided: plot_histogram()
and plot_state()
. These methods will default to the new interactive kind when the environment is Jupyter and internet connection exists.
Secondly, the new release provides Jupyter cell magics for keeping track of the progress of your code. Use %%qiskit_job_status
to keep track of the status of submitted jobs to IBM Q backends. Use %%qiskit_progress_bar
to keep track of the progress of compilation/execution.