Lokale Konfiguration#

Sobald Sie Qiskit installiert und ausgeführt haben, können Sie einige optionale Konfigurationsschritte vornehmen, um das Standardverhalten von Qiskit für Ihren speziellen Anwendungsfall zu ändern.

Benutzerkonfigurationsdatei#

Der Hauptort für die lokale Konfiguration von Qiskit ist die Konfigurationsdatei des Benutzers (user config file). Dies ist eine ini Formatdatei, die verwendet werden kann, um die Standardwerte in Qiskit zu ändern.

Zum Beispiel:

[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 lives in ~/.qiskit/settings.conf but the path used can be overridden with the QISKIT_SETTINGS environment variable. If QISKIT_SETTINGS is set its value will used as the path to the user config file.

Mögliche Optionen:

  • ` ` circuit_Schublade ` : Wird verwendet, um das Standard-Backend für den Schaltkreis-Zeichner :meth: qiskit.circuit.QuantumCircuit.draw ` und :func:` qiskit.visualization.circuit_drawer ` zu ändern. Es kann auf ` ` latex ` `, ` ` mpl ` `, ` ` text ` `, oder ` ` latex_source ` ` gesetzt werden und wenn ` ` ouptut ` ` kwarg nicht explizit gesetzt ist, wird das Zeichner-Backend verwendet.

  • circuit_mpl_style: Dies ist die Standardeinstellung für das mpl Ausgabe-Backend für die Schaltungszeichner qiskit. ircuit.QuantumCircuit.draw() und qiskit.visualization.circuit_drawer(). Es kann auf default oder bw gesetzt werden.

  • ` ` circuit_mpl_style_path ` : Mit diesem Befehl können Sie den/die Pfad(e) einzustellen, in denen der Schaltkreiszeichner, :meth: qiskit.circuit.QuantumCircuit.draw ` oder :func:` qiskit.visualization.circuit_drawer ` nach Json-Style-Sheets sucht, wenn Sie den ` ` mpl ` ` -Ausgabemodus verwenden.

  • state_drawer: Dies wird verwendet, um das Standard-Backend für die Zustands-Visualisierung-Zeichenmethoden zu ändern qiskit.quantum_info.Statevector.draw() und qiskit.quantum_info.DensityMatrix.draw() zu ändern. Es kann auf repr, text‘, latex, latex_source, qsphere, hinton, oder bloch bloch gesetzt werden. Wenn das output kwarg nicht explizit auf die draw() gesetzt wurde, wird diese Ausgabemethode verwendet.

  • transpile_optimization_level: Dies verlangt einen Integer zwischen 0-3 und wird verwendet, um die Standardoptimierungsstufe für transpile() und execute() zu ändern.

  • parallel: This option takes a boolean value (either True or False) and is used to configure whether Python multiprocessing is enabled for operations that support running in parallel (for example transpilation of multiple QuantumCircuit objects). The default setting in the user config file can be overridden by the QISKIT_PARALLEL environment variable.

  • num_processes: This option takes an integer value (> 0) that is used to specify the maximum number of parallel processes to launch for parallel operations if parallel execution is enabled. The default setting in the user config file can be overridden by the QISKIT_NUM_PROCS environment variable.

Umgebungsvariablen#

Es gibt auch ein paar Umgebungsvariablen, die gesetzt werden können, um das Standardverhalten von Qiskit zu ändern.

  • QISKIT_PARALLEL: if this variable is set to TRUE it will enable the use of Python multiprocessing to parallelize certain operations (for example transpilation over multiple circuits) in Qiskit.

  • ` ` QISKIT_NUM_PROCS ` `: Gibt die maximale Anzahl paralleler Prozesse an, die für parallele Operationen gestartet werden sollen, wenn die parallele Ausführung aktiviert ist. Es erwartet einen Integer > 0.

  • RAYON_NUM_THREADS: Specifies the number of threads to run multithreaded operations in Qiskit. By default this multithreaded code will launch a thread for each logical CPU, if you’d like to adjust the number of threads Qiskit will use you can set this to an integer value. For example, setting RAYON_NUM_THREADS=4 will only launch 4 threads for multithreaded functions.

  • QISKIT_FORCE_THREADS: Legt fest, dass Multithread-Code immer in mehreren Threads ausgeführt werden soll. Standardmäßig wird Qiskit nicht mehrere Threads starten, sondern diese Funktion seriell ausführen. Dies wird getan, um zu vermeiden, dass möglicherweise begrenzte CPU-Ressourcen überlastet werden. Wenn jedoch die Verwendung von mehreren Threads erzwungen werden soll, kann QISKIT_FORCE_THREADS=TRUE gesetzt werden, um dies zu tun.