QCalibrate remote interface
Project description
A client library for runnig a control optimization with qruise calibrate software
Note
The API is experimental and subject to change without a prior notice
Description
The qcalibrateremote package provides interface to QCalibrate optimization service, providing algorithms helping to define optimal control for quantum system. The actual optimization algorithm runs on the server, supplying the set of parameters and/or PWC pulses to client side. The client code evaluates the parameters by deriving and applying control signals to a system under control, performing measurement, calcualates and returns the figure of merit (infidelity) value. The algorithm tries different parameters in order to find optimal values to achieve minimal infidelity. Live progress of optimization can be observed in the in web UI, given opportunity to finish the optimization, before the optimization stopping criteria are achieved.
Currently two optimization modes are supported.
pure parameter optimization
Random chopped base PWC function optimization (Fourier and Sigmoid bases)
Installing
Install with pip:
$ pip install qcalibrateremote
for conda environment install grcpio explicitly
$ conda install grpcio
Usage
Prerequisits
Python 3.8+ (developed and tested with 3.8.5)
Qruise Calibrate account (contact r.razilov@fz-juelich.de for details)
Direct internet connection to server (may require VPN access)
Experiment
Experiment defines is a set of meta-parameters controlling the optimiztion Use Web UI to create an experiment and define optimization parameters. Use online help to get learn about o
Pure parameter optimization example
# import dependencies
from typing import Dict
from qcalibrateremote import (
EvaluateFigureOfMerit,
FigureOfMerit,
create_optimizer_client,
)
# setup client connection (copy form web UI: https://www.qcalibrate.staging.optimal-control.net:31603)
experiment_id="0xabcd"
token=("ey...")
optimizer_client = create_optimizer_client(
host="grpc.qcalibrate.staging.optimal-control.net", port=31603, token=token)
# define infidelity evaluation class
class DistanceFom(EvaluateFigureOfMerit):
def __init__(self, *args, **kwargs) -> None:
super().__init__()
def infidelity(self, param1, param2) -> float:
return (param1 - 0.55)**2 + (param2 - 0.33)**2
def evaluate(self, parameters: Dict[str, float], **kwargs) -> FigureOfMerit:
"""Abstract method for figure of merit evaluation"""
# print(parameters)
return FigureOfMerit(self.infidelity(**parameters), '')
# run optimization
optimization_result = optimizer_client.run(experiment_id=experiment_id, evaluate_fom_class=DistanceFom)
# best fiting parameters
optimization_result.top[0].parameters
Pulse optimization example
# import dependencies
from typing import Dict
from qcalibrateremote import (
EvaluateFigureOfMerit,
FigureOfMerit,
create_optimizer_client,
Pulse,
)
# setup client connection (copy form web UI: https://www.qcalibrate.staging.optimal-control.net:31603)
experiment_id="0xabcd"
token=("ey...")
optimizer_client = create_optimizer_client(
host="grpc.qcalibrate.staging.optimal-control.net", port=31603, token=token)
# define infidelity evaluation class
def expected_pulse(t):
return np.sin(2*np.pi*t)**4
class SineFom(EvaluateFigureOfMerit):
def evaluate(self, parameters: Dict[str, float], pulses: Dict[str, Pulse], **kwargs) -> FigureOfMerit:
pulse1 = pulses["pulse1"]
inf = np.sum((expected_pulse(pulse1.times) - pulse1.values)**2)
return FigureOfMerit(inf, '{}')
# run optimization
optimization_result = optimizer_client.run(experiment_id=experiment_id, evaluate_fom_class=SineFom)
# plot best fiting pulse
pulse1 = optimization_result.top[0].pulses["pulse1"]
import matplotlib.pyplot as plt
plt.plot(pulse1.times, expected_pulse(pulse1.times))
plt.plot(pulse1.times, pulse1.values)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for qcalibrateremote-0.1.6-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5def693079ac7c12bf98460ed713a7f963ce688e7cedfdc73c78af201484ad0a |
|
MD5 | 8783dc9e6e891a81736689e4cc8d506c |
|
BLAKE2b-256 | d4d66069c80addb40e68eaaf68bcf3ac54cc74b781649a237a71ffef890e913c |