rho_m_core¶

Post Processing - Classical Shadow - Rho M Core (qurry.process.classical_shadow.rho_m_core)

qurry.process.classical_shadow.rho_m_core.RhoMCoreMethod¶

Type for rho_m_core method. It can be either “numpy”, “numpy_precomputed” or “numpy_flatten”. - “numpy”: Use Numpy to calculate the rho_m. - “numpy_precomputed”: Use Numpy to calculate the rho_m with precomputed values. - “numpy_flatten”: Use Numpy to calculate the rho_m with a flattening workflow. Currently, “numpy_precomputed” is the best option for performance.

alias of Literal[‘numpy’, ‘numpy_precomputed’] | str | Literal[‘numpy_flatten’, ‘jax_flatten’]

qurry.process.classical_shadow.rho_m_core.rho_m_core(shots: int, counts: list[dict[str, int]], random_unitary_um: dict[int, dict[int, Literal[0, 1, 2] | int]], selected_classical_registers: list[int], rho_method: Literal['numpy', 'numpy_precomputed'] | str | Literal['numpy_flatten', 'jax_flatten'] = 'numpy_precomputed') tuple[list[ndarray[tuple[int, int], dtype[complex128]]], list[int], float][source]¶

Rho M Cell Core calculation.

Parameters:
  • shots (int) – The number of shots.

  • counts (list[dict[str, int]]) – The list of the counts.

  • random_unitary_um (dict[int, dict[int, Union[Literal[0, 1, 2], int]]]) – The shadow direction of the unitary operators.

  • selected_classical_registers (list[int]) – The list of the index of the selected_classical_registers.

  • rho_method (RhoMCoreMethod, optional) –

    The method to use for the calculation. Defaults to “numpy_precomputed”. It can be either “numpy”, “numpy_precomputed”, “jax_flatten”, or “numpy_flatten”. - “numpy”:

    Use Numpy to calculate the rho_m.

    • ”numpy_precomputed”:

      Use Numpy to calculate the rho_m with precomputed values.

    • ”numpy_flatten”:

      Use Numpy to calculate the rho_m with a flattening workflow.

    Currently, “numpy_precomputed” is the best option for performance.

Returns:

tuple[

list[np.ndarray[tuple[int, int], np.dtype[np.complex128]]], list[int], float

]:

The dictionary of rho_m, the sorted list of the selected qubits, and calculation time.

qurry.process.classical_shadow.rho_m_core.rho_m_core_py(shots: int, counts: list[dict[str, int]], random_unitary_um: dict[int, dict[int, Literal[0, 1, 2] | int]], selected_classical_registers: list[int], rho_method: Literal['numpy', 'numpy_precomputed'] | str = 'numpy_precomputed') tuple[list[ndarray[tuple[int, int], dtype[complex128]]], list[int], float][source]¶

Rho M Cell Core calculation.

Parameters:
  • shots (int) – The number of shots.

  • counts (list[dict[str, int]]) – The list of the counts.

  • random_unitary_um (dict[int, dict[int, Union[Literal[0, 1, 2], int]]]) – The shadow direction of the unitary operators.

  • selected_classical_registers (list[int]) – The list of the index of the selected_classical_registers.

  • rho_method (RhoMKCellMethod, optional) – The method to use for the calculation. Defaults to “Python_precomputed”. - “numpy”: Use Numpy to calculate the rho_m. - “numpy_precomputed”: Use Numpy to calculate the rho_m with precomputed values.

Returns:

tuple[

list[np.ndarray[tuple[int, int], np.dtype[np.complex128]]], list[int], float

]:

The dictionary of rho_m, the sorted list of the selected qubits, and calculation time.