Skip to content

Commit bfa8f67

Browse files
authored
Let's make the doc generation work - resolves #76. (#78)
* [Doc] Use absolute links in README.md Since README.md is copied to pypi.org, relative links won't make it. * [Doc] Uploading the documentation is good, but generating it is fine step, too. * [Cleanup] Move utils with other utilities * [CI] Let's not forget to install mkapi
1 parent e198df0 commit bfa8f67

22 files changed

Lines changed: 173 additions & 24 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ model.fit(X_train, y_train)
8080

8181
We have a two parts tutorial:
8282

83-
1. [Using a Quantum Device to extract machine-learning features](examples/tutorial%201%20-%20Using%20a%20Quantum%20Device%20to%20Extract%20Machine-Learning%20Features.ipynb);
84-
2. [Machine Learning with the Quantum Evolution Kernel](examples/tutorial%202%20-%20Machine-Learning%20with%20the%20Quantum%20EvolutionKernel.ipynb)
83+
1. [Using a Quantum Device to extract machine-learning features](https://github.com/pasqal-io/quantum-evolution-kernel/blob/main/examples/tutorial%201%20-%20Using%20a%20Quantum%20Device%20to%20Extract%20Machine-Learning%20Features.ipynb);
84+
2. [Machine Learning with the Quantum Evolution Kernel](https://github.com/pasqal-io/quantum-evolution-kernel/blob/main/examples/tutorial%202%20-%20Machine-Learning%20with%20the%20Quantum%20EvolutionKernel.ipynb)
8585

8686
See also the [full API documentation](https://pasqal-io.github.io/quantum-evolution-kernel/latest/).
8787

docs/LICENSE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
PASQAL OPEN-SOURCE SOFTWARE LICENSE AGREEMENT (MIT-derived)
2+
3+
The author of the License is:
4+
Pasqal, a Société par Actions Simplifiée (Simplified Joint Stock Company) registered under number 849 441 522 at the Registre du commerce et des sociétés (Trade and Companies Register) of Evry – France, headquartered at 24 rue Émile Baudot – 91120 – Palaiseau – France, duly represented by its Président, M. Georges-Olivier REYMOND, Hereafter referred to as « the Licensor »
5+
6+
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software (the “Licensee”) and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The Software is “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise arising from, out of or in connection with the Software or the use or other dealings in the Software.
8+
9+
- If use of the Software leads to the necessary use of any patent of the Licensor and/or any of its Affiliates (defined as a company owned or controlled by the Licensor), the Licensee is granted a royalty-free license, in any country where such patent is in force, to use the object of such patent; or use the process covered by such patent,
10+
11+
- Such a patent license is granted for internal research or academic use of the Licensee's, which includes use by employees and students of the Licensee, acting on behalf of the Licensee, for research purposes only.
12+
13+
- The License is governed by the laws of France. Any dispute relating to the License, notably its execution, performance and/or termination shall be brought to, heard and tried by the Tribunal Judiciaire de Paris, regardless of the rules of jurisdiction in the matter.

docs/index.md

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,91 @@
11
# "Quantum Evolution Kernel"
22
## Installation
3-
Installation guidelines
3+
### Using `hatch`, `uv` or any pyproject-compatible Python manager
4+
5+
Edit file `pyproject.toml` to add the line
6+
7+
```toml
8+
"quantum-evolution-kernel"
9+
```
10+
11+
to the list of `dependencies`.
12+
13+
### Using `pip` or `pipx`
14+
To install the `pipy` package using `pip` or `pipx`
15+
16+
1. Create a `venv` if that's not done yet
17+
18+
```sh
19+
$ python -m venv venv
20+
21+
```
22+
23+
2. Enter the venv
24+
25+
```sh
26+
$ . venv/bin/activate
27+
```
28+
29+
3. Install the package
30+
31+
```sh
32+
$ pip install quantum-evolution-kernel
33+
# or
34+
$ pipx install quantum-evolution-kernel
35+
```
436

537
## Usage
6-
Usage guidelines
38+
39+
```python
40+
# Load a dataset
41+
import torch_geometric.datasets as pyg_dataset
42+
og_ptcfm = pyg_dataset.TUDataset(root="dataset", name="PTC_FM")
43+
44+
# Setup a quantum feature extractor for this dataset.
45+
# In this example, we'll use QutipExtractor, to emulate a Quantum Device on our machine.
46+
import qek.data.graphs as qek_graphs
47+
import qek.data.extractors as qek_extractors
48+
extractor = qek_extractors.QutipExtractor(compiler=qek_graphs.PTCFMCompiler())
49+
50+
# Add the graphs, compile them and look at the results.
51+
extractor.add_graphs(graphs=og_ptcfm)
52+
extractor.compile()
53+
processed_dataset = extractor.run().processed_data
54+
55+
# Prepare a machine learning pipeline with Scikit Learn.
56+
from sklearn.model_selection import train_test_split
57+
from sklearn.svm import SVC
58+
59+
X = [data for data in processed_dataset] # Features
60+
y = [data.target for data in processed_dataset] # Targets
61+
X_train, X_test, y_train, y_test = train_test_split(X, y, stratify = y, test_size=0.2, random_state=42)
62+
63+
# Train a kernel
64+
from qek.kernel import QuantumEvolutionKernel as QEK
65+
kernel = QEK(mu=0.5)
66+
model = SVC(kernel=kernel, random_state=42)
67+
model.fit(X_train, y_train)
68+
```
769

870
## Documentation
9-
Documentation guidelines
71+
72+
::: qek
73+
74+
## Tutorials
75+
76+
We have a two parts tutorial:
77+
78+
1. [Using a Quantum Device to extract machine-learning features](https://github.com/pasqal-io/quantum-evolution-kernel/blob/main/examples/tutorial%201%20-%20Using%20a%20Quantum%20Device%20to%20Extract%20Machine-Learning%20Features.ipynb);
79+
2. [Machine Learning with the Quantum Evolution Kernel](https://github.com/pasqal-io/quantum-evolution-kernel/blob/main/examples/tutorial%202%20-%20Machine-Learning%20with%20the%20Quantum%20EvolutionKernel.ipynb)
80+
81+
## Getting in touch
82+
83+
- [Pasqal Community Portal](https://community.pasqal.com/) (forums, chat, tutorials, examples, code library).
84+
- [GitHub Repository](https://github.com/pasqal-io/quantum-evolution-kernel) (source code, issue tracker).
85+
- [Professional Support](https://www.pasqal.com/contact-us/) (if you need tech support, custom licenses, a variant of this library optimized for your workload, your own QPU, remote access to a QPU, ...)
1086

1187
## Contribute
12-
Contribution guidelines
88+
89+
The GitHub repository is open for contributions!
90+
91+
Don't forget to read the [Contributor License Agreement]().

examples/tutorial 1 - Using a Quantum Device to Extract Machine-Learning Features.ipynb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,16 @@
152152
"metadata": {},
153153
"outputs": [],
154154
"source": [
155+
"from pathlib import Path\n",
156+
"\n",
157+
"\n",
155158
"HAVE_PASQAL_ACCOUNT = False # If you have a PASQAL Cloud account, fill in the details and set this to `True`.\n",
156159
"\n",
157160
"if HAVE_PASQAL_ACCOUNT:\n",
158161
" # Use the QPU Extractor.\n",
159162
" extractor = qek_extractors.RemoteQPUExtractor(\n",
160163
" # Once computing is complete, data will be saved in this file.\n",
161-
" path=\"saved_data.json\",\n",
164+
" path=Path(\"saved_data.json\"),\n",
162165
" compiler = compiler,\n",
163166
" project_id = \"XXXX\", # Replace this with your project id on the PASQAL Cloud\n",
164167
" username = \"XXX\", # Replace this with your username on PASQAL Cloud\n",
@@ -216,7 +219,7 @@
216219
"metadata": {},
217220
"outputs": [],
218221
"source": [
219-
"import qek.data.dataset as qek_dataset\n",
222+
"import qek.data.processed_data as qek_dataset\n",
220223
"processed_dataset = qek_dataset.load_dataset(file_path=\"ptcfm_processed_dataset.json\")\n",
221224
"print(f\"Size of the quantum compatible dataset = {len(processed_dataset)}\")"
222225
]

examples/tutorial 1a - Using a Quantum Device to Extract Machine-Learning Features - low-level.ipynb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
"metadata": {},
187187
"outputs": [],
188188
"source": [
189-
"from qek.data.dataset import ProcessedData\n",
189+
"from qek.data.processed_data import ProcessedData\n",
190190
"from qek.backends import QutipBackend\n",
191191
"\n",
192192
"# In this tutorial, to make things faster, we'll only run the sequences that require 5 qubits or less.\n",
@@ -308,7 +308,7 @@
308308
"metadata": {},
309309
"outputs": [],
310310
"source": [
311-
"import qek.data.dataset as qek_dataset\n",
311+
"import qek.data.processed_data as qek_dataset\n",
312312
"processed_dataset = qek_dataset.load_dataset(file_path=\"ptcfm_processed_dataset.json\")\n",
313313
"print(f\"Size of the quantum compatible dataset = {len(processed_dataset)}\")"
314314
]
@@ -333,8 +333,6 @@
333333
"metadata": {},
334334
"outputs": [],
335335
"source": [
336-
"from qek.data.dataset import ProcessedData\n",
337-
"\n",
338336
"# The geometry we compiled from this graph for execution on the Quantum Device.\n",
339337
"dataset_example: ProcessedData = processed_dataset[64]\n",
340338
"dataset_example.draw_register()"

examples/tutorial 2 - Machine-Learning with the Quantum EvolutionKernel.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"metadata": {},
6262
"outputs": [],
6363
"source": [
64-
"import qek.data.dataset as qek_dataset\n",
64+
"import qek.data.processed_data as qek_dataset\n",
6565
"\n",
6666
"# Load the dataset we processed in the quantum extraction tutorial\n",
6767
"processed_dataset = qek_dataset.load_dataset(file_path=\"ptcfm_processed_dataset.json\")\n",

mkdocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ repo_name: "Quantum Evolution Kernel"
44

55
nav:
66
- Overview: index.md
7+
- Reference: $api/qek.***
8+
- License: LICENSE.md
9+
- CLA: CONTRIBUTOR LICENSE AGREEMENT.md
710

811
theme:
912
name: material
@@ -46,6 +49,7 @@ plugins:
4649
- search
4750
- section-index
4851
- markdown-exec
52+
- mkapi
4953
- mkdocstrings:
5054
default_handler: python
5155
handlers:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ dependencies = [
102102
"mkdocstrings-python",
103103
"mkdocs-section-index",
104104
"mkdocs-exclude",
105+
"mkapi",
105106
"markdown-exec",
106107
"mike",
107108
]

qek/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""
2+
The Quantum Evolution Kernel is a Python library designed for the machine learning community to help users design quantum-driven similarity metrics for graphs and to use them inside kernel-based machine learning algorithms for graph data.
3+
4+
The core of the library is focused on the development of a classification algorithm for molecular-graph dataset as it is presented in the published paper [Quantum feature maps for graph machine learning on a neutral atom quantum processor](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.107.042615).
5+
6+
Users setting their first steps into quantum computing will learn how to implement the core algorithm in a few simple steps and run it using the Pasqal Neutral Atom QPU. More experienced users will find this library to provide the right environment to explore new ideas - both in terms of methodologies and data domain - while always interacting with a simple and intuitive QPU interface.
7+
"""

qek/backends.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
Low-level tools to execute compiled registers and pulses onto Quantum Devices, including local emulators, remote emulators and physical QPUs.
3+
"""
4+
15
import abc
26
import asyncio
37
from math import ceil
@@ -13,7 +17,7 @@
1317

1418
from qek.data.extractors import deserialize_device
1519
from qek.shared.error import CompilationError
16-
from qek.utils import make_sequence
20+
from qek.shared._utils import make_sequence
1721

1822

1923
class BaseBackend(abc.ABC):

0 commit comments

Comments
 (0)