Registry / ai-ml / dimod
library0.12.22pypypi✓ verified 90d ago

dimod is a shared API for binary quadratic model (BQM) samplers. It provides classes for representing quadratic models like Ising and QUBO, as well as higher-order models, used by solvers such as the D-Wave quantum computer. The library also offers utilities for constructing new samplers, composed samplers, and tools for working with BQMs. The current version is 0.12.21, with an active release cadence, frequently adding new features and bug fixes.

pip install dimod
INSTALL
IMPORT
SIG · DIMOD
D
dimod
ai-mlpythonv0.12.22
Install
4.4s avg
Import
440ms
Disk
137MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.12.22 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
build_error
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 4.4s · import 0.440s · 135MB
137MB installed
● package 137MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BinaryQuadraticModel
✓ from dimod import BinaryQuadraticModel
ExactSolver
✓ from dimod import ExactSolver
ExactSolver is a reference solver for testing and small problems, not for production quantum hardware.
SPIN
✓ from dimod import SPIN
✗ from dimod.vartype import SPIN
Vartype enumerations (SPIN, BINARY) are directly available under the `dimod` namespace.

This quickstart demonstrates how to create a BinaryQuadraticModel (BQM) with binary variables, solve it using dimod's built-in ExactSolver, and inspect the resulting samples and their energies. It also shows how to convert the BQM's variable type (vartype) between BINARY and SPIN.

import dimod # Construct a simple QUBO problem # Represents E(x0, x1) = -x0 - x1 + 2*x0*x1 bqm = dimod.BinaryQuadraticModel({0: -1, 1: -1}, {(0, 1): 2}, 0.0, dimod.BINARY) # Use dimod's brute-force exact solver sampler = dimod.ExactSolver() response = sampler.sample(bqm) print("SampleSet:\n", response) # Access samples and energies for sample, energy in response.data(['sample', 'energy']): print(f"Sample: {sample}, Energy: {energy}") # Convert the BQM to Ising format bqm_ising = bqm.change_vartype(dimod.SPIN, inplace=False) print("\nIsing BQM vartype:", bqm_ising.vartype)
Debug
Known issues
breakingSupport for Python 3.8 was dropped in dimod version 0.12.18. Python 3.7.x support was dropped in earlier 0.10.x versions.
fix
Upgrade to Python 3.9 or higher. The current version 0.12.21 supports Python 3.9 through 3.14.
affects: <0.12.18 (for 3.8), <0.10.2 (for 3.7)
deprecatedThe `dimod.meta` namespace and its contents (`SamplerABCMeta`, `samplemixinmethod`) were removed in dimod 0.10.5.
fix
Migrate to `dimod.core.sampler` namespace for related functionality.
affects: >=0.10.5
gotchaThe `Variables._relabel()` method in versions prior to 0.12.21 could apply incorrect relabeling when given a superset of labels that corresponded to valid indices.
fix
Upgrade to dimod 0.12.21 or later to ensure correct relabeling behavior for variables.
affects: <0.12.21
gotchaInheritance in `ComposedSampler` and `ComposedPolySampler` was fixed in 0.12.20 to ensure composite attributes correctly override sampler attributes. Older versions might exhibit unexpected behavior if relying on this override.
fix
Upgrade to dimod 0.12.20 or later to ensure proper attribute resolution in composed samplers.
affects: <0.12.20
Errors
Common errors & fixes
TypeError: Parameters to generic types must be types. Got NotImplemented.
This error often occurs when using older Python versions (e.g., Python 3.7.10) with newer dimod versions due to changes in Python's `typing` module or dependencies like NumPy.
fix
Ensure you are using a Python version supported by dimod (currently >=3.9) and compatible versions of its dependencies, especially NumPy. Upgrade Python to 3.9+.
SolverFailureError: quadratic must be a sequence of length X
This error typically indicates an issue with the structure or size of the binary quadratic model (BQM) being submitted to a solver, or a problem within the solver itself, possibly related to embedding or input validation.
fix
Carefully inspect the `quadratic` biases of your BQM. Ensure the quadratic interactions are correctly formed and that the BQM structure matches the expected input of the sampler. This can sometimes occur intermittently due to complex embedding challenges; try simplifying the problem or using a different embedding approach if applicable.
AttributeError: module 'dimod' has no attribute 'meta'
Attempting to access the `dimod.meta` namespace after it has been removed from the library.
fix
The functionality previously in `dimod.meta` has been migrated. Refer to the `dimod.core.sampler` namespace for equivalent functionality or update your code to reflect the current API design.
Upgrade
Version history
0.12.22latest on PyPI · released Jun 8, 2026
Audit
Dependencies
numpyrequiredFundamental for array computing and mathematical operations within binary quadratic models.
Agent activity
21 hits · last 30 days
node
20
OpenAI (training)
1
Resources