QBSolvLikeQpu¶
The QBSolv-like QPU is a specialized solver designed to tackle complex problems by decomposing them into smaller, manageable subproblems. It then solves these individual parts using a Quantum Processing Unit (QPU).
This particular implementation achieves its QBSolv-like behavior by utilizing the hybrid.QPUSubproblemAutoEmbeddingSampler from the D-Wave Ocean SDK as the core sampler for these subproblems. This approach allows for efficient handling of large-scale problems by breaking them down and leveraging the strengths of quantum computation for the subcomponents.
Note
This solver is only available for commercial and academic licenses.
Compatible Backends¶
The QBSolvLikeQpu algorithm supports the following backends:
DWaveQpuBy default,QBSolvLikeQpuuses theDWaveQpubackend.
Initialization¶
The following section outlines the default configurations of QBSolvLikeQpu. 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.algorithms import QBSolvLikeQpu
from luna_quantum.solve.parameters.algorithms.base_params import (
Decomposer,
QuantumAnnealingParams
)
algorithm = QBSolvLikeQpu(
backend=None,
decomposer_size=50,
rolling=True,
rolling_history=0.15,
max_iter=100,
max_time=5,
convergence=3,
target=None,
rtol=1e-05,
atol=1e-08,
num_reads=100,
num_retries=0,
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 QBSolvLikeQpu 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: QBSolvLikeMixin, LunaAlgorithm[DWaveQpu]
QBSolv-like algorithm for QPU.
QBSolv QPU splits the problem into parts and solves them using the Tabu Search algorithm. For this purpose, the DWaveSampler is used.
Attributes:
| Name | Type | Description |
|---|---|---|
decomposer_size |
int
|
Size for the decomposer. Determines the maximum subproblem size to be sent to the quantum processor, with larger values potentially improving solution quality at the cost of increased processing time. |
rolling |
bool
|
Whether to use rolling for the solver. When enabled, this allows for smoother transitions between subproblems during the decomposition process. |
rolling_history |
float
|
Rolling history parameter for the solver. Controls how much previous iteration information is considered when solving subsequent subproblems. |
max_iter |
int | None
|
Maximum number of iterations. Limits the total number of decomposition and solving cycles performed by the algorithm. |
max_time |
int
|
Time in seconds after which the algorithm will stop. Provides a time-based stopping criterion regardless of convergence status. |
convergence |
int
|
Number of iterations with unchanged output to terminate algorithm. Higher values ensure more stable solutions but may increase computation time. |
target |
float | None
|
Energy level that the algorithm tries to reach. If this target energy is achieved, the algorithm will terminate early. |
rtol |
float
|
Relative tolerance for convergence. Used when comparing energy values between iterations to determine if convergence has been reached. |
atol |
float
|
Absolute tolerance for convergence. Used alongside rtol when comparing energy values to determine convergence. |
num_reads |
int
|
Number of reads for the solver. |
num_retries |
int
|
Number of retries for the solver. |
quantum_annealing_params |
QuantumAnnealingParams
|
Quantum annealing parameters. |
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)
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_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. |
Bases: BaseModel
Configuration for breaking down larger problems into subproblems for DWave QPUs.
Attributes:
| Name | Type | Description |
|---|---|---|
size |
int, default=10
|
Nominal number of variables in each subproblem. The actual subproblem can be
smaller depending on other parameters (e.g., |
min_gain |
Optional[float], default=None
|
Minimum required energy reduction threshold for including a variable in the subproblem. A variable is included only if flipping its value reduces the BQM energy by at least this amount. If None, no minimum gain is required. |
rolling |
bool, default=True
|
Controls variable selection strategy for successive calls on the same problem:
|
rolling_history |
float, default=1.0
|
Fraction of the problem size (range 0.0 to 1.0) that participates in the rolling selection. Once this fraction of variables has been processed, subproblem unrolling is reset. Min: 0.0, Max: 1.0 |
silent_rewind |
bool, default=True
|
Controls behavior when resetting/rewinding the subproblem generator:
|
traversal |
Literal["energy", "bfs", "pfs"], default="energy"
|
Algorithm used to select a subproblem of
|
Bases: BaseModel
Parameters for quantum annealing sampling on physical quantum processors (QPUs).
These parameters control the quantum annealing process on hardware devices like D-Wave quantum annealers, specifying how the annealing is performed, how many samples to collect, and various hardware-specific settings that affect solution quality and runtime.
Attributes:
| Name | Type | Description |
|---|---|---|
anneal_offsets |
list[float] | None
|
Per-qubit time offsets for the annealing path in normalized annealing time units. List of floats with length equal to the number of qubits. Default is None. |
anneal_schedule |
list[tuple[float, float]] | None
|
Custom schedule for the annealing process as a list of (time, s) pairs. Time is in normalized units [0, 1] and s is the annealing parameter [0, 1]. Default is None. |
annealing_time |
float | None
|
Duration of the annealing process in microseconds. Must be within the range supported by the QPU hardware. Default is None. |
auto_scale |
bool | None
|
Whether to automatically normalize the problem energy range to use the full range of h and J values supported by the hardware. Default is None. |
fast_anneal |
bool
|
Use accelerated annealing protocol for shorter annealing times. Default is False. |
flux_biases |
list[float] | None
|
Custom flux bias offsets for each qubit in units of Ξ¦β (flux quantum). List length must equal the number of qubits. Default is None. |
flux_drift_compensation |
bool
|
Whether to compensate for drift in qubit flux over time using real-time calibration data. Default is True. |
h_gain_schedule |
list[tuple[float, float]] | None
|
Schedule for h-gain during annealing as a list of (time, gain) pairs. Time is in normalized units [0, 1]. Default is None. |
initial_state |
list[int] | None
|
Starting state for the annealing process. List of {-1, +1} values with length equal to the number of qubits. Default is None. |
max_answers |
int | None
|
Maximum number of unique answer states to return. Must be β€ num_reads. Default is None. |
num_reads |
int
|
Number of annealing cycles to perform. Must be positive integer. Default is 1. |
programming_thermalization |
float | None
|
Wait time after programming the QPU in microseconds to allow the system to thermalize. Default is None. |
readout_thermalization |
float | None
|
Wait time after each anneal before reading results in microseconds. Default is None. |
reduce_intersample_correlation |
bool
|
Whether to add delay between samples to reduce correlation between consecutive measurements. Default is False. |
reinitialize_state |
bool | None
|
Whether to reset to a new initial state between reads to reduce correlation. Default is None. |
anneal_schedule
class-attribute
instance-attribute
¶
annealing_time
class-attribute
instance-attribute
¶
annealing_time: float | None = Field(default=None, gt=0)
h_gain_schedule
class-attribute
instance-attribute
¶
max_answers
class-attribute
instance-attribute
¶
max_answers: int | None = Field(default=None, ge=1)
programming_thermalization
class-attribute
instance-attribute
¶
programming_thermalization: float | None = Field(default=None, gt=0)
readout_thermalization
class-attribute
instance-attribute
¶
readout_thermalization: float | None = Field(default=None, gt=0)