sampler
qemcmc.sampler ¶
ClassicalProposal ¶
Bases: Proposal
Classical Markov Chain Monte Carlo proposer.
This class implements purely classical proposal mechanisms for MCMC. New candidate states are generated either by sampling a completely random (uniform) configuration, or by performing a local single-spin or two-spin flip.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
EnergyModel
|
Energy model defining the target Boltzmann distribution. |
required |
method
|
str
|
Proposal mechanism used to generate candidate states.
Default is |
'uniform'
|
Source code in src/qemcmc/sampler/classical_proposal.py
update_uniform ¶
Proposes a new state by generating a random bitstring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_state_bitstring
|
str
|
The current state represented as a bitstring (not used, but required by the API). |
required |
Returns:
| Type | Description |
|---|---|
str
|
A new random state bitstring of the same length. |
Source code in src/qemcmc/sampler/classical_proposal.py
update_local ¶
Proposes a new state by flipping a single randomly chosen spin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_state_bitstring
|
str
|
The current state represented as a bitstring. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The new state bitstring after flipping one spin. |
Source code in src/qemcmc/sampler/classical_proposal.py
update_2local ¶
Proposes a new state by flipping two randomly chosen spins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_state_bitstring
|
str
|
The current state represented as a bitstring. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The new state bitstring after flipping two spins. |
Source code in src/qemcmc/sampler/classical_proposal.py
Proposal ¶
Bases: ABC
Abstract base class for producing proposals for Markov Chain Monte Carlo algorithms.
Subclasses implement the proposal mechanism by defining an
update(state) method that generates a candidate state from the current one
(e.g. single-spin flips, block updates, or quantum proposals).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
EnergyModel
|
Energy model defining the target distribution over spin configurations. |
required |
Source code in src/qemcmc/sampler/proposal.py
update
abstractmethod
¶
Generate a candidate state from the current state using the proposal mechanism.
This method should be implemented by subclasses to define the specific proposal strategy (e.g., single-spin flips, block updates, or quantum proposals).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
MCMCState
|
The current state of the Markov chain. |
required |
Returns:
| Type | Description |
|---|---|
MCMCState
|
A new candidate state. |
Source code in src/qemcmc/sampler/proposal.py
QuenchProposal ¶
QuenchProposal(
model,
gamma,
time,
r=None,
delta_t=None,
coarse_graining=None,
coupling_weights=None,
)
Bases: Proposal
Quantum-enhanced Markov Chain Monte Carlo proposer.
This class implements the proposal mechanism of the quantum-enhanced MCMC by Layden et al.. Candidate states are generated by simulating the quantum time evolution of a transverse-field Hamiltonian.
The quantum proposal circuit is constructed using :class:QuenchCircuitMaker
and can optionally operate on coarse-grained subgroups of spins to
improve scalability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
EnergyModel
|
Energy model defining the target Boltzmann distribution. |
required |
gamma
|
float | tuple[float, float]
|
Transverse field strength (Γ). If a tuple is provided, a value is sampled uniformly from the range [min, max] at each step. |
required |
time
|
float | tuple[float, float]
|
Total evolution time. If a tuple is provided, a value is sampled uniformly from the range [min, max] at each step. |
required |
r
|
int | None
|
Number of Trotter steps. Mutually exclusive with |
None
|
delta_t
|
float | None
|
Trotter step size. Mutually exclusive with |
None
|
coarse_graining
|
CoarseGraining | None
|
A coarse-graining scheme to define spin subgroups. If None, no coarse-graining
is used. By default |
None
|
coupling_weights
|
list[float | tuple[float, float]] | None
|
Weights for the coupling tensors. If a tuple is provided, a weight is
sampled uniformly from the range. This allows for dynamic adjustment
of the influence of different terms in the Hamiltonian during the proposal
step. By default |
None
|
Notes
The proposal step simulates the time evolution under a transverse-field Hamiltonian defined by the energy model and measures the resulting state to produce a candidate configuration. This proposal is then accepted or rejected using the Metropolis criterion to ensure convergence to the target Boltzmann distribution.
Exactly one of r or delta_t should be passed in as an argument. If neither is
given, a default Δt of 0.8 is used.
Source code in src/qemcmc/sampler/quenchproposal.py
update ¶
Perform sequential quantum updates across non-overlapping subgroups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_state
|
str
|
Current state of the system as a bitstring. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Updated state of the system as a bitstring. |
Source code in src/qemcmc/sampler/quenchproposal.py
sample_hyperparams ¶
Sample hyperparameters (coupling weights, gamma, time, r) for the current proposal step.
Returns:
| Type | Description |
|---|---|
tuple[list[float], float, float, int]
|
(final_coupling_weights, gamma, time, r) for this proposal step. |
Source code in src/qemcmc/sampler/quenchproposal.py
AdiabaticProposal ¶
AdiabaticProposal(
model,
gamma,
alpha,
kappa,
delta_t=None,
coarse_graining=None,
coupling_weights=None,
)
Bases: Proposal
Quantum-enhanced Markov Chain Monte Carlo proposer with adiabatic dressing.
This class implements the adiabatic dressing proposal mechanism for quantum-enhanced MCMC (Ferguson & Wallden / Hsieh et al., arXiv:2603.28076). Candidate states are generated by simulating the quantum time evolution of a time-dependent transverse-field Hamiltonian:
``H(t) = h(t) * gamma * H_mixer + H_problem``
The schedule function h(t) ramps the transverse field up from 0 to 1 over ramp
duration alpha, holds it at 1 for plateau duration kappa, and ramps it down
from 1 to 0 over duration alpha (total duration 2 * alpha + kappa).
For long evolution times, adiabaticity preserves the ground/eigenstates, whereas for intermediate
times diabatic transitions induce proposals concentrated near the target energy levels.
The quantum proposal circuit is constructed using :class:AdiabaticCircuitMaker
and can optionally operate on coarse-grained subgroups of spins to
improve scalability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
EnergyModel
|
Energy model defining the target Boltzmann distribution. |
required |
gamma
|
float | tuple[float, float]
|
Transverse field strength. If a tuple is provided, a value is sampled uniformly from the range [min, max] at each step. |
required |
alpha
|
float | tuple[float, float]
|
Duration of the linear adiabatic ramp. If a tuple is provided, a value is sampled uniformly from the range [min, max] at each step. |
required |
kappa
|
float | tuple[float, float]
|
Duration of the constant plateau. If a tuple is provided, a value is sampled uniformly from the range [min, max] at each step. |
required |
delta_t
|
float | None
|
Trotter step size for the approximate time evolution. The number of Trotter
steps is derived as |
None
|
coarse_graining
|
CoarseGraining | None
|
A coarse-graining scheme to define spin subgroups. If None, no coarse-graining is used. Defaults to None. |
None
|
coupling_weights
|
list[float | tuple[float, float]] | None
|
Weights for the coupling tensors. If a tuple is provided, a weight is sampled uniformly from the range. Defaults to ones. |
None
|
Notes
The proposal step simulates time evolution under a time-dependent transverse-field Hamiltonian and measures the resulting state to produce a candidate configuration. This proposal is then accepted or rejected using the Metropolis criterion to ensure convergence to the target Boltzmann distribution.
Source code in src/qemcmc/sampler/adiabaticproposal.py
update ¶
Perform sequential quantum updates across non-overlapping subgroups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_state
|
str
|
Current state of the system as a bitstring. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Updated state of the system as a bitstring. |
Source code in src/qemcmc/sampler/adiabaticproposal.py
sample_hyperparams ¶
Sample hyperparameters (coupling weights, gamma, alpha, kappa) for the current proposal step.
Returns:
| Type | Description |
|---|---|
tuple[list[float], float, float, float]
|
(final_coupling_weights, gamma, alpha, kappa) for this proposal step. |