isqtools.backend.quafu_backend package

Submodules

isqtools.backend.quafu_backend.qua_task module

class Task(user=None)

Bases: object

Class for submitting quantum computation task to the backend.

shots

Numbers of single shot measurement.

Type:

int

compile

Whether compile the circuit on the backend

Type:

bool

tomo

Whether do tomography (Not support yet)

Type:

bool

user

User object corresponding to Quafu account

Type:

User

priority

priority level of the task

Type:

int

submit_history

circuit submitted with this task

Type:

dict

backend

quantum backend that execute the task.

Type:

dict

Parameters:

user (None)

check_valid_gates(qc)

Check the validity of the quantum circuit. :type qc: None :param qc: QuantumCicuit object that need to be checked.

Return type:

None

config(backend='ScQ-P10', shots=1000, compile=True, tomo=False, priority=2)

Configure the task properties

Parameters:
  • backend (str) – Select the experimental backend.

  • shots (int) – Numbers of single shot measurement.

  • compile (bool) – Whether compile the circuit on the backend

  • tomo (bool) – Whether to do tomography (Not support yet)

  • priority (int) – Task priority.

Return type:

None

get_backend_info()

Get the calibration information of the experimental backend.

Return type:

Dict

Returns:

Backend information dictionary containing the mapping from the indices to the names of physical bits ‘mapping’, backend topology ‘topology_diagram’ and full calibration inforamtion ‘full_info’.

get_history()

Get the history of submitted task. :rtype: Dict :returns: A dict of history. The key is the group name and the value is a list of task id in the group.

retrieve(taskid)

Retrieve the results of submited task by taskid.

Parameters:

taskid (str) – The taskid of the task need to be retrieved.

Return type:

None

retrieve_group(group, history=None, verbose=True)

Retrieve the results of submited task by group name.

Parameters:
  • group (str) – The group name need to be retrieved.

  • history (Dict) – History from which to retrieve the results. If not provided, the history will be the submit history of saved by current task.

  • verbose (bool) – Whether print the task status in the group.

Return type:

List[None]

Returns:

A list of execution results in the retrieved group. Only completed task will be added.

run(qc, measure_base=None)

Single run for measurement task.

Parameters:
  • qc (QuantumCircuit) – Quantum circuit that need to be executed on backend.

  • measure_base (list[str, list[int]]) – measure base and its positions.

Return type:

None

send(qc, name='', group='', wait=False)

Run the circuit on experimental device.

Parameters:
  • qc (None) – Quantum circuit that need to be executed on backend.

  • name (str) – Task name.

  • group (str) – The task belong which group.

  • wait (bool) – Whether wait until the execution return.

Returns:

object that contain the dict return from quantum device. taskid: the id of the task.

Return type:

ExecResult

submit(qc, obslist=None)

Execute the circuit with observable expectation measurement task. :type qc: None :param qc: Quantum circuit that need to be executed on backend. :type qc: QuantumCircuit :type obslist: Optional[List] :param obslist: List of pauli string and its position. :type obslist: list[str, list[int]]

Return type:

Tuple[List[None], List[int]]

Returns:

List of executed results and list of measured observable

Examples

  1. input [[“XYX”, [0, 1, 2]], [“Z”, [1]]] measure pauli operator XYX at 0, 1, 2 qubit, and Z at 1 qubit.

  2. Measure 5-qubit Ising Hamiltonian we can use

obslist = [[“X”, [i]] for i in range(5)]]

obslist.extend([[“ZZ”, [i, i+1]] for i in range(4)])

For the energy expectation of Ising Hamiltonian

res, obsexp = q.submit_task(obslist)

E = sum(obsexp)

isqtools.backend.quafu_backend.quafu_backend module

class QuafuBackend(machine_name='Baihua', token=None)

Bases: HardwareBackend

the backend of quafu quantum hardware

Parameters:
  • machine_name (str)

  • token (str)

property available_backends

get available backends in quadu

static check(line_data)

检查qcis代码,获取qubit字符串表示同qubit索引的映射dict. line_data(list[str]): qcis command with str command of each line in the list. :returns: qubit mapping dictionary {“Q0”: 0, “Q1”: 1, …}.

qnum(int): qubit number

Return type:

qdic(dict)

Parameters:

line_data (list[str])

get_cq(line_data, qdic, qnum)
Parameters:
  • line_data (list[str]) – qcis command with str command of each line in the list.

  • qdic (dict) – qubit mapping dictionary {“Q0”: 0, “Q1”: 1, …}.

  • qnum (int)

Return type:

None

get_ir()

String for the name of the operator.

query_sample_result(task_id)
Return type:

dict[str, int]

sample(qcis, shots=100)
Return type:

str

qcis: qcis command in string format connected by ‘ ‘

exception QuafuBackendError

Bases: Exception

Quafu backend error

Module contents