Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ dates:
| [Qiskit](https://github.com/scaleway/qiskit-scaleway/) | x | x | **OK** | **OK** | **OK** | **OK** | **OK** |
| [Cirq](https://github.com/scaleway/cirq-scaleway/) | x | x | x | **OK** | **OK** | **OK** | x |
| [Perceval](https://github.com/Quandela/Perceval/) | **OK** | x | x | x | x | x | x |
| [MerLin](https://github.com/merlinquantum/merlin/) | **WIP** | x | x | x | x | x | x |
| [MerLin](https://github.com/merlinquantum/merlin/) | **OK** | x | x | x | x | x | x |
| [Pulser](https://github.com/scaleway/pulser-scaleway/) | x | **OK** | x | x | x | x | x |
| [Pennylane](https://github.com/scaleway/pennylane-scaleway/) | x | x | **OK** | **OK** | **OK** | **WIP** | **WIP** |
| [Pennylane](https://github.com/scaleway/pennylane-scaleway/) | x | x | **OK** | **OK** | **OK** | **OK** | **OK** |
| [CUDA-Q (SDK)](https://github.com/NVIDIA/cuda-quantum/) | x | x | **OK** | **OK** | **OK** | x | **OK** |

## Extend compatibility
Expand Down
2 changes: 1 addition & 1 deletion pages/quantum-computing/how-to/use-cudaq-emulators.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dates:
---
import Requirements from '@macros/iam/requirements.mdx'

** CUDA Quantum (CUDA-Q)** is a framework developed by NVIDIA designed for quantum computing applications. It is part of NVIDIA's efforts to integrate quantum computing with classical computing systems, specifically targeting quantum circuit simulation, quantum algorithms, and hybrid quantum-classical workflows. CUDA-Q leverages the power of CUDA (NVIDIA's parallel computing platform) to accelerate quantum computing simulations and provides a foundation for quantum software development that can run on NVIDIA GPUs.
**CUDA Quantum (CUDA-Q)** is a framework developed by NVIDIA designed for quantum computing applications. It is part of NVIDIA's efforts to integrate quantum computing with classical computing systems, specifically targeting quantum circuit simulation, quantum algorithms, and hybrid quantum-classical workflows. CUDA-Q leverages the power of CUDA (NVIDIA's parallel computing platform) to accelerate quantum computing simulations and provides a foundation for quantum software development that can run on NVIDIA GPUs.

Scaleway QaaS allows you to scale CUDA-Q beyond your local machine. You can execute your emulated computation on dedicated **GPU cluster** (like Nvidia H100, L40S and B300) seamlessly, benefiting from pre-configured MPI setup and optimized environments.

Expand Down
173 changes: 173 additions & 0 deletions pages/quantum-computing/how-to/use-merlin.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
---
title: Use MerLin for Photonic Quantum Machine Learning
description: Explore QML capabilities on a Quandela's QPUS or emulators.
tags: quantum quandela photonic merlin perceval pennylane qaas qml ml
dates:
validation: 2026-02-24
posted: 2026-02-24
---
import Requirements from '@macros/iam/requirements.mdx'

**[MerLin](https://merlinquantum.ai/)** is a Photonic Quantum Machine Learning Framework developed by Quandela. It brings quantum computing capabilities to AI practitioners through easy-to-use PyTorch integrations, adding quantum wizardry to your AI toolkit with no extensive quantum expertise required.

It is designed to feel familiar to PyTorch users while unlocking the potential of quantum computing. Under the hood, it leverages photonic quantum computing—a cutting-edge approach using single-photons that's hardware-aware and prepares your models for real quantum processors.

Scaleway offers access to [Quandela's QPUs and emulated QPUs](https://www.scaleway.com/en/docs/quantum-computing/additional-content/quandela-qpus/) via its Quantum as a Service (QaaS) offer. This allows you to run your MerLin-based quantum circuits on real photonic quantum processors or emulators directly from your Python code.

## How to use MerLin with Scaleway

<Requirements />

* A Scaleway account with a valid **Project ID**
* A Scaleway **API Key** (Secret Key)
* Python, `torch`, `perceval-quandela` and `merlinquantum` installed on your machine (`pip install merlinquantum`)

1. Select one of the Quandela platforms to use as your backend target. You can choose between emulators and real QPUs:
* `QPU-ASCELLA-6PQ`
* `QPU-ALTAIR-10PQ`
* `QPU-BELENOS-12PQ`
* `EMU-SAMPLING-L4`
* `EMU-SAMPLING-2L4`
* `EMU-SAMPLING-4L4`
* `EMU-SAMPLING-4H100SXM`
* `EMU-SAMPLING-8H100SXM`

2. Refer to the detailed list of [Scaleway Quantum Computing offers](https://www.scaleway.com/en/quantum-as-a-service/) on the Scaleway website to find a complete list of the available backend platforms.

3. Create a file with the following computation script. Replace `$SCW_PROJECT_ID` and `$SCW_SECRET_KEY` with your Scaleway Project ID and secret key (or set them as environment variables). Also replace the `PLATFORM_NAME` with the emulator or QPU of your choice.
```python
import os
import torch
import perceval.providers.scaleway as scw

from merlin.builder.circuit_builder import CircuitBuilder
from merlin.algorithms import QuantumLayer
from merlin.core.merlin_processor import MerlinProcessor

# Credentials
PROJECT_ID = os.environ.get("SCW_PROJECT_ID", "your_project_id")
SECRET_KEY = os.environ.get("SCW_SECRET_KEY", "your_secret_key")
PLATFORM_NAME = "EMU-SAMPLING-L4"

# Define a simple circuit builder
b = CircuitBuilder(n_modes=4)
b.add_rotations(trainable=True, name="theta")
b.add_angle_encoding(modes=[0, 1], name="px")

# 1. Open a Scaleway session
with scw.Session(platform_name=PLATFORM_NAME, project_id=PROJECT_ID, token=SECRET_KEY) as session:

# 2. Bind the session to the MerlinProcessor
proc = MerlinProcessor(session=session)

# 3. Create a Quantum Layer
q_layer = QuantumLayer(
input_size=2,
builder=b,
n_photons=2
).eval()

# 4. Run inference
X = torch.rand(4, 2)
result = proc.forward(q_layer, X, nsample=100)

print(f"Input shape: {X.shape}")
print(f"Output shape: {result.shape}")

```
4. Save the script. In this example we save it as `merlin_quickstart.py`.
5. Run the script.
```bash
python ~/merlin_quickstart.py

```

## How to manage a session

A session is required to communicate with Scaleway's QaaS infrastructure. The recommended way to handle your session is to use a context manager (`with scw.Session(...) as session:`), ensuring that the connection is cleanly closed when you exit the block.

When initializing the `MerlinProcessor` with your session, you can pass additional keyword arguments to fine-tune how cloud calls are batched and managed:

```python
import perceval.providers.scaleway as scw
from merlin.core.merlin_processor import MerlinProcessor

with scw.Session(platform_name="EMU-SAMPLING-L4", project_id="$SCW_PROJECT_ID", token="$SCW_SECRET_KEY") as session:

proc = MerlinProcessor(
session=session,
microbatch_size=32, # Batch chunk size per cloud call (<=32)
timeout=300.0, # Default wall-time per forward (seconds)
max_shots_per_call=100, # Optional cap per cloud call
chunk_concurrency=1, # Parallel chunk jobs within a quantum leaf
)
# Your quantum layer and model logic here...

```

## Examples

Below is a complete example of building a hybrid Quantum-Classical neural network using PyTorch and MerLin. We define a PyTorch `nn.Sequential` model where a photonic quantum circuit acts as a hidden layer, seamlessly interacting with classical linear layers.

```python
import os
import torch
import torch.nn as nn

import perceval.providers.scaleway as scw
from merlin.algorithms import QuantumLayer
from merlin.builder.circuit_builder import CircuitBuilder
from merlin.core.merlin_processor import MerlinProcessor
from merlin.measurement.strategies import MeasurementStrategy

### Scaleway session ###
PROJECT_ID = os.environ.get("SCW_PROJECT_ID", "<YOUR_SCW_PROJECT_ID>")
SECRET_KEY = os.environ.get("SCW_SECRET_KEY", "<YOUR_SCW_SECRET_KEY>")
PLATFORM_NAME = "EMU-SAMPLING-L4" # could be "QPU-BELENOS-12PQ", or any other Quandela backend running on Scaleway QaaS

with scw.Session(platform_name=PLATFORM_NAME, project_id=PROJECT_ID, token=SECRET_KEY) as session:

# Create the processor using the session and configuration parameters
proc = MerlinProcessor(
session=session,
microbatch_size=32,
timeout=300.0,
)

# Build a simple circuit with 6 modes and 2 photons
b = CircuitBuilder(n_modes=6)
b.add_rotations(trainable=True, name="theta")
b.add_angle_encoding(modes=[0, 1], name="px")
b.add_entangling_layer()

# Instantiate the quantum layer, pytorch module-compatible
q_layer = QuantumLayer(
input_size=2,
builder=b,
n_photons=2,
measurement_strategy=MeasurementStrategy.probs(), # Extract raw probability vector
).eval()

# Combine with classical layers to make a full model
model = nn.Sequential(
nn.Linear(3, 2, bias=False),
q_layer,
nn.Linear(15, 4, bias=False), # 15 = Combinations(6,2) from the chosen circuit
nn.Softmax(dim=-1),
).eval()

# Generate dummy data for inference
X = torch.rand(8, 3)

print("Sending hybrid model to Scaleway QaaS...")
# Execute forward pass
y = proc.forward(model, X, nsample=100)

print("Inference successful!")
print(f"Final output shape: {y.shape}")

```

<Message type="note">
Refer to the [MerLin Reproduced Papers repository](https://github.com/merlinquantum/reproduced_papers) or the [MerLin Documentation](https://merlinquantum.ai/) for more examples and advanced tutorials.
</Message>
6 changes: 4 additions & 2 deletions pages/quantum-computing/how-to/use-pennylane.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: Run Quantum Machine Learning using Pennylane
title: Use Pennylane for Quantum Machine Learning
description: Explore QML capabilities on a range of devices, using the Pennylane framework.
tags: aer aqt iqm quantum qiskit pennylane qaas qml ml
dates:
validation: 2025-11-27
posted: 2021-11-21
posted: 2025-11-27
---
import Requirements from '@macros/iam/requirements.mdx'

Expand All @@ -27,6 +27,8 @@ Scaleway offers access to the `pennylane-scaleway` plugin, which enables you to
- `scaleway.aer`
- `scaleway.aqt`
- `scaleway.iqm`
- `scaleway.cudaq`
- `scaleway.qsim`

2. Select which backend to use within the chose device. This will determine the performance of your device. Refer to the detailed list of [Scaleweay Quantum Computing offers](https://www.scaleway.com/en/quantum-as-a-service/) on the Scaleway Website to find a complete list of the available backend platforms.

Expand Down
6 changes: 5 additions & 1 deletion pages/quantum-computing/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ export const quantumComputingMenu = {
slug: 'use-qsim-emulators',
},
{
label: 'Run Quantum Machine Learning with Pennylane',
label: 'Use Pennylane for Quantum Machine Learning',
slug: 'use-pennylane',
},
{
label: 'Use MerLin for Photonic Quantum Machine Learning',
slug: 'use-merlin',
},
],
label: 'How to',
slug: 'how-to',
Expand Down
Loading