tensorcircuit.cloud.abstraction#

Abstraction for Provider, Device and Task

class tensorcircuit.cloud.abstraction.Device(name: str, provider: Optional[Union[str, tensorcircuit.cloud.abstraction.Provider]] = None, lower: bool = False)[source]#

Bases: object

Device abstraction for cloud connection, eg. quantum chips

__init__(name: str, provider: Optional[Union[str, tensorcircuit.cloud.abstraction.Provider]] = None, lower: bool = False)[source]#
activated_devices: Dict[str, tensorcircuit.cloud.abstraction.Device] = {'tencent::simulator:tc': tencent::simulator:tc}#
classmethod from_name(device: Union[str, tensorcircuit.cloud.abstraction.Device], provider: Optional[Union[str, tensorcircuit.cloud.abstraction.Provider]] = None) β†’ tensorcircuit.cloud.abstraction.Device[source]#
get_task(taskid: str) β†’ tensorcircuit.cloud.abstraction.Task[source]#
get_token() β†’ Optional[str][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[tensorcircuit.cloud.abstraction.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[tensorcircuit.cloud.abstraction.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) β†’ networkx.classes.graph.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, tensorcircuit.cloud.abstraction.Provider] = {'tencent': tencent}#
classmethod from_name(provider: Union[str, tensorcircuit.cloud.abstraction.Provider] = 'tencent') β†’ tensorcircuit.cloud.abstraction.Provider[source]#
get_device(device: Optional[Union[str, tensorcircuit.cloud.abstraction.Device]]) β†’ tensorcircuit.cloud.abstraction.Device[source]#
get_token() β†’ str[source]#
list_devices(**kws: Any) β†’ Any[source]#
list_tasks(**filter_kws: Any) β†’ List[tensorcircuit.cloud.abstraction.Task][source]#
set_token(token: str, cached: bool = True) β†’ Any[source]#
exception tensorcircuit.cloud.abstraction.TCException[source]#

Bases: BaseException

__init__(*args, **kwargs)#
args#
with_traceback()#

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

class tensorcircuit.cloud.abstraction.Task(id_: str, device: Optional[tensorcircuit.cloud.abstraction.Device] = None)[source]#

Bases: object

Task abstraction for quantum jobs on the cloud

__init__(id_: str, device: Optional[tensorcircuit.cloud.abstraction.Device] = 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() β†’ tensorcircuit.cloud.abstraction.Device[source]#

Query which device the task is run on

Returns

_description_

Return type

Device

get_logical_physical_mapping() β†’ Optional[Dict[int, int]][source]#
resubmit() β†’ tensorcircuit.cloud.abstraction.Task[source]#

resubmit the task

Returns

the resubmitted task

Return type

Task

results(format: Optional[str] = None, blocked: bool = True, mitigated: bool = False, calibriation_options: Optional[Dict[str, Any]] = None, readout_mit: Optional[tensorcircuit.results.readout_mitigation.ReadoutMit] = None, mitigation_options: Optional[Dict[str, Any]] = 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: tensorcircuit.cloud.abstraction.TCException

__init__(*args, **kwargs)#
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: tensorcircuit.cloud.abstraction.TaskException

__init__(taskid: str, state: str, message: str)[source]#
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: tensorcircuit.cloud.abstraction.TaskException

__init__(taskid: str, state: str)[source]#
args#
with_traceback()#

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