ParallelTemperingQpu¶
Parallel Tempering uses multiple optimization procedures per temperature. During the cooling process, an exchange of replicas can take place between the parallel procedures, thus enabling higher energy mountains to be overcome.
Note
This solver is only available for commercial and academic licenses.
Compatible Backends¶
The ParallelTemperingQpu
algorithm supports the following backends:
By default, ParallelTemperingQpu
uses the DWaveQpu
backend.
Initialization¶
The following section outlines the default configurations of ParallelTemperingQpu
. You can also specify other compatible backends for the algorithm. When backend=None
is specified, the default backend will be initialized automatically. In this case, if the backend requires a token, it will be taken from the environment variables.
from luna_quantum.solve.parameters.algorithms import ParallelTemperingQpu
from luna_quantum.solve.parameters.algorithms.base_params import (
Decomposer,
QuantumAnnealingParams
)
algorithm = ParallelTemperingQpu(
backend=None,
n_replicas=2,
random_swaps_factor=1,
max_iter=100,
max_time=5,
convergence=3,
target=None,
rtol=1e-05,
atol=1e-08,
num_reads=100,
num_retries=0,
fixed_temp_sampler_num_sweeps=10000,
fixed_temp_sampler_num_reads=None,
quantum_annealing_params=QuantumAnnealingParams(
anneal_offsets=None,
anneal_schedule=None,
annealing_time=None,
auto_scale=None,
fast_anneal=False,
flux_biases=None,
flux_drift_compensation=True,
h_gain_schedule=None,
initial_state=None,
max_answers=None,
num_reads=1,
programming_thermalization=None,
readout_thermalization=None,
reduce_intersample_correlation=False,
reinitialize_state=None
),
decomposer=Decomposer(
size=10,
min_gain=None,
rolling=True,
rolling_history=1.0,
silent_rewind=True,
traversal='energy'
)
)
Parameter Details
For a complete overview of available parameters and their usage, see the ParallelTemperingQpu API Reference.
Usage¶
from luna_quantum import LunaSolve
LunaSolve.authenticate("<YOUR_LUNA_API_KEY>")
# Define your model and algorithm
model = ...
algorithm = ...
solve_job = algorithm.run(model, name="my-solve-job")
API Reference¶
Bases: LunaAlgorithm[DWaveQpu]
Parameters for the Parallel Tempering QPU solver.
Parallel Tempering uses multiple model procedures per temperature. During the cooling process, an exchange of replicas can take place between the parallel procedures, thus enabling higher energy mountains to be overcome.
Attributes:
Name | Type | Description |
---|---|---|
n_replicas |
int
|
Number of system replicas to simulate at different temperatures. More replicas provide better temperature coverage but increase computational cost. Default is 2, which is minimal but can still provide benefits over single-temperature methods. |
random_swaps_factor |
int
|
Factor controlling how frequently random swap attempts occur between replicas. Higher values increase mixing between replicas but add overhead. Default is 1, balancing mixing with efficiency. |
max_iter |
int | None
|
Maximum number of iterations. Controls how many rounds of replica exchange are performed. Higher values allow more thorough exploration. Default is 100. |
max_time |
int
|
Maximum time in seconds that the algorithm is allowed to run. Default is 5. |
convergence |
int
|
Number of consecutive iterations with no improvement required to consider the algorithm converged. Default is 3. |
target |
float | None
|
Target energy value. If reached, the algorithm will terminate. Default is None, meaning no target is set. |
rtol |
float
|
Relative tolerance for convergence checking. Default is DEFAULT_RTOL. |
atol |
float
|
Absolute tolerance for convergence checking. Default is DEFAULT_ATOL. |
num_reads |
int
|
Number of annealing cycles to perform on the D-Wave QPU. Default is 100. |
num_retries |
int
|
Number of attempts to retry embedding the problem onto the quantum hardware. Default is 0. |
fixed_temp_sampler_num_sweeps |
int
|
Number of Monte Carlo sweeps to perform, where one sweep attempts to update all variables once. More sweeps produce better equilibrated samples but increase computation time. Default is 10,000, which is suitable for thorough exploration of moderate-sized problems. |
fixed_temp_sampler_num_reads |
int | None
|
Number of independent sampling runs to perform. Each run produces one sample from the equilibrium distribution. Multiple reads provide better statistical coverage of the solution space. Default is None, which typically defaults to 1 or matches the number of initial states provided. |
quantum_annealing_params |
QuantumAnnealingParams
|
Configuration for the quantum annealing process on D-Wave hardware. Contains settings for anneal schedule, flux biases, and other QPU-specific parameters. See QuantumAnnealingParams documentation for details. |
decomposer |
Decomposer
|
Decomposer: Breaks down problems into subproblems of manageable size Default is a Decomposer instance with default settings. |
backend
class-attribute
instance-attribute
¶
decomposer
class-attribute
instance-attribute
¶
decomposer: Decomposer = Field(default_factory=Decomposer)
fixed_temp_sampler_num_reads
class-attribute
instance-attribute
¶
fixed_temp_sampler_num_sweeps
class-attribute
instance-attribute
¶
model_config
class-attribute
instance-attribute
¶
quantum_annealing_params
class-attribute
instance-attribute
¶
quantum_annealing_params: QuantumAnnealingParams = Field(
default_factory=QuantumAnnealingParams
)
get_compatible_backends
classmethod
¶
get_compatible_backends() -> tuple[type[DWaveQpu], ...]
Check at runtime if the used backend is compatible with the solver.
Returns:
Type | Description |
---|---|
tuple[type[IBackend], ...]
|
True if the backend is compatible with the solver, False otherwise. |
get_default_backend
classmethod
¶
get_default_backend() -> DWaveQpu
Return the default backend implementation.
This property must be implemented by subclasses to provide the default backend instance to use when no specific backend is specified.
Returns:
Type | Description |
---|---|
IBackend
|
An instance of a class implementing the IBackend interface that serves as the default backend. |
run ¶
run(
model: Model | str,
name: str | None = None,
backend: BACKEND_TYPE | None = None,
client: LunaSolve | str | None = None,
*args: Any,
**kwargs: Any,
) -> SolveJob
Run the configured solver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Model or str
|
The model to be optimized or solved. It could be an Model instance or a string identifier representing the model id. |
required |
name
|
str | None
|
If provided, the name of the job. Defaults to None. |
None
|
backend
|
BACKEND_TYPE | None
|
Backend to use for the solver. If not provided, the default backend is used. |
None
|
client
|
LunaSolve or str
|
The client interface used to interact with the backend services. If not provided, a default client will be used. |
None
|
*args
|
Any
|
Additional arguments that will be passed to the solver or client. |
()
|
**kwargs
|
Any
|
Additional keyword parameters for configuration or customization. |
{}
|
Returns:
Type | Description |
---|---|
SolveJob
|
The job object containing the information about the solve process. |