Skip to content

Raise clear error for non-BQM embedding inputs#607

Open
matti-sarjala wants to merge 1 commit into
dwavesystems:masterfrom
matti-sarjala:fix-embedding-composite-cqm-error
Open

Raise clear error for non-BQM embedding inputs#607
matti-sarjala wants to merge 1 commit into
dwavesystems:masterfrom
matti-sarjala:fix-embedding-composite-cqm-error

Conversation

@matti-sarjala
Copy link
Copy Markdown

Fixes #463.

This updates embedding composites to reject non-BQM inputs with a clear TypeError before accessing BQM-specific attributes such as .linear and .quadratic.

The motivating case is passing a CQM to EmbeddingComposite(DWaveSampler()).sample(...). Previously this failed with an internal AttributeError, which made it look like the CQM was missing a BQM attribute. The new error makes the model contract explicit: embedding composites accept BQMs, while CQMs should use an appropriate CQM sampler such as LeapHybridCQMSampler.

A regression test is included for CQM input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CQM fails with AttributeError: 'ConstrainedQuadraticModel' object has no attribute 'quadratic'

1 participant