PennyLane 使用方法 : Configuration (翻訳)
翻訳 : (株)クラスキャット セールスインフォメーション
作成日時 : 10/21/2019
* 本ページは、PennyLane : Using PennyLane の次のページを翻訳した上で適宜、補足説明したものです:
* サンプルコードの動作確認はしておりますが、必要な場合には適宜、追加改変しています。
* ご自由にリンクを張って頂いてかまいませんが、sales-info@classcat.com までご一報いただけると嬉しいです。
$$
\def\bra#1{\mathinner{\left\langle{#1}\right|}}
\def\ket#1{\mathinner{\left|{#1}\right\rangle}}
\def\braket#1#2{\mathinner{\left\langle{#1}\middle|#2\right\rangle}}
$$
使用方法 : Configuration
量子ハードウェア・アクセスのためのユーザ・クレデンシャル、shots の数、あるいは連続変数シミュレータのための cutoff 次元のようなデバイスのための幾つかの重要なデフォルト設定は config.toml と呼ばれる configuration ファイルで定義されます。
Behaviour
最初のインポートで、PennyLane は優先順に次の 3 つのディレクトリをスキャンして configration ファイルをロードすることを試みます :
- 現在のディレクトリ
- 環境変数 PENNYLANE_CONF にストアされるパス
- デフォルトのユーザ configuration ディレクトリ :
- On Linux: ~/.config/pennylane
- On Windows: ~C:\Users\USERNAME\AppData\Local\Xanadu\pennylane
- On MacOS: ~/Library/Preferences/pennylane
configuration ファイルが見つからない場合には、警告メッセージがログで表示され、そしてデバイスをロードするとき総てのデバイス・パラメータはキーワード引数として渡される必要があります。
ユーザは pennylane.config を通して初期化された configuration にアクセスし、ロードされた configuration ファイルパスを見て、configuration オプションをプリントし、それらをキーを通して (i.e., pennylane.config[‘main.shots’]) アクセスして変更し、そして新しい configuration ファイルをセーブ/ロードすることができます。
フォーマット
configuration ファイル config.toml は TOML 標準 を使用し、次の形式を持ちます :
[main] # Global PennyLane options. # Affects every loaded plugin if applicable. shots = 1000 analytic = True [strawberryfields.global] # Options for the Strawberry Fields plugin hbar = 1 shots = 100 [strawberryfields.fock] # Options for the Strawberry Fields Fock plugin cutoff_dim = 10 hbar = 0.5 [strawberryfields.gaussian] # Indentation doesn't matter in TOML files, # but helps provide clarity. [projectq.global] # Options for the Project Q plugin [projectq.simulator] gate_fusion = true [projectq.ibm] user = "johnsmith" password = "secret123" use_hardware = true device = "ibmqx4" num_runs = 1024
標準 PennyLane オプションは [main] セクションで提供されます。これらは総てのロードされたデバイスに適用されます。代わりに、[plugin.global] の下でオプションを設定することによりオプションはプラグイン毎基準で指定できます。
例えば、上の configuration ファイルで、Strawberry Fields デバイスは shots = 1000 ではなく、shots = 100 のデフォルトでロードされます。最後に、[plugin.device] 設定の下でオプションを置くことにより、デバイス毎基準で設定を指定することもできます。
以上