Configure Qiskit locally
After Qiskit is installed and running, there are some optional steps you can take to change the default Qiskit behavior.
User configuration file
The main location for local configuration of Qiskit is the user configuration file. This is an .ini-format file that can be used to change Qiskit default settings.
Example:
[default]
circuit_drawer = mpl
circuit_mpl_style = default
circuit_mpl_style_path = ~:~/.qiskit
state_drawer = hinton
transpile_optimization_level = 3
parallel = False
num_processes = 15
By default, this file is in ~/.qiskit/settings.conf
but the path can be overridden with the QISKIT_SETTINGS environment variable.
Available options
circuit_drawer
: Changes the default backend for the circuit drawer. It can be set tolatex
,mpl
,text
, orlatex_source
. When the output kwarg is not explicitly set, this drawer backend is used.circuit_mpl_style
: The default style sheet used for the mpl output backend for the circuit drawer. Valid values aredefault
orbw
.circuit_mpl_style_path
: The paths to have the circuit drawer use to look for JSON style sheets when using the mpl output mode.state_drawer
: This is used to change the default backend for the state visualization draw methods. Valid values arerepr
,text
,latex
,latex_source
,qsphere
,hinton
, orbloch
. When the output kwarg is not explicitly set on the qiskit.quantum_info.DensityMatrix.draw (opens in a new tab) method, the specified output method is used.- `transpile_optimization_level: Change the default optimization level for qiskit.compiler.transpile (opens in a new tab) and qiskit.execute.execute (opens in a new tab). Specify an integer 0-3.
parallel
: Whether Python multiprocessing is enabled for operations that support running in parallel. For example, transpilation of multiple qiskit.circuit.QuantumCircuit (opens in a new tab) objects. This setting can be overridden by the QISKIT_PARALLEL environment variable. Specify a boolean value.num_processes
: The maximum number of parallel processes to launch for parallel operations if parallel execution is enabled. This setting can be overridden by the QISKIT_NUM_PROCS environment variable. Specify an integer greater than 0.
Note
- Circuit drawer settings apply to qiskit.circuit.QuantumCircuit.draw (opens in a new tab) and qiskit.visualization.circuit_drawer. (opens in a new tab)
- State visualization draw methods are qiskit.quantum_info.Statevector.draw (opens in a new tab) and qiskit.quantum_info.DensityMatrix.draw. (opens in a new tab)
Environment variables
Set these environment variables to alter the default behavior of Qiskit:
- QISKIT_PARALLEL: Enables Python multiprocessing to parallelize certain operations; for example, transpilation over multiple circuits in Qiskit. Specify a boolean value.
- QISKIT_NUM_PROCS: The maximum number of parallel processes to launch for parallel operations if parallel execution is enabled. Specify an integer greater than zero.
- RAYON_NUM_THREADS: The number of threads to run multithreaded operations in Qiskit. By default, multithreaded code launches a thread for each logical CPU. To adjust the number of threads Qiskit uses, set this to an integer value. For example, setting RAYON_NUM_THREADS=4 launches four threads for multithreaded functions.
- QISKIT_FORCE_THREADS: Specifies that multithreaded code should always execute in multiple threads. By default, if you're running multithreaded code in a section of Qiskit that is already running in parallel processes, Qiskit does not launch multiple threads but instead executes that function serially. This is done to avoid potentially overloading limited CPU resources. However, if you want to force the use of multiple threads even when in a multiprocess context, set QISKIT_FORCE_THREADS=TRUE.
Next steps
Recommendation
Follow the steps in Hello world to write and run a quantum program.
Was this page helpful?