From a11b27122ffa53b25680979ae67b718dc949f8c0 Mon Sep 17 00:00:00 2001 From: Koji Terashi Date: Fri, 9 Feb 2024 14:09:55 +0900 Subject: [PATCH] updated prereq --- source/en/prerequisites.md | 58 +++++++++++++++----------------------- 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/source/en/prerequisites.md b/source/en/prerequisites.md index 2388fd0..c09bdcb 100644 --- a/source/en/prerequisites.md +++ b/source/en/prerequisites.md @@ -22,9 +22,9 @@ language_info: version: 3.10.6 --- -# 実習の準備 +# Preparation of Hands-on Exercise -```{contents} 目次 +```{contents} Contents --- local: true --- @@ -34,25 +34,22 @@ local: true ## IBM Quantum -### IBMidを取得し、IBM Quantumにログインする +### Obtain IBMid and log in IBM Quantum -IBM Quantumを利用するには、IBMidというアカウントを作り、サービストークンを取得する必要があります。IBM QuantumウェブサイトからIDを取得し、サービスにログインしてください。 -TO use IBM Quantum, you must first create an IBMid account and receive a service token. Acquire an ID from the IBM Quantum website and log into the service. +To use IBM Quantum, you must first create an IBMid account and receive a service token. Obtain an IBMid from the IBM Quantum website and log into the service. (install_token)= -### (ローカル環境)IBM Quantum APIトークンを取得し、Qiskit設定に保存する +### (Local environment)Get IBM Quantum API token and store it in Qiskit setting -IBM Quantum Lab(IBM Quantumウェブサイト上のJupyter Lab)でプログラムを実行する場合、以下の手続きは不要です。 +You can skip the following step if you are going to execute program on IBM Quantum Lab (Jupyter Lab on IBM Quantum website). -ログインしたらホーム画面のYour API tokenという欄からトークンをコピーできます。 On the main screen shown after logging in, copy the token displayed in the "Your API token" area. ```{image} figs/ibmq_home.png :height: 400px :name: My Account ``` -アカウントごとに発行されるサービストークンは、ユーザー名+パスワードの代わりとしてPythonプログラム中でIBMQに接続するために使用されます。ローカルディスクに書き込める環境にある場合は、一度トークンを設定ファイルに保存することで、以降の認証を自動化できます。下のコードセルの`__paste_your_token_here__`のところにIBM Quantumからコピーしたトークンを貼り付け、実行してください。 -Service tokens are issued on a per-account basis and are used by the Python program to connect to IBMQ. They play the roles of user IDs and passwords. +Service tokens issued on an account basis are used for username+password in Python program to connect to IBM Quantum. If you have a write access to local disks, the authentication to access IBM Quantum can be processed transparently by saving the token into a setting file. Copy the token from IBM Quantum and paste it to `__paste_your_token_here__` in the following code cell and execute. ```{code-cell} ipython3 :tags: [raises-exception, remove-output] @@ -62,7 +59,7 @@ from qiskit_ibm_provider import IBMProvider IBMProvider.save_account('__paste_your_token_here__') ``` -トークンを保存することで、プログラム中でのIBM Quantumへの認証(IBMProviderの取得)は +By saving the token in a setting file, your access to IBM Quantum can be authenticated through IBMProvider, as follows: ```{code-block} python from qiskit_ibm_provider import IBMProvider @@ -70,9 +67,9 @@ from qiskit_ibm_provider import IBMProvider provider = IBMProvider() ``` -のようになります。ちなみにIBM Quantum Labでは最初からトークンが保存されている状態なので、このコードで認証が行なえます。 +In the IBM Quantum Lab, the access token is automatically stored, therefore this code will work as it is. -ローカルディスクに書き込める環境でない場合(このワークブックをインタラクティブに使っている場合など)は、Pythonプログラムを実行するたびに(Jupyterのカーネルを再起動するたびに)手動で認証を行う必要があります。 +If you do not have a write access to local disks (e.g, you are using this notebook interactively), you need to authenticate by hand every time you execute a python program (restarting a Jupyter kernel) as follows: ```{code-block} python from qiskit_ibm_provider import IBMProvider @@ -80,48 +77,37 @@ from qiskit_ibm_provider import IBMProvider provider = IBMProvider(token='__paste_your_token_here__') ``` -## ワークブックの使い方 +## How to use this workbook -### インタラクティブHTML +### Interactive HTML + +You can execute the programs written in each cell of this workbook directly on the browser, just like using Jupyter Notebook. Move the cursor over at the top-right of the page and click Live Code from the menu. A status indicator will appear below the page title, and wait until the status becomes ready. -このワークブックの各ページにあるプログラムの書かれたセルは、そのままJupyter Notebookのようにブラウザ上で実行することができます。ページの右上のにカーソルを乗せ、現れるメニューから Live Codeをクリックしてください。ページのタイトルの下にステータス表示が現れるので、readyと表示されるまで待ちます。 -The cells in which programs are written in in this workbook can be executed directly from the browser, like using Jupyter Notebook. Mouse over at the top right of the page and click Live Code on the menu that appears. A status indicator will appear below the page title. Wait until the status is ready. ```{image} figs/toggle_interactive.jpg :height: 400px :name: Turn interactive contents on ``` -ページがインタラクティブになると、コード・セルにrunおよびrestartというボタンが現れ、直下にセルの出力が表示されるようになります。 -When the page becomes interactive, run and restart buttons will appear in code cells, and the output of running the code will be displayed immediately below them. +When the page becomes interactive, run and restart buttons will appear in a code cell, and the output of the code will be displayed just below. ```{image} figs/interactive_cell.jpg :height: 200px :name: Interactive code cell ``` -この状態になったら、入力セルの内容を自由に書き換えて、runボタンをクリックして(もしくはShift + Enterで)Pythonコードを実行することができます。このときいくつか注意すべき点があります。 -In this state, you can directly edit the contents of the cell and click the "run" button (or press Shift + Enter) to run the Python code. There are several important points to note when doing so. - -- restartを押すまでページ全体が一つのプログラムになっているので、定義された変数などはセルをまたいで利用される。 -- しばらく何もしないでページを放置していると、実行サーバーとの接続が切れてしまう。その場合ページを再度読み込んで、改めてインタラクティブコンテンツを起動する必要がある。 -- コードはmybinder.orgという外部サービス上で実行されるので、個人情報等センシティブな内容の送信は極力避ける。
- (通信は暗号化されていて、mybinder.org中ではそれぞれのユーザーのプログラムは独立のコンテナ中で動くので、情報が外に筒抜けということではないはずですが、念の為。)
- ただし上で出てきたように、IBM Quantumのサービストークンだけはどうしても送信する必要があります。 +In this state, you can directly edit the contents of the cell and click the "run" button (or press Shift + Enter) to run the Python code. There are several points to be aware of when doing this. -- The entire page will be treated as one program, so, for examples, the values of variables defined in one cell will be carried over into other cells until "restart" is pressed.The -- If you do not perform any actions on the page for some time, you will lose the connection to the execution server. If this happens, you must reload the page and start up the interactive content again. -•- The code is executed using an external service, mybinder.org, so whenever possible avoid sending any sensitive information such as personal information. -(Transmission is encrypted, and interactive content is executed in a separate container for each user on mybinder.org, so the information is not exposed, but it is best to avoid sending any sensitive information just in case.) -Of course, as explained above, the IBM Quantum service token must be sent in order to use the service. +- Since the entire page is treated as a single program, the values of variables defined in a cell are carried over into other cells until the "restart" button is pressed. +- If you do not perform any actions on the page for some time, the connection to the executing server is lost. If this happens, you must reload the page and start up the interactive content again. +- The code is executed using an external service called mybinder.org, therefore, you should avoid sending any sensitive information such as personal information whenever possible (since the communication is encrypted and individual user programs are executed in a separate container on mybinder.org, the information is somewhat protected, but it is the best practice to avoid sending any sensitive information). However, as explained above, the service token of IBM Quantum needs to be sent to use the service. ### Jupyter Notebook -インタラクティブHTMLのセキュリティの問題が気になったり、編集したコードを保存したいと考えたりする場合は、ページの元になったノートブックファイルをダウンロードし、自分のローカルの環境で実行することもできます。右上ののメニューの.ipynbをクリックするか、もしくはのメニューのrepositoryからリンクされているgithubレポジトリをクローンしてください。 -If you are concerned about security issues with interactive HTML, or if you would like to save code that you have modified, you can download the notebook file that each page is based on and execute the code in a local environment. From the menu at top right, click .ipynb, or in the menu click on repository to clone the GitHub repository. +If you are concerned about the security of interactive HTML or you want to save codes that you have modified, you can download the original notebook file from each page and execute the codes in a local environment. Click .ipynb from the menu of at the top-right, or make a clone of GitHub repository linked from repository of the menu of . + +Python version 3.8 or above is required to execute the notebook locally. You need to install the following packages using `pip`. -ノートブックをローカルに実行するためには、Pythonバージョン3.8以上が必要です。また、`pip`を使って以下のパッケージをインストールする必要があります。 -Python version 3.8 or above is required to run a notebook locally. You must also use `pip` to install the following packages. ```{code-block} pip install qiskit qiskit-ibm-provider qiskit-ibm-runtime matplotlib pylatexenc tabulate