-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cloud simulator usage example * update to qm-saas 1.1.1 * specify qm-saas version * fixes to comments * black
- Loading branch information
Showing
2 changed files
with
109 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from qm import QuantumMachinesManager, SimulationConfig | ||
from qm.qua import play, program | ||
from qm_saas import QoPVersion, QmSaas | ||
|
||
# for qm-saas version 1.1.1 | ||
|
||
# Define quantum machine configuration dictionary | ||
config = { | ||
"version": 1, | ||
"controllers": { | ||
"con1": { | ||
"analog_outputs": { | ||
1: {"offset": +0.0}, | ||
}, | ||
} | ||
}, | ||
"elements": { | ||
"qe1": { | ||
"singleInput": {"port": ("con1", 1)}, | ||
"intermediate_frequency": 5e6, | ||
"operations": { | ||
"playOp": "constPulse", | ||
}, | ||
}, | ||
}, | ||
"pulses": { | ||
"constPulse": { | ||
"operation": "control", | ||
"length": 1000, # in ns | ||
"waveforms": {"single": "const_wf"}, | ||
}, | ||
}, | ||
"waveforms": { | ||
"const_wf": {"type": "constant", "sample": 0.2}, | ||
}, | ||
} | ||
|
||
# ====================================================================================================================== | ||
# Description: Use default host and port for the QOP simulator. Email and password are mandatory. | ||
# Using the context manager ensures them simulator instance is closed properly. | ||
# ====================================================================================================================== | ||
|
||
# These should be changed to your credentials. | ||
email = "john.doe@mail.com" | ||
password = "Password_given_by_QM" | ||
|
||
# Initialize QOP simulator client | ||
client = QmSaas(email=email, password=password) | ||
|
||
# Choose your QOP version (QOP2.x.y or QOP3.x.y) | ||
# if you choose QOP3.x.y, make sure you are using an adequate config. | ||
version = QoPVersion.v2_2_2 | ||
|
||
with client.simulator(version=version) as instance: # Specify the QOP version | ||
# Initialize QuantumMachinesManager with the simulation instance details | ||
qmm = QuantumMachinesManager( | ||
host=instance.host, port=instance.port, connection_headers=instance.default_connection_headers | ||
) | ||
|
||
# Define a QUA program | ||
with program() as prog: | ||
play("playOp", "qe1") | ||
|
||
# Open quantum machine with the provided configuration and simulate the QUA program | ||
qm = qmm.open_qm(config) | ||
job = qm.simulate(prog, SimulationConfig(int(1000))) | ||
|
||
# Retrieve and handle simulated samples | ||
samples = job.get_simulated_samples() | ||
print("Test passed") | ||
|
||
# analysis of simulation | ||
# do something with samples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters