wy_qcos.drivers package
Subpackages
- wy_qcos.drivers.cascoldatom package
- wy_qcos.drivers.ciqtek package
- wy_qcos.drivers.dummy package
- wy_qcos.drivers.qboson package
- wy_qcos.drivers.qiskit package
- wy_qcos.drivers.qutip package
- wy_qcos.drivers.spinq package
- wy_qcos.drivers.uqc package
Submodules
wy_qcos.drivers.device module
- class wy_qcos.drivers.device.Device(name, driver)
基类:
objectDevice.
- DEVICE_STATUS_ONLINE = 'online'
- DEVICE_STATUS_OFFLINE = 'offline'
- DEVICE_STATUS_BUSY = 'busy'
- DEVICE_STATUS_CALIBRATING = 'calibrating'
- DEVICE_STATUS_MAINTAIN = 'maintain'
- DEVICE_STATUS_UNKNOWN = 'unknown'
- DEVICE_STATUSES = ['online', 'offline', 'busy', 'calibrating', 'maintain', 'unknown']
- init_device()
Init device.
- 返回:
success, err_msgs
- get_name()
Get device name.
- 返回:
device name
- get_driver()
Get device driver.
- 返回:
device driver
- set_enable(enable)
Set enable.
- 参数:
enable -- enable or disable
- get_enable()
Get enable.
- 返回:
enable or disable
- set_status(status)
Set device status.
- 参数:
status -- device status
- get_status()
Get device status.
- set_alias_name(alias_name)
Set device alias name.
- 参数:
alias_name -- device alias name
- get_alias_name()
Get device alias name.
- 返回:
device alias name
- set_description(description)
Set device description.
- 参数:
description -- device description
- get_description()
Get device description.
- 返回:
device description
- set_configs(configs)
Set device configs.
- 参数:
configs -- device configs
- get_configs(hide_password=False)
Get device configs.
- 参数:
hide_password -- hide device password
- 返回:
device configs
- set_device_detail(details)
Set device details.
- 参数:
details -- device details
- set_device_running_info(device_running_info)
Set device running info.
- 参数:
device_running_info -- device running info
- show_device_info()
Show device info.
- set_max_qubits(max_qubits)
Set device max qubits.
- 参数:
max_qubits -- device max qubits
- set_device_options_info(device_options_info)
Set device option info.
- 参数:
device_options_info -- device option info
- get_device_options_info()
Get device option info.
- 返回:
device option info
- set_max_queued_jobs(max_queued_jobs)
Set Max Queued Kobs.
- 参数:
max_queued_jobs (int) -- max_queued_jobs
- get_max_queued_jobs()
Set Max Queued Kobs.
- 返回:
max_queued_jobs
wy_qcos.drivers.device_manager module
- class wy_qcos.drivers.device_manager.DeviceManager(config, driver_manager)
基类:
objectDevice manager.
- load_devices()
Scan and load drivers.
- check_redis_connection()
Check connection to redis.
- init_devices()
Init devices.
- has_device(device_name)
Has device.
- 参数:
device_name -- device name
- 返回:
True or False
- get_device(device_name)
Get device.
- 参数:
device_name -- device name
- 返回:
device instance
- get_devices()
Get devices.
- 返回:
dict of device instances
- subscribe_device_info(redis_instance, device)
Subscribe device info by redis.
wy_qcos.drivers.driver_base module
- class wy_qcos.drivers.driver_base.DriverBase
基类:
objectQuantum Computer base driver.
- DATA_TYPE_GATE_SEQUENCE = 'gate_sequence'
- DATA_TYPE_QUBO = 'qubo'
- DATA_TYPE_QASM2 = 'qasm2'
- DATA_TYPE_QASM3 = 'qasm3'
- DATA_TYPES = ['gate_sequence', 'qubo', 'qasm2', 'qasm3']
- TASK_STAGE_START = 'start'
- TASK_STAGE_INIT = 'init'
- TASK_STAGE_LOADING = 'loading'
- TASK_STAGE_VALIDATING = 'validating'
- TASK_STAGE_USER_AUTHENTICATION = 'user_authentication'
- TASK_STAGE_CHECK_DEVICE_STATUS = 'check_device_status'
- TASK_STAGE_COMPILE = 'compile'
- TASK_STAGE_UPLOAD_FILE = 'upload_file'
- TASK_STAGE_PREPARE_DATA = 'prepare_data'
- TASK_STAGE_SUBMIT_TASK = 'submit_task'
- TASK_STAGE_WAIT_TASK = 'wait_task'
- TASK_STAGE_GET_RESULTS = 'get_results'
- TASK_STAGE_COMPLETE = 'complete'
- default_headers = {'accept': 'application/json, text/plain, */*', 'accept-language': 'zh-CN'}
- auth_headers = {'Authorization': None, 'accept': 'application/json, text/plain, */*', 'accept-language': 'zh-CN'}
- temp_driver_dir = '//tmp/qcos/drivers/'
- validate_driver()
Validate driver.
- validate_driver_configs(configs)
Validate driver configs.
- 参数:
configs -- configs to validate
- 返回:
success, err_msgs
- init_driver()
Init driver.
- close_driver()
Close driver.
- get_driver_options_schema()
Get driver options schema.
- 返回:
driver options schema
- update_driver_options(driver_options)
Update driver options.
- 参数:
driver_options -- new driver options
- get_driver_info()
Show driver info.
- set_name(name)
Set driver name.
- 参数:
name -- driver_name
- get_name()
Get driver name.
- 返回:
driver name
- set_alias_name(alias_name)
Set driver alias name.
- 参数:
alias_name -- alias_name
- get_alias_name()
Get driver alias name.
- 返回:
driver alias name
- get_description()
Get driver description.
- 返回:
driver description
- set_module_name(module_name)
Set module name.
- 参数:
module_name -- module name
- get_module_name()
Get module name.
- 返回:
module name
- set_package_paths(package_paths)
Set package paths.
- 参数:
package_paths (list) -- package path list
- get_package_paths()
Get package paths.
- 返回:
package path list
- set_class_name(class_name)
Set class name.
- 参数:
class_name -- class name
- get_class_name()
Get class name.
- 返回:
class name
- get_transpiler()
Get transpiler.
- get_supported_code_types()
Get supported code types.
- set_supported_code_types(supported_code_types)
Set supported code types.
- get_supported_basis_gates()
Get supported basis gates.
- 返回:
list of supported basis gates
- get_supported_transpilers()
Get supported transpilers.
- 返回:
list of supported transpilers
- get_tech_type()
Get tech type.
- set_progress(progress)
Set progress.
- 参数:
progress -- progress percentage in integer between 0 and 100
- set_progress_by_task(task_name)
Set progress by task name.
- 参数:
task_name -- task name
- get_progress()
Get progress.
- 返回:
progress percentage in integer between 0 and 100
- set_device_status(device_status)
Set device status.
- 参数:
device_status -- device status
- set_configs(configs)
Set configs.
- 参数:
configs -- configs to set
- get_configs()
Get configs.
- 返回:
configs
- fetch_configs()
Fetch configs.
- 返回:
remote transpiler configs
- run(job_id, num_qubits, data, data_type=DATA_TYPE_GATE_SEQUENCE, shots=1)
Run job.
- 参数:
job_id -- job ID
num_qubits -- number of qubits
data -- data
data_type -- data type (Default value = DATA_TYPE_GATE_SEQUENCE)
shots -- shots (Default value = 1)
- dry_run(job_id, num_qubits, data, data_type=DATA_TYPE_GATE_SEQUENCE, shots=1)
Dry-run job.
- 参数:
job_id -- job ID
num_qubits -- number of qubits
data -- data
data_type -- data type (Default value = DATA_TYPE_GATE_SEQUENCE)
shots -- shots (Default value = 1)
- cancel(job_id)
Cancel running job in driver.
Driver should clean up any resources of the job
- 参数:
job_id -- job ID
- set_results(job_id, data_index, results)
Set job results.
Sample: results = {"00": 9, "11": 1}.
- 参数:
job_id -- job ID
data_index -- code index
results -- results
- get_results(job_id=None, data_index=None)
Get results.
- 参数:
job_id -- job ID (Default value = None)
data_index -- code index (Default value = None)
- 返回:
results
- set_machine_time_info(job_id, data_index, machine_time_info)
Set machine time info.
- 参数:
job_id -- job ID
data_index -- code index
machine_time_info -- machine_time_info
- get_machine_time_info(job_id=None, data_index=None)
Get machine_time_info.
- 参数:
job_id -- job ID (Default value = None)
data_index -- code index (Default value = None)
- 返回:
machine_time_info
- get_default_data_type()
Get default data type.
- 返回:
default data type
- set_max_qubits(max_qubits)
Set max qubits.
- 参数:
max_qubits -- max qubits
- get_max_qubits()
Get max qubits.
- 返回:
max qubits
- get_fake_results(num_qubits, shots, data)
Get fake results.
- 参数:
num_qubits -- number of qubits
shots -- number of shots
data -- source data
- get_enable_wirecut()
Get enable wirecut.
- 返回:
enable wirecut
- 返回类型:
bool
- get_driver_options()
Get driver options.
- 返回:
driver options
- 返回类型:
dict
- calibrate_device(data)
Calibrate device.
- 参数:
data -- calibration data
- set_device_options(data)
Set Device options.
- 参数:
data -- Device options data
- get_device_options(data)
Get Device options.
- 参数:
data -- data
- fetch_running_info()
Fetch running info.
- 返回:
remote device running info
wy_qcos.drivers.driver_errors module
- exception wy_qcos.drivers.driver_errors.DriverException
基类:
ExceptionDriver base exception.
-
Driver exception: service unavailable.
wy_qcos.drivers.driver_manager module
- class wy_qcos.drivers.driver_manager.DriverManager
基类:
objectDriver manager.
- load_drivers()
Scan and load drivers.
- init_drivers()
Init drivers.
- has_driver(driver_name)
Has driver.
- 参数:
driver_name -- driver name
- 返回:
True or False
- get_driver(driver_name)
Get driver.
- 参数:
driver_name -- driver name
- get_drivers()
Get drivers.
- 返回:
dict of drivers
wy_qcos.drivers.driver_qubo_base module
- class wy_qcos.drivers.driver_qubo_base.DriverQuboBase
基类:
DriverBaseQUBO驱动基类.
QUBO Base driver
- get_fake_results(num_qubits, shots, data)
Get fake results.
- 参数:
num_qubits -- number of qubits
shots -- number of shots
data -- source data
- get_enable_subqubo()
Get enable subqubo.
- 返回:
enable subqubo
- 返回类型:
bool
- get_enable_prec_reduce()
Get enable precision reduction.
- 返回:
enable precision reduction
- 返回类型:
bool
wy_qcos.drivers.driver_wuyue_base module
- class wy_qcos.drivers.driver_wuyue_base.DriverWuyueBase
基类:
DriverBaseWuyue驱动基类.
Wuyue Base driver
- submit_path = 'submit'
- query_task_path = 'query_task'
- query_param = 'task/WuYue/queryParam'
- task_status_submitted = 1
- task_status_queuing = 2
- task_status_computing = 3
- task_status_pending = 4
- task_status_completed = 5
- task_status_failed = 6
- default_headers = {'accept': 'application/json, */*', 'accept-language': 'zh-CN'}
- init_driver()
Init driver.
- validate_driver_configs(configs)
Validate driver configs.
- 参数:
configs -- configs dictionary
- 返回:
success, err_msg
- close_driver()
Close driver.
- fetch_configs()
Fetch configs.
- 返回:
remote transpiler configs
- convert_code(num_qubits, src_code, transpile_results)
Convert code.
- 参数:
num_qubits (int) -- num qubits
src_code (str) -- src code
transpile_results -- transpile results
- 返回:
converted code
- run(job_id, num_qubits, data, data_type, shots=1)
Run job.
- 参数:
job_id -- job ID
num_qubits -- number of qubits
data -- data
data_type -- data type
shots -- shots (Default value = 1)
- cancel(job_id)
Cancel running job in driver.
Driver should clean up any resources of the job
- 参数:
job_id -- job ID
- format_item(item)
Format list item.
- 参数:
item -- list item
- 返回:
formatted list item
- prepare_sign(data)
Prepare sign data.
- 参数:
data -- raw data
- 返回:
signed value
- encrypt_by_public_key(raw_data)
Encrypt by pub key.
- 参数:
raw_data -- raw_data
- 返回:
encryptted data
- decrypt_by_private_key(raw_data)
decrypt_by_private_key.
- 参数:
raw_data -- raw_data
- 返回:
decryptted data
- prepare_submit_data(job_id, src_code, shots, data_index)
Prepare submit data.
- 参数:
job_id -- job_id
src_code -- src_code
shots -- shots
data_index -- data_index
- 返回:
prepared task data
- submit_tasks(task_data)
Submit tasks.
- 参数:
task_data -- task_data
- 返回:
success or fail, error message
- check_task_status(task_id, expect_task_status)
Check task status meets requirements.
- 参数:
task_id -- task id
expect_task_status -- expect task status list
- 返回:
True if task status meets requirements, False otherwise
- prepare_query_task_data(task_id)
prepare_query_task_data.
- 参数:
task_id -- task ID
- 返回:
query task data
- construct_machine_time_info(data)
Construct machine time info.
- 参数:
data (dict) -- response data
- 返回:
machine_time_info
- 返回类型:
dict
- get_task_realtime_result(task_id)
Get task realtime result.
- 参数:
task_id -- task ID
- 返回:
success or fail, error message, task status
- get_task_results(task_id)
Get task results.
- 参数:
task_id -- task id
- 返回:
success or fail, error message, task results
- get_device_info()
Get device info.
- 返回:
device info
- fetch_running_info()
Fetch running info.
- 返回:
remote device running info