qdk_chemistry.algorithms.time_evolution.builder.partially_randomized module

QDK/Chemistry implementation of partially randomized product formula builder.

This module implements a hybrid approach that combines deterministic Trotter decomposition for large-weight terms with qDRIFT-style randomized sampling for small-weight terms. This is particularly effective for quantum chemistry Hamiltonians where a few terms dominate the weight while many small terms form a long tail.

The method is based on:

Günther, J., Witteveen, F., et al. (2025). Phase estimation with partially randomized time evolution. https://doi.org/10.48550/arXiv.2503.05647

See also

  • Hagan, M., & Wiebe, N. (2023). Composite randomized benchmarking.

  • Ouyang, Y., et al. (2020). Compilation by stochastic Hamiltonian sparsification.

  • Jin, P., et al. (2023). Partially randomized Hamiltonian simulation.

class qdk_chemistry.algorithms.time_evolution.builder.partially_randomized.PartiallyRandomized(weight_threshold=-1.0, trotter_order=2, num_random_samples=100, seed=-1, tolerance=1e-12, merge_duplicate_terms=True, commutation_type='general')[source]

Bases: QDrift

Partially randomized product formula builder.

Implements a hybrid Hamiltonian simulation method that combines deterministic Trotter decomposition with randomized sampling. The Hamiltonian is split as:

\[H = H_D + H_R = \sum_{l=1}^{L_D} H_l + \sum_{m=1}^{M} h_m P_m\]

where: - \(H_D\) contains the \(L_D\) largest-weight terms, treated with Trotter - \(H_R\) contains the remaining terms, treated with qDRIFT-style sampling

The method is effective when: - \(\lambda_R = \sum_m |h_m| \ll \lambda\) (random part has small total weight) - \(L_D \ll M\) (few deterministic terms, many random terms)

For a second-order Trotter formula, each step applies the deterministic part \(H_D\) with half-angles in a symmetric (palindromic) sweep, with the randomized part \(H_R\) sandwiched in between. The first-order variant applies \(H_D\) at full angle followed by \(H_R\).

The total cost scales as \(O(\lambda_R^2 / \epsilon^2)\) Pauli rotations for the randomized part, where \(\lambda_R = \sum_m |h_m|\) is the 1-norm of \(H_R\) (Theorem 2 of [GuntherWS+25]).

Examples

>>> from qdk_chemistry.algorithms import create
>>> # Create a partially randomized builder
>>> builder = create(
...     "time_evolution_builder",
...     "partially_randomized",
...     weight_threshold=0.1,  # Terms with |h_j| >= 0.1 treated deterministically
...     num_random_samples=200,
...     trotter_order=2,
... )
>>> time_evolution = builder.run(qubit_hamiltonian, time=1.0)

References

Günther, J., Witteveen, F., et al. Phase estimation with partially randomized time evolution.

Parameters:
  • weight_threshold (float)

  • trotter_order (int)

  • num_random_samples (int)

  • seed (int)

  • tolerance (float)

  • merge_duplicate_terms (bool)

  • commutation_type (str)

__init__(weight_threshold=-1.0, trotter_order=2, num_random_samples=100, seed=-1, tolerance=1e-12, merge_duplicate_terms=True, commutation_type='general')[source]

Initialize partially randomized builder with specified settings.

Parameters:
  • weight_threshold (float) – Terms with |h_j| >= threshold are treated deterministically with Trotter. Use -1.0 for automatic determination (top 10% of terms by weight).

  • trotter_order (int) – Order of Trotter formula for deterministic part. 1 = first order, 2 = second order (symmetric). Defaults to 2.

  • num_random_samples (int) – Number of random samples for the qDRIFT-style treatment of H_R. Defaults to 100.

  • seed (int) – Random seed for reproducibility. Use -1 for non-deterministic. Defaults to -1.

  • tolerance (float) – Threshold for filtering negligible coefficients. Defaults to 1e-12.

  • merge_duplicate_terms (bool) – If True, identical Pauli terms within consecutive mutually-commuting runs in the random block are fused to reduce circuit depth. Distinct commuting terms are kept separate. Defaults to True.

  • commutation_type (str) – Commutation check used when merging duplicate terms. "qubit_wise" requires every single-qubit pair to commute individually — stricter but always safe. "general" (default) uses standard Pauli commutation (even number of anti-commuting positions), which allows larger merge groups.

name()[source]

Return the name of the time evolution unitary builder.

Return type:

str

type_name()[source]

Return time_evolution_builder as the algorithm type name.

Return type:

str

class qdk_chemistry.algorithms.time_evolution.builder.partially_randomized.PartiallyRandomizedSettings[source]

Bases: Settings

Settings for partially randomized product formula builder.

The partially randomized method splits the Hamiltonian into: - H_D: Large-weight terms treated deterministically (Trotter) - H_R: Small-weight terms treated randomly (qDRIFT-style)

This hybrid approach benefits from: - Better ε-scaling from deterministic treatment of dominant terms - Reduced circuit depth from random sampling of the long tail

__init__()[source]

Initialize PartiallyRandomizedSettings with default values.

weight_threshold

Terms with |h_j| >= threshold are treated deterministically. Use -1.0 for automatic determination (top 10% of terms by weight).

trotter_order

Order of Trotter formula for deterministic terms (1 or 2).

num_random_samples

Number of random samples for the randomized part.

seed

Random seed for reproducibility. Use -1 for non-deterministic.

tolerance

Absolute tolerance for filtering small coefficients.