Optimized Drive
Optimized Drive Shaper
Section titled “Optimized Drive Shaper”OptimizedDriveShaper uses bayesian optimization to find drive parameters (amplitude and detuning) in order to solve a QUBO problem using quantum simulation.
It outputs both the optimized drive and a solution object containing bitstrings, counts, probabilities, and associated costs.
Features:
Section titled “Features:”- Computes normalized weights from the QUBO diagonal to support later application of the Detuning Map Modulator (DMM).
- Uses Bayesian optimization to tune six parameters: three for the Rabi amplitude (Ω), and three for the global detuning (δ).
- Executes quantum simulations at each iteration to evaluate candidate drive parameters and their performance on the QUBO.
- Returns the final optimized drive and best QUBO solution, with full metadata (counts, probabilities, and costs).
Initialization Parameters:
Section titled “Initialization Parameters:”| Field | Type | Description |
|---|---|---|
instance |
QUBOInstance |
Qubo instance. |
config |
SolverConfig |
Configuration for solving. |
Drive Parameterization
Section titled “Drive Parameterization”The optimized drive is built from an InterpolatedWaveform with:
Amplitude: Ω=[0,Ω1,Ω2,Ω3,0]
Detuning: δ=[δ1,δ2,δ3]
These waveforms:
Always start and end in zero amplitude; Use 3 intermediate amplitude values (Ω1 to Ω3) and 3 detuning values (δ1 to δ3), which are the parameters optimized.
The drive starts with an InterpolatedWaveform with the points (later they are normalized to fit device constraints):
- Ω=[0,5,10,5,0]
- δ=[−10,0,10]
Methods Overview
Section titled “Methods Overview”-
generate(self, register: Register, instance: QUBOInstance) -> tuple[Drive, QUBOSolution]: Runs the Bayesian optimization loop and returns the optimized drive and corresponding solution. Handles fallback cases if simulation fails. -
build_drive(self, params: list) -> Drive: Creates a Drive from a 6-element parameter list: the first 3 for amplitude, the last 3 for detuning. -
_compute_norm_weights(self, QUBO: torch.Tensor) -> list[float]: Normalizes the QUBO diagonal weights (used in DMM shaping). -
run_simulation(...) -> tuple[...]: Runs a simulation of the current drive on a quantum backend and returns bitstring results, probabilities, and QUBO costs. -
compute_qubo_cost(self, bitstring: str, QUBO: torch.Tensor) -> float: Computes the QUBO cost of a specific bitstring.
Output Structure
Section titled “Output Structure”After the final round of optimization, the following attributes are populated:
drive: Final Drive object with optimized waveform parameters.best_cost: Minimum cost found during optimization.best_bitstring: Corresponding bitstring with the lowest cost.bitstrings, counts, probabilities, costs: Full result distributions as PyTorch tensors.
Example
Section titled “Example”import torch
from qubosolver import QUBOInstancefrom qubosolver.config import SolverConfig, DriveShapingConfigfrom qubosolver.solver import QuboSolverfrom qubosolver.qubo_types import DriveType
Q = torch.tensor([[-1.0, 0.5, 0.2], [0.5, -2.0, 0.3], [0.2, 0.3, -3.0]])
instance = QUBOInstance(Q)
default_config = SolverConfig( use_quantum = True, drive_shaping=DriveShapingConfig(drive_shaping_method=DriveType.OPTIMIZED, optimized_n_calls = 25),)solver = QuboSolver(instance, default_config)
solution = solver.solve()print(solution)QUBOSolution(bitstrings=tensor([[0, 1, 1], [1, 1, 1], [1, 0, 1], [0, 0, 1], [0, 1, 0], [1, 1, 0], [1, 0, 0], [0, 0, 0]], dtype=torch.int32), costs=tensor([-4.4000, -4.0000, -3.6000, -3.0000, -2.0000, -2.0000, -1.0000, 0.0000]), counts=tensor([21, 31, 20, 8, 6, 7, 3, 4], dtype=torch.int32), probabilities=tensor([0.2100, 0.3100, 0.2000, 0.0800, 0.0600, 0.0700, 0.0300, 0.0400]), solution_status=)
This will return a QUBOSolution instance, which comprehends the solution bitstrings, the counts of each bitstring, their probabilities and costs.
var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))
{"annotate": null, "base": "../../..", "features": ["content.code.annotate", "content.action.view", "content.action.edit", "navigation.tabs", "navigation.indexes", "navigation.sections", "content.code.copy"], "search": "../../../assets/javascripts/workers/search.2c215733.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": {"provider": "mike"}}