qciconnect-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qciconnect_mcp-0.1.0/PKG-INFO +457 -0
- qciconnect_mcp-0.1.0/README.md +439 -0
- qciconnect_mcp-0.1.0/pyproject.toml +109 -0
- qciconnect_mcp-0.1.0/pyproject.toml.orig +107 -0
- qciconnect_mcp-0.1.0/src/qciconnect/mcp/__init__.py +1 -0
- qciconnect_mcp-0.1.0/src/qciconnect/mcp/__main__.py +11 -0
- qciconnect_mcp-0.1.0/src/qciconnect/mcp/config.py +83 -0
- qciconnect_mcp-0.1.0/src/qciconnect/mcp/server.py +423 -0
- qciconnect_mcp-0.1.0/src/qciconnect/mcp/skills/alf-circuits/SKILL.md +212 -0
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qciconnect-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server exposing the DLR QCI Connect quantum computing platform to LLM agents.
|
|
5
|
+
Keywords: quantum computing,QCI Connect SDK,MCP,model context protocol
|
|
6
|
+
Author: DLR-SC, Thomas Keitzl
|
|
7
|
+
Author-email: DLR-SC <qc-software@dlr.de>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Dist: qciconnect-client[socks]>=1.5.0,<2
|
|
13
|
+
Requires-Dist: qciconnect-alf>=0.5.0,<1
|
|
14
|
+
Requires-Dist: mcp>=2.2.0
|
|
15
|
+
Requires-Dist: python-dotenv>=1.0.1
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# qciconnect-mcp
|
|
20
|
+
|
|
21
|
+
A local [MCP](https://modelcontextprotocol.io/) server exposing the [QCI Connect](https://qci.dlr.de/connect/)
|
|
22
|
+
quantum computing platform ([German Aerospace Center, DLR](https://www.dlr.de/)) to LLM agents.
|
|
23
|
+
It is a thin tool layer over the [API Client](https://pypi.org/project/qciconnect-client/) - it
|
|
24
|
+
does not reimplement platform access, and inherits the API Client's per-user auth, so an agent
|
|
25
|
+
using it can only do what your own platform token allows.
|
|
26
|
+
|
|
27
|
+
It is a component of the [QCI Connect SDK](https://pypi.org/project/qciconnect/). It will allow your LLM to answer question like:
|
|
28
|
+
- **Hey Agent, which QPUs are available on the platform?**
|
|
29
|
+
- **Simulate a Bell state locally, 1000 shots**
|
|
30
|
+
- **Simulate a Bell state with the digital twin of XYZ, 1000 shots**
|
|
31
|
+
- **What are `<Z0 Z1>` and `<X0 X1>` on that state?**
|
|
32
|
+
|
|
33
|
+
and see [examples](#examples) for further inspiration.
|
|
34
|
+
|
|
35
|
+
> **Current coverage:** so far the MCP server covers the **API Client**, **ALF** and the
|
|
36
|
+
> **QCI Connect platform** only. Support for **AppLib**, the **Miniserver** and the other SDK
|
|
37
|
+
> components is coming soon.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
`qciconnect-mcp` is a local **stdio MCP server**. Any harness that supports local MCP
|
|
42
|
+
servers can launch it, including Codex, Mistral Vibe, OpenCode and Claude Code. The launch
|
|
43
|
+
command is shared; registration commands and configuration formats depend on the harness.
|
|
44
|
+
|
|
45
|
+
### tl;dr (using `claude` and `uv`)
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
claude mcp add qciconnect-mcp -- uvx qciconnect-mcp
|
|
49
|
+
echo "QCICONNECT_TOKEN=your-token" >> .env
|
|
50
|
+
claude
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Using `uv`
|
|
54
|
+
|
|
55
|
+
Install [uv](https://docs.astral.sh/uv/getting-started/installation/), then register the server
|
|
56
|
+
with your harness using one of the following commands:
|
|
57
|
+
|
|
58
|
+
| Harness | Registration command | Documentation |
|
|
59
|
+
| --- |-------------------------------------------------------------------------------------------------------------------------------------------------------------| --- |
|
|
60
|
+
| Codex | `codex mcp add qciconnect-mcp -- uvx qciconnect-mcp` | [MCP setup](https://developers.openai.com/codex/mcp/) |
|
|
61
|
+
| Mistral Vibe | `vibe mcp add qciconnect-mcp --transport stdio --command "uvx qciconnect-mcp"` | [MCP setup](https://docs.mistral.ai/vibe/code/cli/mcp-servers) |
|
|
62
|
+
| OpenCode (v2) | `opencode mcp add qciconnect-mcp -- uvx qciconnect-mcp` | [MCP setup](https://opencode.ai/docs/mcp-servers) |
|
|
63
|
+
| Claude Code | `claude mcp add qciconnect-mcp -- uvx qciconnect-mcp` | [MCP setup](https://code.claude.com/docs/en/mcp) |
|
|
64
|
+
|
|
65
|
+
`uvx` fetches `qciconnect-mcp` from PyPI into an isolated, cached environment on first start - no
|
|
66
|
+
checkout, no virtual environment to manage. The harness starts the server for you.
|
|
67
|
+
|
|
68
|
+
For another harness or a version with different registration commands, configure a local MCP
|
|
69
|
+
server named `qciconnect-mcp` with executable `uvx` and arguments `["qciconnect-mcp"]`. Use that
|
|
70
|
+
harness's configuration format: there is no universal MCP config file. For example, Codex uses
|
|
71
|
+
TOML, while OpenCode uses JSON/JSONC with a command array.
|
|
72
|
+
|
|
73
|
+
### Using `pip`
|
|
74
|
+
|
|
75
|
+
With Python 3.12 or newer, install into your chosen Python environment:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install qciconnect-mcp
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Register the server in your harness with the absolute path to that environment's
|
|
82
|
+
`qciconnect-mcp` executable and no arguments, replacing `uvx qciconnect-mcp` above. For Vibe,
|
|
83
|
+
set `--command` to that path and omit `--arg`.
|
|
84
|
+
|
|
85
|
+
### Dependencies and local simulation
|
|
86
|
+
|
|
87
|
+
`qciconnect-mcp` requires both `qciconnect-client` for platform access and
|
|
88
|
+
`qciconnect-alf` for `simulate_circuit` and `estimate_observables`. ALF declares its
|
|
89
|
+
simulation dependencies, including Qiskit. A normal `pip install qciconnect-mcp` or
|
|
90
|
+
`uvx qciconnect-mcp` installs these dependencies automatically; no extra is required.
|
|
91
|
+
|
|
92
|
+
If a local tool reports `ModuleNotFoundError: No module named 'qciconnect.alf'`
|
|
93
|
+
(or a missing backend such as `qiskit`), check the Python environment that actually
|
|
94
|
+
runs the MCP server. Installing ALF in your project's environment does not repair
|
|
95
|
+
an isolated `uvx` environment or another harness's configured interpreter.
|
|
96
|
+
For a pip installation, use that server environment's Python executable to check
|
|
97
|
+
and repair the installation:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
python -m pip check
|
|
101
|
+
python -m pip install --upgrade qciconnect-mcp
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Restart the MCP server after repairing its environment. Verify both local tools with
|
|
105
|
+
a circuit without explicit measurements, such as the Bell-state examples below.
|
|
106
|
+
A generic error alone does not establish that ALF is missing: use the exception type
|
|
107
|
+
and message reported by the local tools to distinguish import, parsing, and simulation
|
|
108
|
+
failures. In particular, explicit measurements produce a separate statevector error.
|
|
109
|
+
|
|
110
|
+
### Credentials and first use
|
|
111
|
+
|
|
112
|
+
Create a token at https://connect.qci.dlr.de/Account and put it in a `.env` file in the
|
|
113
|
+
**server's working directory**:
|
|
114
|
+
|
|
115
|
+
```dotenv
|
|
116
|
+
QCICONNECT_TOKEN=your-token
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
When the harness launches the server from your project root, place `.env` there. Otherwise,
|
|
120
|
+
configure the server's working directory or pass `QCICONNECT_TOKEN` through the harness's
|
|
121
|
+
server environment settings. Existing environment variables take precedence over `.env`.
|
|
122
|
+
Keep the token out of version control.
|
|
123
|
+
|
|
124
|
+
Start or restart your chosen harness, check its MCP status/tool list for `qciconnect-mcp`, check if the setup works by asking:
|
|
125
|
+
|
|
126
|
+
> **Which QPUs are available on the platform?**
|
|
127
|
+
|
|
128
|
+
For a credential-free check, ask **Simulate a Bell state locally, 1000 shots**. See
|
|
129
|
+
[Examples](#examples) for more prompts and [Checking the installation](FAQ.md#checking-the-installation)
|
|
130
|
+
for a harness-independent protocol check.
|
|
131
|
+
|
|
132
|
+
To drive a local [miniserver](https://gitlab.com/dlr-sc-qc/qciconnect-sdk/miniserver) instead of
|
|
133
|
+
the production platform, use `QCICONNECT_SERVER=http://127.0.0.1:8000/` instead - a miniserver
|
|
134
|
+
needs no token.
|
|
135
|
+
|
|
136
|
+
Behind a proxy, set the standard proxy variables in the same `.env` (or in your MCP host's
|
|
137
|
+
server environment settings):
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
HTTPS_PROXY=http://user:password@proxy.example.com:3128
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY` and `NO_PROXY` are honoured, including SOCKS proxies
|
|
144
|
+
(`socks5://...`). A local miniserver (`localhost`, `127.0.0.1`) is never sent through the proxy.
|
|
145
|
+
|
|
146
|
+
## Tools
|
|
147
|
+
|
|
148
|
+
Read-only:
|
|
149
|
+
|
|
150
|
+
- `list_qpus` - real quantum hardware, with status, whether you have access, and the platform's
|
|
151
|
+
usage hint where there is one
|
|
152
|
+
- `list_simulators` - statevector simulators and digital twins, same fields
|
|
153
|
+
- `list_apus` - analog processing units
|
|
154
|
+
- `list_compiler_methods` - available compiler passes, as `<pass_alias>_<compiler_alias>` names
|
|
155
|
+
- `list_recent_jobs`, `get_result` - completed jobs and their results
|
|
156
|
+
- `simulate_circuit`, `estimate_observables` - run a circuit on this machine, no platform needed
|
|
157
|
+
|
|
158
|
+
Submitting (annotated as not read-only, so a host's approval prompt can tell them apart):
|
|
159
|
+
|
|
160
|
+
- `submit_qpu_job` - run an OpenQASM circuit on a QPU
|
|
161
|
+
- `submit_apu_job` - compile and/or run code on an analog processing unit
|
|
162
|
+
- `submit_compiler_job` - run circuits through a compiler pass
|
|
163
|
+
|
|
164
|
+
The server also publishes one MCP **resource**, `qci://skills/alf-circuits`, a guide to writing
|
|
165
|
+
idiomatic [ALF](https://gitlab.com/dlr-sc-qc/qciconnect-sdk/alf) that an agent can read on demand.
|
|
166
|
+
Reading it requires a harness with MCP resource support; see the [FAQ](FAQ.md) to install it
|
|
167
|
+
as a skill instead.
|
|
168
|
+
|
|
169
|
+
## Examples
|
|
170
|
+
|
|
171
|
+
You do not call these tools yourself - you ask the agent for the thing you want, and it picks the
|
|
172
|
+
tool. The exchanges below are illustrative and, unless noted, run against a local
|
|
173
|
+
[miniserver](https://gitlab.com/dlr-sc-qc/qciconnect-sdk/miniserver) started with the example
|
|
174
|
+
compilers and the bundled Qiskit Aer simulator:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
uv run miniserver -c compilers # in a miniserver checkout; needs Docker
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Listing the compilers
|
|
181
|
+
|
|
182
|
+
> **List all available compilers**
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
┌─────────────────────┬─────────────────────────────┬──────────────┬────────────────────────────────────────────────────────────────┐
|
|
186
|
+
│ Method name │ Compiler │ Pass │ What it does │
|
|
187
|
+
├─────────────────────┼─────────────────────────────┼──────────────┼────────────────────────────────────────────────────────────────┤
|
|
188
|
+
│ zne_mitiq_compiler │ Mitiq Compiler (Unitary │ ZNE │ Zero Noise Extrapolation as implemented by the mitiq library │
|
|
189
|
+
│ │ Foundation) │ │ │
|
|
190
|
+
├─────────────────────┼─────────────────────────────┼──────────────┼────────────────────────────────────────────────────────────────┤
|
|
191
|
+
│ optimization_qronos │ Qronos (Linus Scholz) │ Optimization │ Compilation and optimization of Clifford circuits │
|
|
192
|
+
├─────────────────────┼─────────────────────────────┼──────────────┼────────────────────────────────────────────────────────────────┤
|
|
193
|
+
│ pyqsp_qsp │ QSP (Team Biber) │ pyqsp │ Quantum Signal Processes the given block encoding according to │
|
|
194
|
+
│ │ │ │ a provided polynomial │
|
|
195
|
+
├─────────────────────┼─────────────────────────────┼──────────────┼────────────────────────────────────────────────────────────────┤
|
|
196
|
+
│ exactoddqsp_qsp │ QSP (Team Biber) │ exactoddqsp │ Exact QSP angles for odd monomials │
|
|
197
|
+
└─────────────────────┴─────────────────────────────┴──────────────┴────────────────────────────────────────────────────────────────┘
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
*Calls `list_compiler_methods`.* The method name is `<pass_alias>_<compiler_alias>`, both halves
|
|
201
|
+
lowercased with spaces and hyphens turned into underscores. The compiler half comes from the
|
|
202
|
+
compiler's *name*, not from the `compiler_alias` field of its description - which is why "Mitiq
|
|
203
|
+
Compiler" yields `mitiq_compiler`.
|
|
204
|
+
|
|
205
|
+
### Listing the devices
|
|
206
|
+
|
|
207
|
+
> **Which QPUs can I use?**
|
|
208
|
+
|
|
209
|
+
Against the production platform, rather than the miniserver the other examples use:
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
┌────────────────┬────────┬───────────────────┬─────────────┐
|
|
213
|
+
│ Alias │ Qubits │ Technology │ Status │
|
|
214
|
+
├────────────────┼────────┼───────────────────┼─────────────┤
|
|
215
|
+
│ kratos_xaphiro │ 24 │ other │ IDLE │
|
|
216
|
+
│ xq2i │ 8 │ vacancy_centres │ IDLE │
|
|
217
|
+
│ saxonq_4qb_rt │ 3 │ vacancy_centres │ CALIBRATION │
|
|
218
|
+
│ xq1i │ 4 │ vacancy_centres │ CALIBRATION │
|
|
219
|
+
│ qsea_i │ 4 │ trapped_ions │ OFFLINE │
|
|
220
|
+
│ carina │ 4 │ photons │ COMING_SOON │
|
|
221
|
+
│ comiqc │ 50 │ solid_state_spins │ COMING_SOON │
|
|
222
|
+
│ dedalo │ 64 │ photons │ COMING_SOON │
|
|
223
|
+
│ dinaqc │ 100 │ neutral_atoms │ COMING_SOON │
|
|
224
|
+
│ legato │ 20 │ trapped_ions │ COMING_SOON │
|
|
225
|
+
│ qsea_ii │ 20 │ trapped_ions │ COMING_SOON │
|
|
226
|
+
│ redac │ 8 │ analogue_computer │ COMING_SOON │
|
|
227
|
+
│ sunqc │ 8 │ vacancy_centres │ COMING_SOON │
|
|
228
|
+
│ toccata │ 50 │ trapped_ions │ COMING_SOON │
|
|
229
|
+
│ xaphiro │ 50 │ trapped_ions │ COMING_SOON │
|
|
230
|
+
└────────────────┴────────┴───────────────────┴─────────────┘
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
*Calls `list_qpus`.* Real hardware only - ask for simulators and you get `list_simulators` instead,
|
|
234
|
+
which covers the statevector simulators and the digital twins (`statevector_simulator`,
|
|
235
|
+
`kratos_aer`, `qsea_i_digital_twin` and friends). The split is on the platform's own `technology`
|
|
236
|
+
field, so a device labelled `other` counts as hardware. Both lists are submitted to the same way,
|
|
237
|
+
through `submit_qpu_job`, and both also report `access_for_current_user`, which is what decides
|
|
238
|
+
whether you can actually use a row. `list_apus` does the same for analog processing units. A local
|
|
239
|
+
miniserver only offers what you started it with, which is usually a single simulator.
|
|
240
|
+
|
|
241
|
+
### Running a circuit
|
|
242
|
+
|
|
243
|
+
> **Run a Bell state on the Aer simulator with 1000 shots**
|
|
244
|
+
|
|
245
|
+
The agent writes the circuit, submits it, and waits for the result:
|
|
246
|
+
|
|
247
|
+
```
|
|
248
|
+
Submitted to qiskit_aer_simulator (sampling, 1000 shots) - finished.
|
|
249
|
+
|
|
250
|
+
┌─────────┬───────┬───────────┐
|
|
251
|
+
│ Outcome │ Count │ Frequency │
|
|
252
|
+
├─────────┼───────┼───────────┤
|
|
253
|
+
│ 00 │ 503 │ 50.3% │
|
|
254
|
+
├─────────┼───────┼───────────┤
|
|
255
|
+
│ 11 │ 497 │ 49.7% │
|
|
256
|
+
└─────────┴───────┴───────────┘
|
|
257
|
+
|
|
258
|
+
Only 00 and 11 appear, as expected for a Bell pair - the two qubits are perfectly correlated.
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
*Calls `submit_qpu_job`.* This runs a real job and may consume QPU time or HPC allocation, so your
|
|
262
|
+
host should prompt for approval first - the tool is annotated as not read-only precisely so that
|
|
263
|
+
prompt can tell it apart from the listing tools. Shots default to 10000 if you do not say;
|
|
264
|
+
QPUs on an HPC system also need a cost bearer, which the agent will ask you for.
|
|
265
|
+
|
|
266
|
+
### Simulating without a platform
|
|
267
|
+
|
|
268
|
+
> **`Simulate a Bell state locally, 1000 shots`**
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
Simulated on this machine - no platform involved.
|
|
272
|
+
|
|
273
|
+
┌─────────┬───────┬───────────┐
|
|
274
|
+
│ Outcome │ Count │ Frequency │
|
|
275
|
+
├─────────┼───────┼───────────┤
|
|
276
|
+
│ 00 │ 503 │ 50.3% │
|
|
277
|
+
├─────────┼───────┼───────────┤
|
|
278
|
+
│ 11 │ 497 │ 49.7% │
|
|
279
|
+
└─────────┴───────┴───────────┘
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
*Calls `simulate_circuit`.* This one runs through ALF's local statevector simulator, so it needs no
|
|
283
|
+
token, no miniserver and no Docker - useful for checking a circuit before spending QPU time on it.
|
|
284
|
+
It samples all qubits from the final state. Explicit measurement statements (register-wide or
|
|
285
|
+
individual) are unsupported by the local statevector backend; for final-state sampling, provide
|
|
286
|
+
a circuit without measurements. Both local tools report failures with the underlying exception
|
|
287
|
+
type and message, including parsing and missing-dependency errors.
|
|
288
|
+
`estimate_observables` is the same idea for expectation values, taking Pauli strings in ALF's form:
|
|
289
|
+
|
|
290
|
+
> **What are <Z0 Z1> and <X0 X1> on that state?**
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
Z0 Z1 -> 1.0
|
|
294
|
+
X0 X1 -> 1.0
|
|
295
|
+
|
|
296
|
+
Both correlators are +1, which is the signature of a Bell pair.
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Building a circuit with ALF's algebra
|
|
300
|
+
|
|
301
|
+
> **Build a GHZ state on 4 qubits with ALF and simulate it**
|
|
302
|
+
|
|
303
|
+
```python
|
|
304
|
+
from qciconnect.alf.circuit import Circuit, H, CX
|
|
305
|
+
|
|
306
|
+
ghz = Circuit(name="ghz", width=4)
|
|
307
|
+
ghz += H(0)
|
|
308
|
+
for q in range(3):
|
|
309
|
+
ghz += CX(q, q + 1)
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
┌──────────┬───────┬───────────┐
|
|
314
|
+
│ Outcome │ Count │ Frequency │
|
|
315
|
+
├──────────┼───────┼───────────┤
|
|
316
|
+
│ 0000 │ 503 │ 50.3% │
|
|
317
|
+
├──────────┼───────┼───────────┤
|
|
318
|
+
│ 1111 │ 497 │ 49.7% │
|
|
319
|
+
└──────────┴───────┴───────────┘
|
|
320
|
+
|
|
321
|
+
All four qubits agree every shot - nothing in between, as a GHZ state should be.
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
*Reads `qci://skills/alf-circuits`, then calls `simulate_circuit`.* The skill is what keeps the
|
|
325
|
+
generated code idiomatic: `+=` to append, `width=` by keyword, and the parameter-before-qubit order
|
|
326
|
+
that parameterised gates use (`RX(0.5, 0)`, not `RX(0, 0.5)`).
|
|
327
|
+
|
|
328
|
+
### Checking a circuit undoes itself
|
|
329
|
+
|
|
330
|
+
> **Apply that two-qubit block five times, then invert the whole thing. Do I get the identity back?**
|
|
331
|
+
|
|
332
|
+
```python
|
|
333
|
+
from qciconnect.alf.circuit import RX, RZ
|
|
334
|
+
|
|
335
|
+
block = Circuit(name="block", width=2)
|
|
336
|
+
block += RX(0.3, 0)
|
|
337
|
+
block += CX(0, 1)
|
|
338
|
+
block += RZ(0.7, 1)
|
|
339
|
+
|
|
340
|
+
loop = block.repeat(5)
|
|
341
|
+
echo = loop.composed(loop.dagger())
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
```
|
|
345
|
+
Counts: {'00': 1000} - every shot returns to the start.
|
|
346
|
+
echo.is_equivalent_to(Circuit(name="id", width=2)) -> True
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
*Calls `simulate_circuit`.* `repeat`, `dagger` and `composed` each return a **new** circuit. Their
|
|
350
|
+
in-place counterparts are the trap: `compose` mutates the receiver and returns `None`, so
|
|
351
|
+
`tail = circuit.compose(other)` silently binds `None`. The skill has the full table.
|
|
352
|
+
|
|
353
|
+
### Stacking error mitigation
|
|
354
|
+
|
|
355
|
+
> **Wrap the local sampler in a readout-mitigation pass**
|
|
356
|
+
|
|
357
|
+
```python
|
|
358
|
+
from qciconnect.alf.mitigation import AbstractSimpleMitigationSampler
|
|
359
|
+
from qciconnect.alf.execution import LocalSampler
|
|
360
|
+
from qciconnect.alf.circuit import X
|
|
361
|
+
|
|
362
|
+
class FlipReadout(AbstractSimpleMitigationSampler):
|
|
363
|
+
def _adapt_circuit(self, circuit):
|
|
364
|
+
return {"plain": circuit, "flipped": circuit + X(0)}
|
|
365
|
+
|
|
366
|
+
def _mitigate_samplesets(self, samplesets):
|
|
367
|
+
return samplesets["plain"]
|
|
368
|
+
|
|
369
|
+
sampler = FlipReadout(None) >> LocalSampler()
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
*No tool call - this is the skill doing the work.* `>>` stacks mitigation samplers: circuits flow
|
|
373
|
+
left to right to the right-most one, which talks to the backend, and results are post-processed right
|
|
374
|
+
to left. It is defined only on the mitigation base classes: `TrivialSampler() >>
|
|
375
|
+
LocalSampler()` is a `TypeError`. On a `PauliString` the same operator shifts qubit indices
|
|
376
|
+
instead (`PauliString.from_string("X0Z1") >> 2` gives `X2Z3`).
|
|
377
|
+
|
|
378
|
+
### Compiling a circuit
|
|
379
|
+
|
|
380
|
+
> **Optimize this circuit with Qronos**
|
|
381
|
+
>
|
|
382
|
+
> ```
|
|
383
|
+
> OPENQASM 3.0;
|
|
384
|
+
> include "stdgates.inc";
|
|
385
|
+
> qubit[2] q;
|
|
386
|
+
> h q[0];
|
|
387
|
+
> cx q[0], q[1];
|
|
388
|
+
> s q[1];
|
|
389
|
+
> s q[1];
|
|
390
|
+
> ```
|
|
391
|
+
|
|
392
|
+
```
|
|
393
|
+
Compiled with optimization_qronos - finished.
|
|
394
|
+
|
|
395
|
+
OPENQASM 3.0;
|
|
396
|
+
include "stdgates.inc";
|
|
397
|
+
qubit[2] q;
|
|
398
|
+
h q[0];
|
|
399
|
+
cx q[0], q[1];
|
|
400
|
+
z q[1];
|
|
401
|
+
|
|
402
|
+
The two S gates were merged into a single Z.
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
*Calls `submit_compiler_job`.* One call can carry several named circuits at once, so "compile these
|
|
406
|
+
three variants" is a single job. Pass-specific settings (`options`) are filled in by the agent from
|
|
407
|
+
what you ask for.
|
|
408
|
+
|
|
409
|
+
### Looking up earlier work
|
|
410
|
+
|
|
411
|
+
> **What have I run recently?**
|
|
412
|
+
|
|
413
|
+
```
|
|
414
|
+
┌──────────────────────────────────────┬────────────────────────────────┬──────────┐
|
|
415
|
+
│ Job ID │ Type │ Status │
|
|
416
|
+
├──────────────────────────────────────┼────────────────────────────────┼──────────┤
|
|
417
|
+
│ 01234567-89ab-cdef-0123-456789abcdef │ QPU (qiskit_aer_simulator) │ finished │
|
|
418
|
+
├──────────────────────────────────────┼────────────────────────────────┼──────────┤
|
|
419
|
+
│ fedcba98-7654-3210-fedc-ba9876543210 │ Compiler (optimization_qronos) │ finished │
|
|
420
|
+
└──────────────────────────────────────┴────────────────────────────────┴──────────┘
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
> **Show me the counts from the first one**
|
|
424
|
+
|
|
425
|
+
```
|
|
426
|
+
┌─────────┬───────┬───────────┐
|
|
427
|
+
│ Outcome │ Count │ Frequency │
|
|
428
|
+
├─────────┼───────┼───────────┤
|
|
429
|
+
│ 00 │ 503 │ 50.3% │
|
|
430
|
+
├─────────┼───────┼───────────┤
|
|
431
|
+
│ 11 │ 497 │ 49.7% │
|
|
432
|
+
└─────────┴───────┴───────────┘
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
*Calls `list_recent_jobs`, then `get_result`.* Only successfully completed jobs show up here -
|
|
436
|
+
failed and running ones are not listed. For a job you just submitted in the same conversation the
|
|
437
|
+
agent already has the result and will not look it up again.
|
|
438
|
+
|
|
439
|
+
## Scope
|
|
440
|
+
|
|
441
|
+
v1 wraps the API Client's public surface, as listed above. Submitting a job is a real, potentially
|
|
442
|
+
billable action on the platform - qciconnect-mcp relies on your MCP host's own tool-approval prompt
|
|
443
|
+
before running one, rather than adding a confirmation step of its own.
|
|
444
|
+
|
|
445
|
+
`simulate_circuit` and `estimate_observables` are the exception to the "thin layer" rule: they use
|
|
446
|
+
[ALF](https://gitlab.com/dlr-sc-qc/qciconnect-sdk/alf)'s local statevector simulator rather than the
|
|
447
|
+
platform, so they work with no credentials, no miniserver and no Docker. Everything else still goes
|
|
448
|
+
through the API client.
|
|
449
|
+
|
|
450
|
+
AppLib, the Miniserver and the other SDK components are not covered yet - support is coming soon.
|
|
451
|
+
Until then, running named AppLib algorithms (VQE, QAOA, time evolution) rather than raw circuits is
|
|
452
|
+
out of scope.
|
|
453
|
+
|
|
454
|
+
## Questions
|
|
455
|
+
|
|
456
|
+
Anything else, check the [FAQ](FAQ.md) - or write to
|
|
457
|
+
[qc-software@dlr.de](mailto:qc-software@dlr.de).
|