tensorcircuit.cloud.wrapper#

higher level wrapper shortcut for submit_task

tensorcircuit.cloud.wrapper.batch_expectation_ps(c: tensorcircuit.circuit.Circuit, pss: List[List[int]], device: Optional[Any] = None, ws: Optional[List[float]] = None, shots: int = 8192, with_rem: bool = True, compile_func: Optional[Callable[[tensorcircuit.circuit.Circuit], Tuple[tensorcircuit.circuit.Circuit, Dict[str, Any]]]] = None, batch_limit: int = 64, batch_submit_func: Optional[Callable[[...], List[Dict[str, int]]]] = None) → Union[Any, List[Any]][source]#

Unified interface to compute the Pauli string expectation lists or sums via simulation or on real qpu. Error mitigation, circuit compilation and Pauli string grouping are all built-in.

One line access to unlock the whole power or real quantum hardware on quantum cloud.

Example

c = tc.Circuit(2)
c.h(0)
c.x(1)
tc.cloud.wrapper.batch_expectation_ps(c, [[1, 0], [0, 3]], device=None)
# array([ 0.99999994, -0.99999994], dtype=float32)
tc.cloud.wrapper.batch_expectation_ps(c, [[1, 0], [0, 3]], device="tencent::9gmon")
# array([ 1.03093477, -1.11715944])
Parameters
  • c (Circuit) – The target circuit to compute expectation

  • pss (List[List[int]]) – List of Pauli string list, eg. [[0, 1, 0], [2, 3, 3]] represents [X1, Y0Z1Z2].

  • device (Any, optional) – The device str or object for quantum cloud module, defaults to None, None is for analytical exact simulation

  • ws (Optional[List[float]], optional) – List of float to indicate the final return is the weighted sum of Pauli string expectations, e.g. [2., -0.3] represents the final results is 2* pss [0]-0.3* pss [1] defaults to None, None indicate the list of expectations for pss are all returned

  • shots (int, optional) – measurement shots for each expectation estimation, defaults to 8192

  • with_rem (bool, optional) – whether enable readout error mitigation for the result, defaults to True

Returns

List of Pauli string expectation or a weighted sum float for Pauli strings, depending on ws

Return type

Union[Any, List[Any]]

tensorcircuit.cloud.wrapper.batch_submit_template(device: str, batch_limit: int = 64, **kws: Any) → Callable[[...], List[Dict[str, int]]][source]#
tensorcircuit.cloud.wrapper.reduce_and_evaluate(cs: List[tensorcircuit.circuit.Circuit], shots: int, run: Callable[[...], Any]) → List[Dict[str, int]][source]#
tensorcircuit.cloud.wrapper.sample_expectation_ps(c: tensorcircuit.circuit.Circuit, x: Optional[Sequence[int]] = None, y: Optional[Sequence[int]] = None, z: Optional[Sequence[int]] = None, shots: int = 1024, device: Optional[tensorcircuit.cloud.abstraction.Device] = None, **kws: Any) → float[source]#

Deprecated, please use tensorcircuit.cloud.wrapper.batch_expectation_ps().