tensorcircuit.cloud.abstractionΒΆ

Abstraction for Provider, Device and Task

class tensorcircuit.cloud.abstraction.Device(name: str, provider: str | Provider | None = None, lower: bool = False)[source]ΒΆ

Bases: object

Device abstraction for cloud connection, eg. quantum chips

__init__(name: str, provider: str | Provider | None = None, lower: bool = False)[source]ΒΆ
activated_devices: Dict[str, Device] = {'tencent::simulator:tc': tencent::simulator:tc}ΒΆ
classmethod from_name(device: str | Device, provider: str | Provider | None = None) Device[source]ΒΆ
get_task(taskid: str) Task[source]ΒΆ
get_token() str | None[source]ΒΆ
list_properties() Dict[str, Any][source]ΒΆ

List all device properties in as dict

Returns:

[description]

Return type:

Dict[str, Any]

list_tasks(**filter_kws: Any) List[Task][source]ΒΆ
native_gates() List[str][source]ΒΆ

List native gates supported for the device, str conforms qiskit convention

Returns:

_description_

Return type:

List[str]

set_token(token: str, cached: bool = True) Any[source]ΒΆ
submit_task(**task_kws: Any) List[Task][source]ΒΆ
topology() List[Tuple[int, int]][source]ΒΆ

Get the bidirectional topology link list of the device

Returns:

[description]

Return type:

List[Tuple[int, int]]

topology_graph(visualize: bool = False) Graph[source]ΒΆ

Get the qubit topology in nx.Graph or directly visualize it

Parameters:

visualize (bool, optional) – [description], defaults to False

Returns:

[description]

Return type:

nx.Graph

class tensorcircuit.cloud.abstraction.Provider(name: str, lower: bool = True)[source]ΒΆ

Bases: object

Provider abstraction for cloud connection, eg. β€œtencent”, β€œlocal”

__init__(name: str, lower: bool = True)[source]ΒΆ
activated_providers: Dict[str, Provider] = {'tencent': tencent}ΒΆ
classmethod from_name(provider: str | Provider = 'tencent') Provider[source]ΒΆ
get_device(device: str | Device | None) Device[source]ΒΆ
get_token() str[source]ΒΆ
list_devices(**kws: Any) Any[source]ΒΆ
list_tasks(**filter_kws: Any) List[Task][source]ΒΆ
set_token(token: str, cached: bool = True) Any[source]ΒΆ
exception tensorcircuit.cloud.abstraction.TCException[source]ΒΆ

Bases: BaseException

__init__(*args, **kwargs)ΒΆ
add_note()ΒΆ

Exception.add_note(note) – add a note to the exception

argsΒΆ
with_traceback()ΒΆ

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class tensorcircuit.cloud.abstraction.Task(id_: str, device: Device | None = None)[source]ΒΆ

Bases: object

Task abstraction for quantum jobs on the cloud

__init__(id_: str, device: Device | None = None)[source]ΒΆ
add_details(**kws: Any) None[source]ΒΆ
details(blocked: bool = False, **kws: Any) Dict[str, Any][source]ΒΆ

Get the current task details

Parameters:
  • blocked (bool) – whether return until task is finished, defaults to False

  • wait (bool) – alias for the argument blocked

Returns:

_description_

Return type:

Dict[str, Any]

get_device() Device[source]ΒΆ

Query which device the task is run on

Returns:

_description_

Return type:

Device

get_logical_physical_mapping() Dict[int, int] | None[source]ΒΆ
more_details: Dict[str, Any]ΒΆ
resubmit() Task[source]ΒΆ

resubmit the task

Returns:

the resubmitted task

Return type:

Task

results(format: str | None = None, blocked: bool = True, mitigated: bool = False, calibriation_options: Dict[str, Any] | None = None, readout_mit: ReadoutMit | None = None, mitigation_options: Dict[str, Any] | None = None) Dict[str, int][source]ΒΆ

get task results of the qjob

Parameters:
  • format (Optional[str], optional) – unsupported now, defaults to None, which is β€œcount_dict_bin”

  • format – alias for the argument format

  • blocked (bool, optional) – whether blocked to wait until the result is returned, defaults to False, which raise error when the task is unfinished

  • wait (bool, optional) – alias for the argument blocked

  • mitigated (bool, optional) – whether enable readout error mitigation, defaults to False

  • calibriation_options (Optional[Dict[str, Any]], optional) – option dict for ReadoutMit.cals_from_system, defaults to None

  • readout_mit (Optional[rem.ReadoutMit], optional) – if given, directly use the calibriation info on readout_mit, defaults to None

  • mitigation_options (Optional[Dict[str, Any]], optional) – option dict for ReadoutMit.apply_correction, defaults to None

Returns:

count dict results

Return type:

Any

state() str[source]ΒΆ

Query the current task status

Returns:

_description_

Return type:

str

status() strΒΆ

Query the current task status

Returns:

_description_

Return type:

str

exception tensorcircuit.cloud.abstraction.TaskException[source]ΒΆ

Bases: TCException

__init__(*args, **kwargs)ΒΆ
add_note()ΒΆ

Exception.add_note(note) – add a note to the exception

argsΒΆ
with_traceback()ΒΆ

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception tensorcircuit.cloud.abstraction.TaskFailed(taskid: str, state: str, message: str)[source]ΒΆ

Bases: TaskException

__init__(taskid: str, state: str, message: str)[source]ΒΆ
add_note()ΒΆ

Exception.add_note(note) – add a note to the exception

argsΒΆ
with_traceback()ΒΆ

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception tensorcircuit.cloud.abstraction.TaskUnfinished(taskid: str, state: str)[source]ΒΆ

Bases: TaskException

__init__(taskid: str, state: str)[source]ΒΆ
add_note()ΒΆ

Exception.add_note(note) – add a note to the exception

argsΒΆ
with_traceback()ΒΆ

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.