Ocean
D-Wave's SDK for quantum annealing and hybrid solvers
Quick install
pip install dwave-ocean-sdk Background and History
D-Wave Ocean is the software development kit for D-Wave Systems, a Canadian company that has been building quantum annealing processors since its founding in 1999. D-Wave is the longest-operating commercial quantum computing company and the first to sell quantum computing systems, with its initial D-Wave One system (128 qubits) shipped to Lockheed Martin in 2011. The company was founded by Geordie Rose and Haig Farris in Vancouver, British Columbia.
D-Wave’s software tools evolved over several iterations before coalescing into the Ocean SDK. Early access to D-Wave hardware used lower-level interfaces, including a C library and the SAPI (Solver API) Python client. As the user base grew, D-Wave developed higher-level tools: dimod for defining binary quadratic models, dwave-system for hardware access, and minorminer for embedding problem graphs onto the processor’s Chimera or Pegasus topology. Around 2018, these components were bundled into the dwave-ocean-sdk meta-package, which provided a unified installation and a coherent programming model.
D-Wave’s hardware has gone through several generations: the Chimera topology (used in D-Wave 2000Q and earlier systems, up to 2,048 qubits), the Pegasus topology (introduced with the Advantage system in 2020, offering over 5,000 qubits), and the Zephyr topology (introduced with the Advantage2 prototype in 2023, with improved connectivity). The Ocean SDK has tracked these hardware changes, adding support for new topologies and solvers with each generation. The Leap cloud platform, launched in 2018, provides remote access to D-Wave processors and hybrid solvers.
Ocean occupies a unique position in the quantum computing ecosystem because D-Wave’s quantum annealers solve optimization problems natively, not gate-model circuits. Users formulate problems as QUBOs (Quadratic Unconstrained Binary Optimization) or Ising models rather than sequences of quantum gates. The LeapHybridSampler and LeapHybridCQMSampler are particularly notable, combining classical and quantum resources to handle problems with thousands of variables that exceed the native qubit count. As of 2025, Ocean is actively maintained, with D-Wave continuing to release regular updates. The SDK has a dedicated user community, particularly among operations research and combinatorial optimization practitioners.
Installation
pip install dwave-ocean-sdk
Configure access to D-Wave’s cloud:
dwave setup # interactive setup, saves token to ~/.config/dwave/dwave.conf
Key Imports
import dimod
from dwave.system import DWaveSampler, EmbeddingComposite, LeapHybridSampler
from dwave.samplers import SimulatedAnnealingSampler, SteepestDescentSampler
Core Concepts
D-Wave solves quadratic unconstrained binary optimisation (QUBO) problems, not gate-model quantum circuits. The workflow is:
- Express your problem as a Binary Quadratic Model (BQM) or QUBO
- Submit to a sampler (annealer, hybrid solver, or classical simulator)
- Read back lowest-energy samples as solutions
Binary Quadratic Model (BQM)
import dimod
# Create from scratch
bqm = dimod.BinaryQuadraticModel('BINARY') # variables in {0, 1}
bqm = dimod.BinaryQuadraticModel('SPIN') # variables in {-1, +1}
# Add linear (single-variable) terms
bqm.add_variable('x', -1.0) # bias for variable x
bqm.add_variable('y', -1.0)
# Add quadratic (interaction) terms
bqm.add_interaction('x', 'y', 2.0)
# From a dict (QUBO format)
Q = {('x', 'x'): -1, ('y', 'y'): -1, ('x', 'y'): 2}
bqm = dimod.BinaryQuadraticModel.from_qubo(Q)
Energy formula: E = Σ bias_i * x_i + Σ J_ij * x_i * x_j
The sampler finds the assignment of variables that minimises E.
Samplers
SimulatedAnnealingSampler (local, no account needed)
from dwave.samplers import SimulatedAnnealingSampler
sampler = SimulatedAnnealingSampler()
sampleset = sampler.sample(bqm, num_reads=1000)
print(sampleset.first.sample) # best solution
print(sampleset.first.energy) # lowest energy found
DWaveSampler (real QPU)
from dwave.system import DWaveSampler, EmbeddingComposite
# EmbeddingComposite handles the minor-embedding step automatically
sampler = EmbeddingComposite(DWaveSampler())
sampleset = sampler.sample(bqm, num_reads=1000)
LeapHybridSampler (recommended for large problems)
from dwave.system import LeapHybridSampler
sampler = LeapHybridSampler()
sampleset = sampler.sample(bqm, time_limit=5) # seconds
Reading Results
sampleset = sampler.sample(bqm, num_reads=100)
sampleset.first # best (lowest energy) sample
sampleset.first.sample # dict: variable → value
sampleset.first.energy # float
# All samples as DataFrame
df = sampleset.to_pandas_dataframe()
# Iterate
for sample, energy in sampleset.data(['sample', 'energy']):
print(sample, energy)
Constrained Quadratic Model (CQM)
For problems with constraints (e.g. “exactly one item selected”):
import dimod
cqm = dimod.ConstrainedQuadraticModel()
x = [dimod.Binary(f'x_{i}') for i in range(5)]
# Objective: minimise sum of costs
costs = [3, 1, 4, 1, 5]
cqm.set_objective(sum(c * x_i for c, x_i in zip(costs, x)))
# Constraint: pick exactly 2 items
cqm.add_constraint(sum(x) == 2, label='pick_two')
from dwave.system import LeapHybridCQMSampler
sampler = LeapHybridCQMSampler()
sampleset = sampler.sample_cqm(cqm, time_limit=5)
feasible = sampleset.filter(lambda s: s.is_feasible)
print(feasible.first.sample)
Common Patterns
Maximum cut (graph partitioning)
import dimod, networkx as nx
from dwave.samplers import SimulatedAnnealingSampler
G = nx.karate_club_graph()
bqm = dimod.generators.maximum_weight_matching(G) # or build manually
# Build MaxCut BQM
bqm = dimod.BinaryQuadraticModel('BINARY')
for u, v in G.edges():
bqm.add_interaction(u, v, -1)
bqm.add_variable(u, 0.5)
bqm.add_variable(v, 0.5)
sampler = SimulatedAnnealingSampler()
result = sampler.sample(bqm, num_reads=100)
print(result.first.sample)
Quadratic assignment / Ising form
# Ising form: variables in {-1, +1}
h = {0: -1, 1: -1} # linear biases
J = {(0, 1): 1} # quadratic couplings
sampler = SimulatedAnnealingSampler()
sampleset = sampler.sample_ising(h, J, num_reads=100)