mimiqcircuits.remote¶
Remote connection and execution utilities.
Classes
|
Represents a connection to the Mimiq Server via direct cloud connection. |
|
Represents a connection to the Mimiq Server via PlanQK. |
|
|
|
Base class for connections to the Mimiq Server. |
- class mimiqcircuits.remote.MimiqConnection(url=None)[source]¶
Bases:
RemoteConnectionRepresents a connection to the Mimiq Server via direct cloud connection.
This is a wrapper around mimiqlink.MimiqConnection to provide the circuit execution API.
- class mimiqcircuits.remote.PlanqkConnection(url=None, consumer_key=None, consumer_secret=None)[source]¶
Bases:
RemoteConnectionRepresents a connection to the Mimiq Server via PlanQK.
This is a wrapper around mimiqlink.PlanqkConnection to provide the circuit execution API.
- class mimiqcircuits.remote.RemoteConnection(connection)[source]¶
Bases:
objectBase class for connections to the Mimiq Server.
This class provides common functionality for both MimiqConnection and PlanqkConnection.
- __init__(connection)[source]¶
Initialize a remote connection using a specific connection type.
- Parameters:
connection (AbstractConnection) – A mimiqlink connection object (MimiqConnection or PlanqkConnection)
- submit(circuits, label='pyapi_v0.21.2', algorithm='auto', nsamples=1000, bitstrings=None, timelimit=None, bonddim=None, entdim=None, mpscutoff=None, remove_swaps=None, canonicaldecompose=None, fuse=None, reorderqubits=None, reorderqubits_seed=None, seed=None, qasmincludes=None, force=False, mpsmethod=None, mpotraversal=None, noisemodel=None, streaming=None)[source]¶
Submit a circuit or a list of quantum circuits to the Mimiq server. Returns a Job object (non-blocking).
- Parameters:
circuits (Circuit or list of Circuits or str) – A single Circuit object, a list of Circuit objects, or QASM file paths representing the circuits to be executed.
label (str) – A label for the execution. Defaults to “pyapi_v” + __version__.
algorithm (str) – The algorithm to use. Defaults to “auto”.
nsamples (int) – The number of samples to collect. Defaults to DEFAULT_SAMPLES.
seed (int, optional) – A seed for random number generation. Defaults to None.
bitstrings (list of str, optional) – Specific bitstrings to measure. Defaults to None.
timelimit (int, optional) – The maximum execution time in minutes. Defaults to None.
bonddim (int, optional) – The bond dimension to use. Defaults to None.
entdim (int, optional) – The entanglement dimension to use. Defaults to None.
mpscutoff (float, optional) – Singular value truncation cutoff for MPS simulation. Smaller values give higher accuracy at increased cost. Defaults to None (let the remote service decide).
remove_swaps (bool, optional) – Whether to remove SWAP gates. Defaults to None (let the remote service decide).
canonicaldecompose (bool, optional) – Whether to decompose the circuit into GateU and GateCX. Defaults to None (let the remote service decide).
fuse (bool, optional) – Whether to fuse gates. Defaults to None (let the remote service decide).
reorderqubits (bool or str, optional) – Whether to reorder qubits. Can be a boolean or a string specifying the method (e.g., ‘greedy’, ‘spectral’, ‘rcm’, ‘sa_warm_start’, ‘sa_only’, ‘memetic’, ‘multilevel’, ‘grasp’, ‘hybrid’). Defaults to None (let the remote service decide).
reorderqubits_seed (int, optional) – Independent seed for the qubit reordering RNG, allowing reproducible reordering independently of the simulation seed. Defaults to None (uses main seed).
mpsmethod (str, optional) – whether to use variational (“vmpoa”, “vmpob”) or direct (“dmpo”) methods for MPO application in MPS simulations. Defaults to None (let the remote service decide).
mpotraversal (str, optional) – method to traverse the circuit while compressing it into MPOs. Can be “sequential” (default) or “bfs” (Breadth-First Search). Defaults to None.
noisemodel (NoiseModel, optional) – A NoiseModel object to be applied to the circuit(s) before execution. Defaults to None.
streaming (bool, optional) – whether or not to use the streaming simulator. Defaults to None (let the remote service decide).
qasmincludes (list of str, optional) – Additional QASM includes. Defaults to None.
- Returns:
A handle to the execution, typically used to retrieve results.
- Return type:
- Raises:
ValueError – If nsamples exceeds MAX_SAMPLES, bond/entanglement dimensions are out of bounds, or if a circuit contains unevaluated symbolic parameters.
FileNotFoundError – If a QASM file is not found.
TypeError – If the circuits argument is not a Circuit object or a valid file path.
- check_equivalence(experiment, **kwargs)[source]¶
Executes a CircuitTesterExperiment and verifies the results. Blocks until execution is complete.
- Parameters:
experiment (CircuitTesterExperiment) – The experiment to run.
**kwargs – Arguments passed to execute.
- Returns:
The verification score (probability of all-zero state).
- Return type:
- optimize(experiments, label='pyapi_v0.21.2', algorithm='auto', nsamples=1000, timelimit=None, bonddim=None, entdim=None, mpscutoff=None, remove_swaps=None, canonicaldecompose=None, fuse=None, reorderqubits=None, reorderqubits_seed=None, seed=None, history=False, force=False, debug=False)[source]¶
- get_input(execution, **kwargs)¶
Retrieve the first circuit or experiment and parameters of the execution.
- Parameters:
execution (str) – The execution identifier.
- Returns:
A tuple containing the first Circuit or OptimizationExperiment object and parameters (dict).
- Return type:
- Raises:
RuntimeError – If required files are not found in the inputs.
- get_inputs(execution)¶
Retrieve the inputs (circuits or experiments and parameters) of the execution.
- Parameters:
execution (str) – The execution identifier.
- Returns:
A tuple containing a list of Circuit or OptimizationExperiment objects and parameters (dict).
- Return type:
- Raises:
RuntimeError – If required files are not found in the inputs.
- get_result(execution, **kwargs)¶
Retrieve the first result if multiple are found.
- Parameters:
execution (str) – The execution identifier.
**kwargs – Additional keyword arguments for result retrieval.
- Returns:
The first result found.
- Return type:
QCSResults | OptimizationRun | OptimizationResults
- Raises:
RuntimeWarning – If multiple results are found.
- get_results(execution, interval=1)¶
Retrieve the results of a completed execution.
- Parameters:
- Returns:
A list of result instances.
- Return type:
List[QCSResults | OptimizationRun | OptimizationResults]
- Raises:
RuntimeError – If the remote job encounters an error.