Skip to content

Commit 6c3184c

Browse files
committed
Adds devices for CUDA-Q and Qsim backends.
1 parent 1004b5f commit 6c3184c

File tree

3 files changed

+175
-1
lines changed

3 files changed

+175
-1
lines changed

pennylane_scaleway/cudaq_device.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Copyright 2026 Scaleway
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from pennylane.devices.modifiers import simulator_tracking, single_tape_support
16+
17+
from qiskit_scaleway.backends import CudaqBackend
18+
19+
from pennylane_scaleway.scw_device import ScalewayDevice
20+
21+
22+
@simulator_tracking # update device.tracker with some relevant information
23+
@single_tape_support # add support for device.execute(tape) in addition to device.execute((tape,))
24+
class CudaqDevice(ScalewayDevice):
25+
"""
26+
Scaleway's device to run Pennylane circuits on CUDA-Q backends.
27+
"""
28+
29+
name = "scaleway.cudaq"
30+
backend_type = CudaqBackend
31+
32+
# operations = set(QISKIT_OPERATION_MAP.keys())
33+
# observables = {
34+
# "PauliX",
35+
# "PauliY",
36+
# "PauliZ",
37+
# "Identity",
38+
# "Hadamard",
39+
# "Hermitian",
40+
# "Projector",
41+
# "Prod",
42+
# "Sum",
43+
# "LinearCombination",
44+
# "SProd",
45+
# }
46+
47+
def __init__(self, wires, shots=None, seed=None, **kwargs):
48+
"""
49+
Params:
50+
51+
wires (int, Iterable): Number of subsystems represented by the device,
52+
or iterable that contains a unique label for each subsystem.
53+
shots (int, ~pennylane.measurements.Shots): DEPRECATED, use the qml.set_shot() decorator for each QNode instead. Number of circuit evaluations to run.
54+
seed (int): Random seed used to initialize the pseudo-random number generator.
55+
**kwargs:
56+
- project_id (str): The Scaleway Quantum Project ID.
57+
- secret_key (str): The API token for authentication with Scaleway.
58+
- backend (str): The specific quantum backend to run on Scaleway.
59+
- url (str): The Scaleway API URL (optional).
60+
- session_name (str): Name of the session (optional).
61+
- deduplication_id (str): Unique deduplication identifier for session (optional).
62+
- max_duration (str): Maximum uptime session duration (e.g., "1h", "30m") (optional).
63+
- max_idle_duration (str): Maximum idle session duration (e.g., "1h", "5m") (optional).
64+
- Any options supported by qiskit's BackendSamplerV2 or BackendEstimatorV2 primitives (optional).
65+
66+
Example:
67+
```python
68+
import pennylane as qml
69+
70+
with qml.device("scaleway.cudaq",
71+
wires=2,
72+
project_id=<your-project-id>,
73+
secret_key=<your-secret-key>,
74+
backend="EMU-CUDAQ-8H100SXM"
75+
) as dev:
76+
@qml.set_shots(512)
77+
@qml.qnode(dev)
78+
def circuit():
79+
qml.Hadamard(wires=0)
80+
qml.CNOT(wires=[0, 1])
81+
return qml.counts()
82+
print(circuit())
83+
```
84+
"""
85+
86+
super().__init__(wires=wires, kwargs=kwargs, shots=shots)

pennylane_scaleway/qsim_device.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Copyright 2026 Scaleway
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from pennylane.devices.modifiers import simulator_tracking, single_tape_support
16+
17+
from qiskit_scaleway.backends import QsimBackend
18+
19+
from pennylane_scaleway.scw_device import ScalewayDevice
20+
21+
22+
@simulator_tracking # update device.tracker with some relevant information
23+
@single_tape_support # add support for device.execute(tape) in addition to device.execute((tape,))
24+
class QsimDevice(ScalewayDevice):
25+
"""
26+
Scaleway's device to run Pennylane circuits on Qsim backends.
27+
"""
28+
29+
name = "scaleway.qsim"
30+
backend_type = QsimBackend
31+
32+
# operations = set(QISKIT_OPERATION_MAP.keys())
33+
# observables = {
34+
# "PauliX",
35+
# "PauliY",
36+
# "PauliZ",
37+
# "Identity",
38+
# "Hadamard",
39+
# "Hermitian",
40+
# "Projector",
41+
# "Prod",
42+
# "Sum",
43+
# "LinearCombination",
44+
# "SProd",
45+
# }
46+
47+
def __init__(self, wires, shots=None, seed=None, **kwargs):
48+
"""
49+
Params:
50+
51+
wires (int, Iterable): Number of subsystems represented by the device,
52+
or iterable that contains a unique label for each subsystem.
53+
shots (int, ~pennylane.measurements.Shots): DEPRECATED, use the qml.set_shot() decorator for each QNode instead. Number of circuit evaluations to run.
54+
seed (int): Random seed used to initialize the pseudo-random number generator.
55+
**kwargs:
56+
- project_id (str): The Scaleway Quantum Project ID.
57+
- secret_key (str): The API token for authentication with Scaleway.
58+
- backend (str): The specific quantum backend to run on Scaleway.
59+
- url (str): The Scaleway API URL (optional).
60+
- session_name (str): Name of the session (optional).
61+
- deduplication_id (str): Unique deduplication identifier for session (optional).
62+
- max_duration (str): Maximum uptime session duration (e.g., "1h", "30m") (optional).
63+
- max_idle_duration (str): Maximum idle session duration (e.g., "1h", "5m") (optional).
64+
- Any options supported by qiskit's BackendSamplerV2 or BackendEstimatorV2 primitives (optional).
65+
66+
Example:
67+
```python
68+
import pennylane as qml
69+
70+
with qml.device("scaleway.qsim",
71+
wires=2,
72+
project_id=<your-project-id>,
73+
secret_key=<your-secret-key>,
74+
backend="EMU-QSIM-64C-512M"
75+
) as dev:
76+
@qml.set_shots(512)
77+
@qml.qnode(dev)
78+
def circuit():
79+
qml.Hadamard(wires=0)
80+
qml.CNOT(wires=[0, 1])
81+
return qml.counts()
82+
print(circuit())
83+
```
84+
"""
85+
86+
super().__init__(wires=wires, kwargs=kwargs, shots=shots)

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
"scaleway.aer = pennylane_scaleway:AerDevice",
2525
"scaleway.aqt = pennylane_scaleway:AqtDevice",
2626
"scaleway.iqm = pennylane_scaleway:IqmDevice",
27+
"scaleway.qsim = pennylane_scaleway:QsimDevice",
28+
"scaleway.cudaq = pennylane_scaleway:CudaqDevice",
2729
]
2830

2931
setup(
3032
name="pennylane-scaleway",
31-
version="0.3.1",
33+
version="0.3.2",
3234
project_urls={
3335
"Documentation": "https://www.scaleway.com/en/quantum-as-a-service/",
3436
"Source": "https://github.com/scaleway/pennylane-scaleway",

0 commit comments

Comments
 (0)