Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions docs/guides/debug-qiskit-runtime-jobs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "a45a6d9e-de39-4586-8395-a7f580f0e0dc",
"metadata": {},
"outputs": [],
Expand All @@ -114,7 +114,8 @@
"backend = service.least_busy(operational=True, simulator=False)\n",
"\n",
"# Generate a preset pass manager\n",
"# This will be used to convert the abstract circuit to an equivalent Instruction Set Architecture (ISA) circuit.\n",
"# This will be used to convert the abstract circuit to an \n",
"# equivalent Instruction Set Architecture (ISA) circuit.\n",
"pm = generate_preset_pass_manager(backend=backend, optimization_level=0)\n",
"\n",
"# Set the random seed\n",
Expand All @@ -136,7 +137,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "df19af55-897d-4b1f-baf8-fac2641ae87d",
"metadata": {},
"outputs": [
Expand All @@ -154,8 +155,8 @@
"source": [
"def generate_circuit(n_qubits, n_layers):\n",
" r\"\"\"\n",
" A function to generate a pseudo-random a circuit with ``n_qubits`` qubits and\n",
" ``2*n_layers`` entangling layers of the type used in this notebook.\n",
" A function to generate a pseudo-random a circuit with ``n_qubits`` qubits\n",
" and ``2*n_layers`` entangling layers of the type used in this notebook.\n",
" \"\"\"\n",
" # An array of random angles\n",
" angles = [\n",
Expand Down Expand Up @@ -212,7 +213,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "830b1dcc-2669-46cc-bff8-01a96a05c6ab",
"metadata": {},
"outputs": [
Expand All @@ -232,7 +233,8 @@
"# Map the observables to the backend's layout\n",
"isa_obs = [SparsePauliOp(o).apply_layout(isa_qc.layout) for o in obs]\n",
"\n",
"# Initialize the PUBs, which consist of six-qubit circuits with `n_layers` 1, ..., 6\n",
"# Initialize the PUBs, which consist of six-qubit circuits with \n",
"# `n_layers` 1, ..., 6\n",
"all_n_layers = [1, 2, 3, 4, 5, 6]\n",
"\n",
"pubs = [(pm.run(generate_circuit(6, n)), isa_obs) for n in all_n_layers]"
Expand Down Expand Up @@ -326,7 +328,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "23859a99-2455-460e-98ea-17b36ea59c36",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -377,7 +379,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "cd61e437-bd2f-4349-a667-7edab51c4a6e",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -425,7 +427,8 @@
" # Print the mean absolute difference for the observables\n",
" mean_vals = np.round(np.mean(vals), 2)\n",
" print(\n",
" f\"Mean absolute difference between ideal and noisy results for circuits with {all_n_layers[idx]} layers:\\n {mean_vals}%\\n\"\n",
" f\"Mean absolute difference between ideal and noisy results\"\n",
" f\" for circuits with {all_n_layers[idx]} layers:\\n {mean_vals}%\\n\"\n",
" )"
]
},
Expand Down Expand Up @@ -453,7 +456,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "0835c562-55c9-4dbe-879e-7271f8bed280",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -508,7 +511,8 @@
" # Print the mean absolute difference for the observables\n",
" mean_values = np.round(np.mean(values), 2)\n",
" print(\n",
" f\"Mean absolute difference between ideal and noisy results for circuits with {all_n_layers[idx]} layers:\\n {mean_values}%\\n\"\n",
" f\"Mean absolute difference between ideal and noisy results\"\n",
" f\"for circuits with {all_n_layers[idx]} layers:\\n {mean_values}%\\n\"\n",
" )"
]
},
Expand Down Expand Up @@ -599,7 +603,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"id": "7db531a1-c417-4d5b-bdc3-7a4ad3385fd4",
"metadata": {},
"outputs": [
Expand All @@ -626,11 +630,13 @@
}
],
"source": [
"# Look at the mean absolute difference to quickly tell the best choice for your options\n",
"# Look at the mean absolute difference to quickly tell \n",
"# the best choice for your options\n",
"for factors, res in zip(noise_factors, results):\n",
" d = rdiff(ideal_results[0], res[0])\n",
" print(\n",
" f\"Mean absolute difference for factors {factors}:\\n {np.round(np.mean(d), 2)}%\\n\"\n",
" f\"Mean absolute difference for factors\"\n",
" f\" {factors}:\\n {np.round(np.mean(d), 2)}%\\n\"\n",
" )"
]
},
Expand Down
17 changes: 12 additions & 5 deletions docs/guides/function-template-chemistry-workflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,18 @@
"serverless = QiskitServerless(\n",
" channel=\"ibm_quantum_platform\",\n",
" instance=\"INSTANCE_CRN\",\n",
" token=\"YOUR_API_KEY\" # Use the 44-character API_KEY you created and saved from the IBM Quantum Platform Home dashboard\n",
" token=\"YOUR_API_KEY\" # Use the 44-character API_KEY you created and \n",
" # saved from the IBM Quantum Platform Home dashboard.\n",
")\n",
"```\n",
"\n",
"Optionally, use `save_account()` to save your credentials in a local environment (see the [Set up your IBM Cloud account](/docs/guides/cloud-setup#cloud-save) guide). Note that this writes your credentials to the same file as [`QiskitRuntimeService.save_account()`](/docs/api/qiskit-ibm-runtime/qiskit-runtime-service#save_account):\n",
"\n",
"```python\n",
"QiskitServerless.save_account(token=\"YOUR_API_KEY\", channel=\"ibm_quantum_platform\", instance=\"INSTANCE_CRN\")\n",
"QiskitServerless.save_account(\n",
" token=\"YOUR_API_KEY\",\n",
" channel=\"ibm_quantum_platform\",\n",
" instance=\"INSTANCE_CRN\")\n",
"```\n",
"\n",
"If the [account is saved](/docs/guides/save-credentials), there is no need to provide the token to authenticate:"
Expand Down Expand Up @@ -222,7 +226,8 @@
"template = QiskitFunction(\n",
" title=\"sqd_pcm_template\",\n",
" entrypoint=\"sqd_pcm_entrypoint.py\",\n",
" working_dir=\"./source_files/\", # all files in this directory will be uploaded\n",
" working_dir=\"./source_files/\", \n",
" # all files in this directory will be uploaded\n",
" dependencies=[\n",
" \"ffsim==0.0.54\",\n",
" \"pyscf==2.9.0\",\n",
Expand Down Expand Up @@ -344,7 +349,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "a1719ab1",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -373,7 +378,9 @@
"}\n",
"\n",
"solvent_options = {\n",
" \"method\": \"IEF-PCM\", # other available methods are COSMO, C-PCM, SS(V)PE, see https://manual.q-chem.com/5.4/topic_pcm-em.html\n",
" \"method\": \"IEF-PCM\", \n",
" # Other available methods are COSMO, C-PCM and SS(V)PE.\n",
" # see https://manual.q-chem.com/5.4/topic_pcm-em.html for more details\n",
" \"eps\": 78.3553, # value for water\n",
"}\n",
"\n",
Expand Down
18 changes: 14 additions & 4 deletions docs/guides/install-c-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ int main(int argc, char *argv[]) {

// add the term 2 * (X0 Y1 Z2) to the observable
QkComplex64 coeff = {2, 0};
QkBitTerm bit_terms[3] = {QkBitTerm_X, QkBitTerm_Y, QkBitTerm_Z}; // bit terms: X Y Z
QkBitTerm bit_terms[3] = {QkBitTerm_X, QkBitTerm_Y, QkBitTerm_Z};
// bit terms: X Y Z
uint32_t indices[3] = {0, 1, 2}; // indices: 0 1 2
QkObsTerm term = {coeff, 3, bit_terms, indices, num_qubits};
qk_obs_add_term(obs, &term); // append the term
Expand Down Expand Up @@ -83,7 +84,8 @@ include `/path/to/dist/c/lib`. If the Python library is not available per defaul
this also needs to be added. These commands depend on the platform. On Linux:
```bash
export LD_LIBRARY_PATH=/path/to/dist/c/lib:$LD_LIBRARY_PATH
# on Linux, the Python library is typically included in the dynamic library path per default
# On Linux, the Python library is typically included
# in the dynamic library path by default.
export LD_LIBRARY_PATH=/path/to/python/lib:$LD_LIBRARY_PATH
```
On MacOS:
Expand All @@ -108,7 +110,11 @@ which, if using the example snippet shown previously, should print
```
num_qubits: 100
num_terms: 1
observable: SparseObservable { num_qubits: 100, coeffs: [Complex { re: 2.0, im: 0.0 }], bit_terms: [X, Y, Z], indices: [0, 1, 2], boundaries: [0, 3] }
observable: SparseObservable { num_qubits: 100,
coeffs: [Complex { re: 2.0, im: 0.0 }],
bit_terms: [X, Y, Z],
indices: [0, 1, 2],
boundaries: [0, 3] }
```

## Windows
Expand Down Expand Up @@ -154,5 +160,9 @@ should then print
```
num_qubits: 100
num_terms: 1
observable: SparseObservable { num_qubits: 100, coeffs: [Complex { re: 2.0, im: 0.0 }], bit_terms: [X, Y, Z], indices: [0, 1, 2], boundaries: [0, 3] }
observable: SparseObservable { num_qubits: 100,
coeffs: [Complex { re: 2.0, im: 0.0 }],
bit_terms: [X, Y, Z],
indices: [0, 1, 2],
boundaries: [0, 3] }
```
Loading