|
54 | 54 | "source": [ |
55 | 55 | "To extract machine-learning features from our dataset, we will need to configure a feature extractor. This library provides several feature extractors to either make use of a physical quantum device (QPU), or a variety of emulators.\n", |
56 | 56 | "\n", |
57 | | - "To configure a feature extractor, we will need to give it a _compiler_, whose task is to take a list of graphs, extract embeddings and compile these embeddings to _sequences of pulses_, the format that can be executed by either a QPU or an emulator. For this tutorial, our dataset is composed of molecule graphs, so we will use the `MoleculeGraphCompiler`:" |
| 57 | + "To configure a feature extractor, we will need to give it a _compiler_, whose task is to take a list of graphs, extract embeddings and compile these embeddings to _sequences of pulses_, the format that can be executed by either a QPU or an emulator. For this tutorial, our dataset is composed of molecule graphs encoded with the PTC-FM conventions, so we will use the `PTCFMGraphCompiler`:" |
58 | 58 | ] |
59 | 59 | }, |
60 | 60 | { |
|
65 | 65 | "source": [ |
66 | 66 | "import qek.data.graphs as qek_graphs\n", |
67 | 67 | "\n", |
68 | | - "compiler = qek_graphs.MoleculeGraphCompiler()" |
| 68 | + "compiler = qek_graphs.PTCFMCompiler()" |
69 | 69 | ] |
70 | 70 | }, |
71 | 71 | { |
72 | 72 | "cell_type": "markdown", |
73 | 73 | "metadata": {}, |
74 | 74 | "source": [ |
75 | | - "This library provides other compilers from other formats of graphs." |
| 75 | + "This library provides other compilers from other formats of graphs, including the `MoleculeGraphCompiler` and general-purpose graph compilers for pytorch_geometric or networkx graphs." |
76 | 76 | ] |
77 | 77 | }, |
78 | 78 | { |
|
126 | 126 | "# You can increase this value to higher number of qubits, but this\n", |
127 | 127 | "# notebook will take longer to execute and may run out of memory.\n", |
128 | 128 | "max_qubits = 5\n", |
129 | | - "processed_dataset = await extractor.run(max_qubits=max_qubits) # Don't forget to `await`!\n", |
130 | | - "display(\"Extracted features from %s samples\"% (len(processed_dataset), ))" |
| 129 | + "processed_dataset = extractor.run(max_qubits=max_qubits)\n", |
| 130 | + "display(\"Extracted features from %s samples\"% (len(processed_dataset.states), ))" |
131 | 131 | ] |
132 | 132 | }, |
133 | 133 | { |
|
159 | 159 | "HAVE_PASQAL_ACCOUNT = False # If you have a PASQAL Cloud account, fill in the details and set this to `True`.\n", |
160 | 160 | "\n", |
161 | 161 | "if HAVE_PASQAL_ACCOUNT:\n", |
162 | | - " processed_dataset = []\n", |
163 | | - "\n", |
164 | 162 | " # Use the QPU Extractor.\n", |
165 | 163 | " extractor = qek_extractors.QPUExtractor(\n", |
166 | 164 | " # Once computing is complete, data will be saved in this file.\n", |
|
179 | 177 | " display(\"Compiled %s sequences\" % (len(compiled), ))\n", |
180 | 178 | "\n", |
181 | 179 | " # Launch the execution.\n", |
182 | | - " execution = extractor.run()\n", |
183 | | - " display(\"Work enqueued with ids %s\" % (extractor.batch_ids, ))\n", |
| 180 | + " processed_dataset = extractor.run()\n", |
| 181 | + " display(\"Work enqueued with ids %s\" % (processed_dataset.batch_ids, ))\n", |
184 | 182 | "\n", |
185 | 183 | " # ...and wait for the results.\n", |
186 | | - " processed_dataset = await execution\n", |
187 | | - " display(\"Extracted features from %s samples\"% (len(processed_dataset), ))" |
| 184 | + " await processed_dataset\n", |
| 185 | + " display(\"Extracted states from %s samples\"% (len(processed_dataset.states), ))" |
188 | 186 | ] |
189 | 187 | }, |
190 | 188 | { |
|
221 | 219 | "outputs": [], |
222 | 220 | "source": [ |
223 | 221 | "import qek.data.dataset as qek_dataset\n", |
224 | | - "processed_dataset = qek_dataset.load_dataset(file_path=\"ptcfm_processed_dataset.json\")\n", |
| 222 | + "from qek.data.dataset import ProcessedData\n", |
| 223 | + "processed_dataset: list[ProcessedData] = qek_dataset.load_dataset(file_path=\"ptcfm_processed_dataset.json\")\n", |
225 | 224 | "print(f\"Size of the quantum compatible dataset = {len(processed_dataset)}\")" |
226 | 225 | ] |
227 | 226 | }, |
|
0 commit comments