Skip to main content

API Reference

The Dynex SDK exposes a small, focused set of classes. All public API is importable directly from the dynex 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

ClassPurpose
DynexConfigCredentials, backend selection, timeouts
DynexSamplerSubmit annealing jobs and retrieve results
BQMWrap a dimod BinaryQuadraticModel
CQMWrap a dimod ConstrainedQuadraticModel
DQMWrap a dimod DiscreteQuadraticModel
DynexCircuitSubmit gate circuit jobs
ComputeBackendEnum: LOCAL, CPU, GPU, QPU
QPUModelEnum: 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 dimod SampleSet:
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