Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

quapp-merlin

Quapp provider lib for MerLin, Quandela's photonic quantum machine learning framework. MerLin wraps Perceval but is a separate SDK here: a MerLin handler returns a PyTorch model, not a circuit.

SDK tag: MERLIN · providers: QUAO_QUANTUM_SIMULATOR (local), QUANDELA (cloud)

What a handler returns

Every other SDK on the platform has processing() return a circuit. MerLin has no circuit to return -- the unit of work is a torch.nn.Module holding a merlin.QuantumLayer, plus the batch to run it on.

import merlin as ML
import torch

from quapp_merlin import MerlinJobSpec


def processing(invocation_input: dict) -> MerlinJobSpec:
    layer = ML.QuantumLayer.simple(
            input_size=4,
            measurement_strategy=ML.MeasurementStrategy.probs())

    return MerlinJobSpec(model=layer,
                         inputs=torch.tensor(invocation_input['inputs']),
                         shots=invocation_input.get('shots'))


def post_processing(job_result: dict) -> dict:
    return {'probabilities': job_result['result']['values']}

Returning a bare torch.nn.Module also works, and the batch is then read from invocation_input["inputs"].

shots=None (the default) means exact probabilities: MerLin does not invent a shot count, and neither does this lib.

One invocation, one machine

MerLin fans out along three axes, and the first one can put a job on a machine nobody selected:

Axis What it does Rule here
Backend one MerlinProcessor binds one backend, but a handler can build a second one and route layers to it refused -- the machine comes from DeviceSelection
Chunks len(X) > microbatch_size splits a batch into several cloud jobs chunk_concurrency=1, batch must fit one microbatch
Leaves several QuantumLayers in one model, each its own remote job one layer per invocation

Together these keep future.job_ids a single id, so provider_job_id stays one value the backend can store as-is. The rules live in quapp_merlin/util/single_machine.py and are locked by tests/test_single_machine.py.

Local vs remote

local (QUAO_QUANTUM_SIMULATOR) remote (QUANDELA)
Runs on SLOS simulation in the container, CPU only Quandela Cloud, sim:* or qpu:*
Training yes, MerlinJobSpec(training=TrainingSpec(...)) no -- no gradient flows through the MerLin processor
Phases COMPILATION, EXECUTION, ANALYSIS plus POLLING while waiting on the cloud
Job id none one, from future.job_ids

The image ships the CPU build of torch on purpose: the default wheel drags in the whole CUDA runtime (~2.5 GB) for a photonic simulator that never touches a GPU. A job asking for ProcessingUnit.GPU runs on CPU with a warning.

Result shape

_create_job returns a dict that is already JSON-safe -- no tensor ever reaches json.dumps in a callback:

{'result': {'values': [[0.24, 0.76]], 'truncated': False, 'elements': 2},
 'shape': [1, 2],
 'batch_size': 1,
 'shots': None,
 'measurement': 'probs',
 'execution_time': 0.184,
 'provider_job_id': None,
 'histogram': {'state_0': 0.24, 'state_1': 0.76},
 'metadata': {}}

histogram is only produced for a probability measurement of a single row: with a batch there are as many distributions as rows, and with mode_expectations() / amplitudes() there is no distribution over states to bin. It is None in those cases, and the full output stays in result.

Large outputs are truncated with truncated: True and the real element count, rather than silently sending the first rows as if they were everything.

Versions

merlinquantum ==0.4.1 -- 0.4 renamed the QuantumLayer arguments 0.3 used (output_mapping_strategy -> measurement_strategy, ansatz -> builder), so >= would break every handler
quapp-common ==0.0.17.dev1 -- Sdk.MERLIN exists from 0.0.15.dev5 on; 0.0.15 stable lacks it, so a stable pin needs 0.0.16 or later
perceval-quandela >=1.2.1,<1.3 -- merlinquantum 0.4.1 only asks for >=1.2.1, but it imports perceval.runtime.session, which 1.3.0 removed; without the cap a fresh install fails on import merlin
Python >=3.10 (merlinquantum), <3.15 (perceval-quandela)

import quapp_merlin needs none of torch, merlin or perceval: every SDK import sits inside the function that uses it, so the error classifier still works in an image where the SDK failed to install. tests/test_lazy_sdk_imports.py enforces it.

Metadata

Release files for quapp-merlin 0.0.1.dev9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quapp-merlin 0.0.1.dev9
File Size Uploaded Provenance
quapp_merlin-0.0.1.dev9.tar.gz 40.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for quapp-merlin 0.0.1.dev9
File Interpreter ABI Platform
quapp_merlin-0.0.1.dev9-py3-none-any.whl Python 3 none any Details

Total release size: 73.0 kB

Release files / quapp_merlin-0.0.1.dev9.tar.gz

Download URL quapp_merlin-0.0.1.dev9.tar.gz
Size 40.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fa9442895bd49e8df9327cf7c7192008a33ca73a6ff3f0b194aebe8bbf5cf1b7
BLAKE2b-256 checksum
How to use checksums
af8b891e291e1cb0c4f09a5b8c6b9e1669b609a9340a53b083cf2bb5c5224db0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Release files / quapp_merlin-0.0.1.dev9-py3-none-any.whl

Download URL quapp_merlin-0.0.1.dev9-py3-none-any.whl
Size 32.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fba1d8dfad86c49a33214cd5e50cbac1402398baebcfa78a55841f1a81b2bdd7
BLAKE2b-256 checksum
How to use checksums
8078b7559f8eed547cfe5a7fcee48af520a5e331d2eaf65ec3cd95fb04955ab8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Security for quapp-merlin 0.0.1.dev9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page