API Reference
The Dynex SDK exposes a small, focused set of classes. All public API is importable directly from thedynex package.
Core classes
import dynex
from dynex import (
DynexConfig, # Configuration and credentials
DynexSampler, # Run annealing jobs
DynexCircuit, # Run gate circuits
BQM, # Binary Quadratic Model wrapper
CQM, # Constrained Quadratic Model wrapper
DQM, # Discrete Quadratic Model wrapper
ComputeBackend, # Backend enum (LOCAL, CPU, GPU, QPU)
QPUModel, # QPU hardware model enum
)
Quick reference
| Class | Purpose |
|---|---|
DynexConfig | Credentials, backend selection, timeouts |
DynexSampler | Submit annealing jobs and retrieve results |
BQM | Wrap a dimod BinaryQuadraticModel |
CQM | Wrap a dimod ConstrainedQuadraticModel |
DQM | Wrap a dimod DiscreteQuadraticModel |
DynexCircuit | Submit gate circuit jobs |
ComputeBackend | Enum: LOCAL, CPU, GPU, QPU |
QPUModel | Enum: APOLLO_RC1, APOLLO_10000 |
Minimal example
import dynex
import dimod
from dynex import DynexConfig, ComputeBackend
bqm = dimod.BinaryQuadraticModel({0: -1, 1: -1}, {(0, 1): 2}, 0.0, 'BINARY')
config = DynexConfig(compute_backend=ComputeBackend.GPU)
model = dynex.BQM(bqm)
sampler = dynex.DynexSampler(model, config=config)
sampleset = sampler.sample(num_reads=1000, annealing_time=200)
print(sampleset.first.sample, sampleset.first.energy)
Return types
All samplers return a dimodSampleSet:
sampleset.first # Best sample (lowest energy)
sampleset.first.sample # dict: {variable: value}
sampleset.first.energy # float: objective value
sampleset.samples() # Iterator over all samples
sampleset.to_pandas_dataframe() # pandas DataFrame