cqlib.quantum_platform package
Quantum Computing platforms.
- This module provides an abstract and implementation for different quantum computing platforms,
allowing for the execution and management of tasks across various quantum computing environments.
- Classes:
- BasePlatform: A base class that provides the common interface and functionality for all
quantum computing platforms. This includes basic operations such as authentication, job submission, and result retrieval.
- TianYanPlatform: A implementation of the BasePlatform tailored for the TianYan quantum
- computing quantum_platform. This class customizes the base functionalities with specific
endpoints (URLs) and methods suited for the TianYan infrastructure.
- GuoDunPlatform: Similar to TianYanPlatform, this class is designed for the GuoDun quantum
computing quantum_platform. It extends the BasePlatform with customizations specific to GuoDun’s operational needs and technical specifications, including unique URLs and functions.
- class cqlib.quantum_platform.BasePlatform(login_key: str, auto_login: bool = True, machine_name: str | None = None)
Bases:
objectbase class for all platforms
- CREATE_EXP_AND_RUN_PATH = ''
- CREATE_LAB_PATH = ''
- DOMAIN = ''
- DOWNLOAD_CONFIG_PATH = ''
- GET_EXP_CIRCUIT_PATH = ''
- LOGIN_PATH = ''
- MACHINE_CONFIG_PATH = ''
- MACHINE_LIST_PATH = ''
- QCIS_CHECK_REGULAR_PATH = ''
- QUERY_EXP_PATH = ''
- RE_EXECUTE_TASK_PATH = ''
- SAVE_EXP_PATH = ''
- SCHEME = 'https'
- STOP_RUNNING_EXP_PATH = ''
- create_lab(name: str, remark: str = '') str
create a new lab, a collection of experiments.
- Parameters:
name – new experiment collection Name.
remark – experimental remarks.
- Returns:
0 failed, not 0 successful, success returns the experimental set id
- download_config(read_time: str | None = None, machine: str | None = None)
download experimental parameters.
- Parameters:
read_time – select configuration data according to the reading time, and the parameter format is yyyy-MM-dd HH:mm:ss, Defaults to None.
machine – machine name
- Returns:
0 failed, not 0 successful, success returns the experimental parameters.
- get_experiment_circuit(query_id: str | List[str])
According to the exp_id obtained experimental circuit
- Parameters:
query_id – experimental id list. max length is 50
- Returns:
the experimental circuit, The parameters of the returned experimental circuit include qcis、mapQcis and computerQcis. qcis is the line submitted by the user, mapQcis is the compiled circuit, computerQcis is a circuit submitted to a quantum computer.
- get_machine_config(params: Optional)
Download qpu topology structure without authentication.
- Parameters:
params – parameter input required by gplot module.
- Returns:
data about qpu topology info.
- handler_run_experiment_result(data)
Handles the request to save the result of running an experiment.
Attempts to temporarily save the experiment results to the server. Returns a list of saved query IDs upon success; may reconnect and retry on failure.
- Parameters:
data (dict) – A dictionary containing the experiment results.
- Returns:
A list of saved query IDs if successful; otherwise, returns 0.
- Return type:
list
- login(timeout=60) int
Authenticate username and password and return user credit
- Returns:
log in state, 1 means pass authentication, 0 means failed
- qcis_check_regular(qcis_raw: str)
qcis regular check,normal returns 1, abnormal returns 0
- Parameters:
qcis_raw – qcis circuit
- Returns:
0 failed, 1 success
- query_experiment(query_id: str | List[str], max_wait_time: int = 120, sleep_time: int = 5)
query experimental results
- Parameters:
query_id – experiment task ids. The maximum count is 50.
max_wait_time – maximum waiting time for querying experiments. Defaults to 60.
sleep_time – If query result failed, take a break and start again.
- Returns:
the experimental result list
- query_quantum_computer_list()
Get a full list of quantum computers, a list of simulators, and show the corresponding states.
- Returns:
List of quantum computers and related information.
- re_execute_task(query_id: str | None = None, lab_id: str | None = None)
Re-execute the experiment that has been run previously.
- Parameters:
query_id – query id
lab_id – resubmit all exp tasks in this lab set.
- Returns:
the query id for resubmitting the experiment
- run_experiment(exp_id: str, num_shots: int = 12000, is_verify: bool = True)
running the experiment returns the query result id.
- Parameters:
exp_id – experimental id. the id returned by the save_experiment interface.
num_shots – number of repetitions per experiment. Defaults to 12000.
is_verify – Is the circuit verified.
- Returns:
experiment task query id.
- save_experiment(lab_id: str, circuit: str, name: str | None = '', language: QuantumLanguage = QuantumLanguage.QCIS, **kwargs)
save the experiment and return the experiment ID. (Will not run immediately)
- Parameters:
lab_id – experiment lab ID
circuit – experiment circuit
name – experiment name
language – Quantum computer language, including [‘isq’, ‘quingo’, ‘qcis’].
kwargs – Optional attachment key word args.
- kwargs Description
noise: This parameter is a list of dictionaries, each describing a type of quantum noise model for simulations that utilize a noisy quantum simulator. Currently, only one noise model can be specified at a time, but future updates will allow multiple parameters.
This parameter allows the configuration of different types of quantum noise which affects the simulation by altering the state of qubits. The accepted noise types and their corresponding parameters are as follows:
bit-flip: Simulates the bit flip error, where a qubit state ∣0⟩ flips to ∣1⟩ and vice versa. The parameter is the probability pp of a bit flip occurring, typically set to a default value of 0.1.
` noise=[{"noise_type": "bit-flip", "params": [0.1]}] `phase-flip: Simulates the phase flip error, which flips the phase of a qubit. It takes a probability pp, with a typical default of 0.1.
` noise=[{"noise_type": "phase-flip", "params": [0.1]}] `depolarizing: Simulates a depolarizing channel, which can randomly alter the state of a qubit to any other state. It is defined by a probability pp, commonly set to 0.1 by default.
` noise=[{"noise_type": "depolarizing", "params": [0.1]}] `decoherence: Represents decoherence noise which is characterized by operational time, coherence time, and decoherence time. It’s defined by the parameters: operation time (default 0.5), coherence time (default 200), and decoherence time (default 30).
` noise=[{"noise_type": "decoherence", "params": [0.5, 200, 30]}] `quantum_state: This parameter specifies the state of the quantum simulation where only a single amplitude is simulated. It generally requires a parameter specifying the output state, with a default value of 0.
` quantum_state=1 `
- Returns:
experiment id
- set_machine(machine_name: str)
set the machine name.
- Parameters:
machine_name – name of quantum computer or simulator.
- stop_running_experiments(lab_id: str | None = None, query_id: str | None = None)
Terminate recently running experiments
- Parameters:
query_id – query id
lab_id – Terminate all exp tasks in this lab set.
- Returns:
the query id for stopped the experiment
- submit_job(circuit: List | str | None = None, exp_name: str | None = '', parameters: List[List] | None = None, values: List[List] | None = None, num_shots: int | None = 12000, lab_id: str | None = None, exp_id: str | None = None, language: QuantumLanguage = QuantumLanguage.QCIS, version: str | None = '1', is_verify: bool | None = True, **kwargs)
submit experimental tasks.
There are some parameter range limitations when using batch submission circuits.
- circuits length less than 50, num_shots maximum 100000, the number of measurement
qubits is less than 15.
circuits length greater than 50 but less than 100, num_shots maximum 50000, the number of measurement qubits is less than 30.
circuits length greater than 100 but less than 600, num_shots maximum 10000, the number of measurement bits is less than the number of all available qubits.
When the circuit is none, the exp_id cannot be none and the lab_id needs to be none,
- When the circuit is not none, when the circuit is multiple lines,
the version and exp_id need to be none, and the line will be saved under the default collection if the lab_id or exp_name is not transmitted.
- When the circuit is not none, when the circuit is a single line, exp_id need to be none,
version does not transmit to generate the default, lab_id or exp_name does not transmit the line is saved under the default collection.
- Parameters:
circuit – experimental content, qcis. Defaults to None.
exp_name – new experiment collection Name. Defaults to “exp0”.
parameters – parameters that need to be assigned in the experimental content.
values – The values corresponding to the parameters that need to be assigned in the experimental content. Defaults to None.
num_shots – number of repetitions per experiment. Defaults to 12000.
lab_id – the result returned by the create_experiment interface, experimental set id.
exp_id – the result returned by the save_experiment interface, experimental id.
language – quantum language code. Defaults to qcis.
version – version description. Defaults to ‘version01’.
is_verify – Is the circuit verified.True verify, False do not verify.
kwargs – Same as in save_experiment. Refer to the save_experiment function for details on the accepted parameters and usage examples.
- Returns:
If 0 failed, else return the query id if successful.
- Return type:
Union[int, str]
- class cqlib.quantum_platform.GuoDunPlatform(login_key: str, auto_login: bool = True, machine_name: str | None = None)
Bases:
BasePlatformGuoDun quantum platform test case
- CREATE_EXP_AND_RUN_PATH = '/experiment/sdk/experiment/temporary/save'
- CREATE_LAB_PATH = '/experiment/sdk/experiment/save'
- CREATE_WAVEFORM_DIAGRAM = '/experiment/sdk/generateWaveformDiagram'
- DOMAIN = 'quantumctek-cloud.com'
- DOWNLOAD_CONFIG_PATH = '/experiment/sdk/experiment/download/config'
- DOWN_WAVEFORM_DIAGRAM = '/experiment/sdk/getWaveformDiagram'
- GET_EXP_CIRCUIT_PATH = '/experiment/sdk/experiment/getQcis/by/taskIds'
- LOGIN_PATH = '/api-uaa/oauth/token'
- MACHINE_CONFIG_PATH = '/experiment/sdk/quantumComputer/config'
- MACHINE_LIST_PATH = '/experiment/sdk/quantumComputer/list'
- QCIS_CHECK_REGULAR_PATH = '/experiment/sdk/experiment/qcis/rule/verify'
- QUERY_EXP_PATH = '/experiment/sdk/experiment/result/find'
- RE_EXECUTE_TASK_PATH = '/experiment/sdk/experiment/resubmit'
- SAVE_EXP_PATH = '/experiment/sdk/experiment/detail/save'
- SCHEME = 'https'
- STOP_RUNNING_EXP_PATH = '/experiment/sdk/experiment/discontinue'
- create_waveform_data(circuit, circuit_name: str | None = None) int
Generates a waveform data for the given quantum circuit.
- Parameters:
circuit – The quantum circuit to visualize
circuit_name (Optional[str]) – Optional name for the circuit
- Returns:
The query_id of the generated waveform data
- Return type:
int
- Raises:
CqlibInputParaError – If required parameters are missing
- query_waveform_data(query_id: int) str
Get the waveform_data URL based on the provided query_id
- Parameters:
query_id (int or str) – The circuit ID .
- Returns:
The waveform_data_file download path or the URL.
- Return type:
str
- re_execute_task(query_id: str | None = None, lab_id: str | None = None)
Re-execute the experiment that has been run previously.
- Parameters:
query_id – query id
lab_id – resubmit all exp tasks in this lab set.
- Returns
the query id for resubmitting the experiment
- stop_running_experiments(lab_id: str | None = None, query_id: str | None = None)
Terminate recently running experiments
- Parameters:
query_id – query id
lab_id – Terminate all exp tasks in this lab set.
- Returns:
the query id for stopped the experiment
- class cqlib.quantum_platform.QuantumLanguage(value)
Bases:
EnumQuantum circuit language
- ISQ = 'isq'
- QCIS = 'qcis'
- QUINGO = 'quingo'
- class cqlib.quantum_platform.TianYanPlatform(login_key: str, auto_login: bool = True, machine_name: str | None = None)
Bases:
BasePlatformTian yan quantum computing cloud quantum_platform
- CREATE_EXP_AND_RUN_PATH = '/qccp-quantum/sdk/experiment/temporary/save'
- CREATE_LAB_PATH = '/qccp-quantum/sdk/experiment/save'
- DOMAIN = 'qc.zdxlz.com'
- DOWNLOAD_CONFIG_PATH = '/qccp-quantum/sdk/experiment/download/config'
- GET_EXP_CIRCUIT_PATH = '/qccp-quantum/sdk/experiment/getQcis/by/taskIds'
- LOGIN_PATH = '/qccp-auth/oauth2/sdk/opnId'
- MACHINE_LIST_PATH = '/qccp-quantum/sdk/quantumComputer/list'
- QCIS_CHECK_REGULAR_PATH = '/qccp-quantum/sdk/experiment/qcis/rule/verify'
- QUERY_EXP_PATH = '/qccp-quantum/sdk/experiment/result/find'
- RE_EXECUTE_TASK_PATH = '/qccp-quantum/sdk/experiment/resubmit'
- RUN_EXP_PATH = '/qccp-quantum/sdk/experiment/detail/run'
- SAVE_EXP_PATH = '/qccp-quantum/sdk/experiment/detail/save'
- SCHEME = 'https'
- STOP_RUNNING_EXP_PATH = ''
- SUBMIT_EXP_PATH = '/qccp-quantum/sdk/experiment/submit'
- download_fsim_config(machine: str | None = None, read_time: str | None = None) dict[tuple[str, str], dict[str, float]]
download FSIM experimental parameters.
- Parameters:
read_time – select configuration data according to the reading time, and the parameter format is yyyy-MM-dd HH:mm:ss, Defaults to None.
machine – machine name
- Returns:
0 failed, not 0 successful, success returns the experimental parameters.
- query_experiment(query_id: str | list[str], max_wait_time: int = 3600, sleep_time: int = 5, readout_calibration: bool = False, machine_config: dict | None = None)
query the experiment result.
- Parameters:
query_id – experiment task ids. The maximum count is 50.
max_wait_time – maximum waiting time for querying experiments. Defaults to 3600.
sleep_time – If query result failed, take a break and start again.
readout_calibration – readout correction for quantum measurements. Defaults to False.
machine_config – Optional machine configuration. If not provided, will attempt to download configuration automatically when readout_calibration is True.
- run_experiment(exp_id: str, num_shots: int = 12000, is_verify: bool = True)
running the experiment returns the query result id.
- Parameters:
exp_id – experimental id. the id returned by the save_experiment interface.
num_shots – number of repetitions per experiment. Defaults to 12000.
is_verify – Is the circuit verified.
- Returns:
experiment task query id.
- submit_experiment(circuit: str | list[str], language: QuantumLanguage = QuantumLanguage.QCIS, name: str | None = None, parameters: list[list[str]] | None = None, values: list[list[float]] | None = None, lab_id: str | None = None, lab_name: str | None = None, num_shots: int = 12000, machine_name: str | None = None, is_verify: bool = True, **kwargs)
running the experiment returns the query result id.
- Parameters:
circuit – experimental content, qcis. Defaults to None.
language – quantum language code. Defaults to qcis.
name – new experiment collection Name.
parameters – parameters that need to be assigned in the experimental content.
values – The values corresponding to the parameters that need to be assigned in the experimental content. Defaults to None.
lab_id – the result returned by the create_experiment interface, experimental set id.
lab_name – defined lab name.
num_shots – number of repetitions per experiment. Defaults to 12000.
machine_name – specified which machine to use.
is_verify – Is the circuit verified.
- Returns:
experiment task query id.
Submodules
cqlib.quantum_platform.base module
Base class for all quantum platform
- class cqlib.quantum_platform.base.BasePlatform(login_key: str, auto_login: bool = True, machine_name: str | None = None)
Bases:
objectbase class for all platforms
- CREATE_EXP_AND_RUN_PATH = ''
- CREATE_LAB_PATH = ''
- DOMAIN = ''
- DOWNLOAD_CONFIG_PATH = ''
- GET_EXP_CIRCUIT_PATH = ''
- LOGIN_PATH = ''
- MACHINE_CONFIG_PATH = ''
- MACHINE_LIST_PATH = ''
- QCIS_CHECK_REGULAR_PATH = ''
- QUERY_EXP_PATH = ''
- RE_EXECUTE_TASK_PATH = ''
- SAVE_EXP_PATH = ''
- SCHEME = 'https'
- STOP_RUNNING_EXP_PATH = ''
- create_lab(name: str, remark: str = '') str
create a new lab, a collection of experiments.
- Parameters:
name – new experiment collection Name.
remark – experimental remarks.
- Returns:
0 failed, not 0 successful, success returns the experimental set id
- download_config(read_time: str | None = None, machine: str | None = None)
download experimental parameters.
- Parameters:
read_time – select configuration data according to the reading time, and the parameter format is yyyy-MM-dd HH:mm:ss, Defaults to None.
machine – machine name
- Returns:
0 failed, not 0 successful, success returns the experimental parameters.
- get_experiment_circuit(query_id: str | List[str])
According to the exp_id obtained experimental circuit
- Parameters:
query_id – experimental id list. max length is 50
- Returns:
the experimental circuit, The parameters of the returned experimental circuit include qcis、mapQcis and computerQcis. qcis is the line submitted by the user, mapQcis is the compiled circuit, computerQcis is a circuit submitted to a quantum computer.
- get_machine_config(params: Optional)
Download qpu topology structure without authentication.
- Parameters:
params – parameter input required by gplot module.
- Returns:
data about qpu topology info.
- handler_run_experiment_result(data)
Handles the request to save the result of running an experiment.
Attempts to temporarily save the experiment results to the server. Returns a list of saved query IDs upon success; may reconnect and retry on failure.
- Parameters:
data (dict) – A dictionary containing the experiment results.
- Returns:
A list of saved query IDs if successful; otherwise, returns 0.
- Return type:
list
- login(timeout=60) int
Authenticate username and password and return user credit
- Returns:
log in state, 1 means pass authentication, 0 means failed
- qcis_check_regular(qcis_raw: str)
qcis regular check,normal returns 1, abnormal returns 0
- Parameters:
qcis_raw – qcis circuit
- Returns:
0 failed, 1 success
- query_experiment(query_id: str | List[str], max_wait_time: int = 120, sleep_time: int = 5)
query experimental results
- Parameters:
query_id – experiment task ids. The maximum count is 50.
max_wait_time – maximum waiting time for querying experiments. Defaults to 60.
sleep_time – If query result failed, take a break and start again.
- Returns:
the experimental result list
- query_quantum_computer_list()
Get a full list of quantum computers, a list of simulators, and show the corresponding states.
- Returns:
List of quantum computers and related information.
- re_execute_task(query_id: str | None = None, lab_id: str | None = None)
Re-execute the experiment that has been run previously.
- Parameters:
query_id – query id
lab_id – resubmit all exp tasks in this lab set.
- Returns:
the query id for resubmitting the experiment
- run_experiment(exp_id: str, num_shots: int = 12000, is_verify: bool = True)
running the experiment returns the query result id.
- Parameters:
exp_id – experimental id. the id returned by the save_experiment interface.
num_shots – number of repetitions per experiment. Defaults to 12000.
is_verify – Is the circuit verified.
- Returns:
experiment task query id.
- save_experiment(lab_id: str, circuit: str, name: str | None = '', language: QuantumLanguage = QuantumLanguage.QCIS, **kwargs)
save the experiment and return the experiment ID. (Will not run immediately)
- Parameters:
lab_id – experiment lab ID
circuit – experiment circuit
name – experiment name
language – Quantum computer language, including [‘isq’, ‘quingo’, ‘qcis’].
kwargs – Optional attachment key word args.
- kwargs Description
noise: This parameter is a list of dictionaries, each describing a type of quantum noise model for simulations that utilize a noisy quantum simulator. Currently, only one noise model can be specified at a time, but future updates will allow multiple parameters.
This parameter allows the configuration of different types of quantum noise which affects the simulation by altering the state of qubits. The accepted noise types and their corresponding parameters are as follows:
bit-flip: Simulates the bit flip error, where a qubit state ∣0⟩ flips to ∣1⟩ and vice versa. The parameter is the probability pp of a bit flip occurring, typically set to a default value of 0.1.
` noise=[{"noise_type": "bit-flip", "params": [0.1]}] `phase-flip: Simulates the phase flip error, which flips the phase of a qubit. It takes a probability pp, with a typical default of 0.1.
` noise=[{"noise_type": "phase-flip", "params": [0.1]}] `depolarizing: Simulates a depolarizing channel, which can randomly alter the state of a qubit to any other state. It is defined by a probability pp, commonly set to 0.1 by default.
` noise=[{"noise_type": "depolarizing", "params": [0.1]}] `decoherence: Represents decoherence noise which is characterized by operational time, coherence time, and decoherence time. It’s defined by the parameters: operation time (default 0.5), coherence time (default 200), and decoherence time (default 30).
` noise=[{"noise_type": "decoherence", "params": [0.5, 200, 30]}] `quantum_state: This parameter specifies the state of the quantum simulation where only a single amplitude is simulated. It generally requires a parameter specifying the output state, with a default value of 0.
` quantum_state=1 `
- Returns:
experiment id
- set_machine(machine_name: str)
set the machine name.
- Parameters:
machine_name – name of quantum computer or simulator.
- stop_running_experiments(lab_id: str | None = None, query_id: str | None = None)
Terminate recently running experiments
- Parameters:
query_id – query id
lab_id – Terminate all exp tasks in this lab set.
- Returns:
the query id for stopped the experiment
- submit_job(circuit: List | str | None = None, exp_name: str | None = '', parameters: List[List] | None = None, values: List[List] | None = None, num_shots: int | None = 12000, lab_id: str | None = None, exp_id: str | None = None, language: QuantumLanguage = QuantumLanguage.QCIS, version: str | None = '1', is_verify: bool | None = True, **kwargs)
submit experimental tasks.
There are some parameter range limitations when using batch submission circuits.
- circuits length less than 50, num_shots maximum 100000, the number of measurement
qubits is less than 15.
circuits length greater than 50 but less than 100, num_shots maximum 50000, the number of measurement qubits is less than 30.
circuits length greater than 100 but less than 600, num_shots maximum 10000, the number of measurement bits is less than the number of all available qubits.
When the circuit is none, the exp_id cannot be none and the lab_id needs to be none,
- When the circuit is not none, when the circuit is multiple lines,
the version and exp_id need to be none, and the line will be saved under the default collection if the lab_id or exp_name is not transmitted.
- When the circuit is not none, when the circuit is a single line, exp_id need to be none,
version does not transmit to generate the default, lab_id or exp_name does not transmit the line is saved under the default collection.
- Parameters:
circuit – experimental content, qcis. Defaults to None.
exp_name – new experiment collection Name. Defaults to “exp0”.
parameters – parameters that need to be assigned in the experimental content.
values – The values corresponding to the parameters that need to be assigned in the experimental content. Defaults to None.
num_shots – number of repetitions per experiment. Defaults to 12000.
lab_id – the result returned by the create_experiment interface, experimental set id.
exp_id – the result returned by the save_experiment interface, experimental id.
language – quantum language code. Defaults to qcis.
version – version description. Defaults to ‘version01’.
is_verify – Is the circuit verified.True verify, False do not verify.
kwargs – Same as in save_experiment. Refer to the save_experiment function for details on the accepted parameters and usage examples.
- Returns:
If 0 failed, else return the query id if successful.
- Return type:
Union[int, str]
- class cqlib.quantum_platform.base.QuantumLanguage(value)
Bases:
EnumQuantum circuit language
- ISQ = 'isq'
- QCIS = 'qcis'
- QUINGO = 'quingo'
- cqlib.quantum_platform.base.format_circuit(circuit: str)
Parse circuit description and generate experiment script and extract number of measured qubits.
- Parameters:
circuit – circuit content
- Returns:
circuit
cqlib.quantum_platform.guodun module
GuoDun quantum platform
- class cqlib.quantum_platform.guodun.GuoDunPlatform(login_key: str, auto_login: bool = True, machine_name: str | None = None)
Bases:
BasePlatformGuoDun quantum platform test case
- CREATE_EXP_AND_RUN_PATH = '/experiment/sdk/experiment/temporary/save'
- CREATE_LAB_PATH = '/experiment/sdk/experiment/save'
- CREATE_WAVEFORM_DIAGRAM = '/experiment/sdk/generateWaveformDiagram'
- DOMAIN = 'quantumctek-cloud.com'
- DOWNLOAD_CONFIG_PATH = '/experiment/sdk/experiment/download/config'
- DOWN_WAVEFORM_DIAGRAM = '/experiment/sdk/getWaveformDiagram'
- GET_EXP_CIRCUIT_PATH = '/experiment/sdk/experiment/getQcis/by/taskIds'
- LOGIN_PATH = '/api-uaa/oauth/token'
- MACHINE_CONFIG_PATH = '/experiment/sdk/quantumComputer/config'
- MACHINE_LIST_PATH = '/experiment/sdk/quantumComputer/list'
- QCIS_CHECK_REGULAR_PATH = '/experiment/sdk/experiment/qcis/rule/verify'
- QUERY_EXP_PATH = '/experiment/sdk/experiment/result/find'
- RE_EXECUTE_TASK_PATH = '/experiment/sdk/experiment/resubmit'
- SAVE_EXP_PATH = '/experiment/sdk/experiment/detail/save'
- SCHEME = 'https'
- STOP_RUNNING_EXP_PATH = '/experiment/sdk/experiment/discontinue'
- create_waveform_data(circuit, circuit_name: str | None = None) int
Generates a waveform data for the given quantum circuit.
- Parameters:
circuit – The quantum circuit to visualize
circuit_name (Optional[str]) – Optional name for the circuit
- Returns:
The query_id of the generated waveform data
- Return type:
int
- Raises:
CqlibInputParaError – If required parameters are missing
- query_waveform_data(query_id: int) str
Get the waveform_data URL based on the provided query_id
- Parameters:
query_id (int or str) – The circuit ID .
- Returns:
The waveform_data_file download path or the URL.
- Return type:
str
- re_execute_task(query_id: str | None = None, lab_id: str | None = None)
Re-execute the experiment that has been run previously.
- Parameters:
query_id – query id
lab_id – resubmit all exp tasks in this lab set.
- Returns
the query id for resubmitting the experiment
- stop_running_experiments(lab_id: str | None = None, query_id: str | None = None)
Terminate recently running experiments
- Parameters:
query_id – query id
lab_id – Terminate all exp tasks in this lab set.
- Returns:
the query id for stopped the experiment
cqlib.quantum_platform.tianyan module
TianYan quantum platform
- class cqlib.quantum_platform.tianyan.TianYanPlatform(login_key: str, auto_login: bool = True, machine_name: str | None = None)
Bases:
BasePlatformTian yan quantum computing cloud quantum_platform
- CREATE_EXP_AND_RUN_PATH = '/qccp-quantum/sdk/experiment/temporary/save'
- CREATE_LAB_PATH = '/qccp-quantum/sdk/experiment/save'
- DOMAIN = 'qc.zdxlz.com'
- DOWNLOAD_CONFIG_PATH = '/qccp-quantum/sdk/experiment/download/config'
- GET_EXP_CIRCUIT_PATH = '/qccp-quantum/sdk/experiment/getQcis/by/taskIds'
- LOGIN_PATH = '/qccp-auth/oauth2/sdk/opnId'
- MACHINE_LIST_PATH = '/qccp-quantum/sdk/quantumComputer/list'
- QCIS_CHECK_REGULAR_PATH = '/qccp-quantum/sdk/experiment/qcis/rule/verify'
- QUERY_EXP_PATH = '/qccp-quantum/sdk/experiment/result/find'
- RE_EXECUTE_TASK_PATH = '/qccp-quantum/sdk/experiment/resubmit'
- RUN_EXP_PATH = '/qccp-quantum/sdk/experiment/detail/run'
- SAVE_EXP_PATH = '/qccp-quantum/sdk/experiment/detail/save'
- SCHEME = 'https'
- STOP_RUNNING_EXP_PATH = ''
- SUBMIT_EXP_PATH = '/qccp-quantum/sdk/experiment/submit'
- download_fsim_config(machine: str | None = None, read_time: str | None = None) dict[tuple[str, str], dict[str, float]]
download FSIM experimental parameters.
- Parameters:
read_time – select configuration data according to the reading time, and the parameter format is yyyy-MM-dd HH:mm:ss, Defaults to None.
machine – machine name
- Returns:
0 failed, not 0 successful, success returns the experimental parameters.
- query_experiment(query_id: str | list[str], max_wait_time: int = 3600, sleep_time: int = 5, readout_calibration: bool = False, machine_config: dict | None = None)
query the experiment result.
- Parameters:
query_id – experiment task ids. The maximum count is 50.
max_wait_time – maximum waiting time for querying experiments. Defaults to 3600.
sleep_time – If query result failed, take a break and start again.
readout_calibration – readout correction for quantum measurements. Defaults to False.
machine_config – Optional machine configuration. If not provided, will attempt to download configuration automatically when readout_calibration is True.
- run_experiment(exp_id: str, num_shots: int = 12000, is_verify: bool = True)
running the experiment returns the query result id.
- Parameters:
exp_id – experimental id. the id returned by the save_experiment interface.
num_shots – number of repetitions per experiment. Defaults to 12000.
is_verify – Is the circuit verified.
- Returns:
experiment task query id.
- submit_experiment(circuit: str | list[str], language: QuantumLanguage = QuantumLanguage.QCIS, name: str | None = None, parameters: list[list[str]] | None = None, values: list[list[float]] | None = None, lab_id: str | None = None, lab_name: str | None = None, num_shots: int = 12000, machine_name: str | None = None, is_verify: bool = True, **kwargs)
running the experiment returns the query result id.
- Parameters:
circuit – experimental content, qcis. Defaults to None.
language – quantum language code. Defaults to qcis.
name – new experiment collection Name.
parameters – parameters that need to be assigned in the experimental content.
values – The values corresponding to the parameters that need to be assigned in the experimental content. Defaults to None.
lab_id – the result returned by the create_experiment interface, experimental set id.
lab_name – defined lab name.
num_shots – number of repetitions per experiment. Defaults to 12000.
machine_name – specified which machine to use.
is_verify – Is the circuit verified.
- Returns:
experiment task query id.