Quantum-related components of a QUBO solver
Drive Shapping
BaseDriveShaper(instance, config, backend)
Bases: ABC
Abstract base class for generating Qoolqit drives based on a QUBO problem.
This class transforms the structure of a QUBOInstance into a quantum waveform sequence or drive that can be applied to a physical register. The register is passed at the time of drive generation, not during initialization.
| ATTRIBUTE | DESCRIPTION |
|---|---|
instance |
The QUBO problem instance.
TYPE:
|
config |
The solver configuration.
TYPE:
|
drive |
A saved current drive obtained by
TYPE:
|
backend |
Backend to use.
TYPE:
|
device |
Device from backend.
TYPE:
|
Initialize the drive shaping module with a QUBO instance.
| PARAMETER | DESCRIPTION |
|---|---|
instance
|
The QUBO problem instance.
TYPE:
|
config
|
The solver configuration.
TYPE:
|
backend
|
Backend to use.
TYPE:
|
Source code in qubosolver/pipeline/drive.py
generate(register)
abstractmethod
Generate a drive based on the problem and the provided register.
| PARAMETER | DESCRIPTION |
|---|---|
register
|
The physical register layout.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Drive
|
A generated Drive.
TYPE:
|
QUBOSolution
|
An instance of the qubo solution
TYPE:
|
Source code in qubosolver/pipeline/drive.py
HeuristicDriveShaper(instance, config, backend)
Bases: BaseDriveShaper
Heuristic schedule drive shaper.
With DMM
Final target encoding: d_i = -alpha * Q_ii
DMM convention in this stack: WeightedDetuning waveform must be <= 0
Hence we encode the local final detuning as: delta_i(T) = delta_g(T) + delta_dmm(T) * w_i
with: delta_g(T) = d_max delta_dmm(T) = -(d_max - d_min) <= 0 w_i = (d_max - d_i) / (d_max - d_min) in [0, 1]
so that: delta_i(T) = d_i
Without DMM
Only a global detuning is available, so the final detuning is chosen as: delta_g(T) = mean(d_i) and no weighted detunings are declared.
Source code in qubosolver/pipeline/drive.py
OptimizedDriveShaper(instance, config, backend)
Bases: BaseDriveShaper
Drive shaper that uses optimization to find the best drive parameters for solving QUBOs. Returns an optimized drive, the bitstrings, their counts, probabilities, and costs.
| ATTRIBUTE | DESCRIPTION |
|---|---|
drive |
current drive.
TYPE:
|
best_cost |
Current best cost.
TYPE:
|
best_bitstring |
Current best bitstring.
TYPE:
|
bitstrings |
List of current bitstrings obtained.
TYPE:
|
counts |
Frequencies of bitstrings.
TYPE:
|
probabilities |
Probabilities of bitstrings.
TYPE:
|
costs |
Qubo cost.
TYPE:
|
optimized_custom_qubo_cost |
Apply a different qubo cost evaluation during optimization.
Must be defined as:
TYPE:
|
optimized_custom_objective_fn |
For bayesian optimization, one can change the output of
TYPE:
|
optimized_callback_objective |
Apply a callback
during bayesian optimization. Only accepts one input dictionary
created during optimization
TYPE:
|
Instantiate an OptimizedDriveShaper.
| PARAMETER | DESCRIPTION |
|---|---|
instance
|
Qubo instance.
TYPE:
|
config
|
Configuration for solving.
TYPE:
|
backend
|
Backend to use during optimization.
TYPE:
|
Source code in qubosolver/pipeline/drive.py
build_drive(params)
Build the drive from a list of parameters for the objective.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
List of parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Drive
|
Drive sequence.
TYPE:
|
Source code in qubosolver/pipeline/drive.py
compute_qubo_cost(bitstring, QUBO)
The qubo cost for a single bitstring to apply during optimization.
| PARAMETER | DESCRIPTION |
|---|---|
bitstring
|
candidate bitstring.
TYPE:
|
QUBO
|
qubo coefficients.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
respective cost of bitstring.
TYPE:
|
Source code in qubosolver/pipeline/drive.py
generate(register)
Generate a drive via optimization.
| PARAMETER | DESCRIPTION |
|---|---|
register
|
The physical register layout.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Drive
|
A generated Drive.
TYPE:
|
QUBOSolution
|
An instance of the qubo solution
TYPE:
|
Source code in qubosolver/pipeline/drive.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | |
run_simulation(register, drive, QUBO, convert_to_tensor=True)
Run a quantum program using backend and returns a tuple of (bitstrings, counts, probabilities, costs, best cost, best bitstring).
| PARAMETER | DESCRIPTION |
|---|---|
register
|
register of quantum program.
TYPE:
|
drive
|
drive to run on backend.
TYPE:
|
QUBO
|
Qubo coefficients.
TYPE:
|
convert_to_tensor
|
Convert tuple components to tensors. Defaults to True.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple
|
tuple of (bitstrings, counts, probabilities, costs, best cost, best bitstring)
TYPE:
|
Source code in qubosolver/pipeline/drive.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | |
get_drive_shaper(instance, config, backend)
Method that returns the correct DriveShaper based on configuration. The correct drive shaping method can be identified using the config, and an object of this driveshaper can be returned using this function.
| PARAMETER | DESCRIPTION |
|---|---|
instance
|
The QUBO problem to embed.
TYPE:
|
config
|
The solver configuration used.
TYPE:
|
backend
|
Backend to extract device from or to use during drive shaping.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BaseDriveShaper
|
The representative Drive Shaper object. |
Source code in qubosolver/pipeline/drive.py
Embedding
BaseEmbedder(instance, config, backend)
Bases: ABC
Abstract base class for all embedders.
Prepares the geometry (register) of atoms based on the QUBO instance. Returns a Register compatible with Pasqal/Pulser devices.
| PARAMETER | DESCRIPTION |
|---|---|
instance
|
The QUBO problem to embed.
TYPE:
|
config
|
The Solver Configuration.
TYPE:
|
Source code in qubosolver/pipeline/embedder.py
embed()
abstractmethod
Creates a layout of atoms as the register.
| RETURNS | DESCRIPTION |
|---|---|
Register
|
The register.
TYPE:
|
GreedyEmbedder(instance, config, backend)
Bases: BaseEmbedder
Create an embedding in a greedy fashion.
At each step, place one logical node onto one trap to minimize the incremental mismatch between the logical QUBO matrix Q and the physical interaction matrix U (approx. C / ||r_i - r_j||^6).
Source code in qubosolver/pipeline/embedder.py
embed()
Creates a layout of atoms as the register.
| RETURNS | DESCRIPTION |
|---|---|
Register
|
The register.
TYPE:
|
Source code in qubosolver/pipeline/embedder.py
get_embedder(instance, config, backend)
Method that returns the correct embedder based on configuration. The correct embedding method can be identified using the config, and an object of this embedding can be returned using this function.
| PARAMETER | DESCRIPTION |
|---|---|
instance
|
The QUBO problem to embed.
TYPE:
|
config
|
The quantum device to target.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BaseEmbedder
|
The representative embedder object. |