Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › D-Wave

How to Run Your First Optimization Problem on a D-Wave Quantum Computer With Leap

By Freedom251 Team · · 11 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can run a first D-Wave optimization experiment without owning or installing a quantum computer. Create a Leap account and project, authenticate the Ocean SDK with that project’s API token, express a small problem as a binary quadratic model (BQM) or QUBO, and submit it to a Leap hybrid solver. Leap returns assignments and energies; you then check the lowest-energy candidate against the original constraints and objective.

What you need for a first Leap run

Leap is D-Wave’s cloud service for submitting problems to quantum processing units (QPUs) and quantum-classical hybrid solvers. Your Python program sends a model over the service; it does not connect to locally installed quantum hardware. The first successful run requires an account, a selected Leap project, an API token authorized for that project, and an Ocean SDK environment.

As an Amazon Associate I earn from qualifying purchases.

  • A Leap account and project: create or sign in to an account and select the project that will own the submission. Access, quotas, and available solvers are project-dependent.
  • An API token: arbitrary problem submission requires a token. Trial projects may be restricted to specified demonstrations rather than unrestricted problem submission.
  • Python or a compatible development environment: D-Wave supports local IDEs and cloud development environments that implement the Development Containers specification; its documentation recommends GitHub Codespaces as one option.
  • The Ocean SDK: install the packages that provide BQM classes, samplers, composites, and the Leap client configuration.
  • A small objective model: a BQM/QUBO is the most approachable starting point. Problems with richer constraints or variable types require another model and its matching sampler.

Keep the token out of source control, notebooks shared with other people, screenshots, and error reports. Store it through Ocean’s configuration workflow or the environment-variable method documented for the D-Wave Solver API (SAPI).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How Ocean’s optimization workflow works

D-Wave describes the process in two steps: formulate the problem as an objective function, then find good solutions by sampling. Ocean packages those steps into a model-and-sampler workflow:

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
  1. Formulate: translate decisions, costs, and penalties into a supported objective model.
  2. Select a solver: choose a classical sampler, a Leap hybrid solver, or a QPU sampler.
  3. Sample: submit the model and receive candidate variable assignments, energies, and diagnostic fields.
  4. Validate: decode the assignment into business terms, check every original constraint, and compare its objective value with a suitable classical baseline.

The energy reported by a sampler is the value of the encoded mathematical objective, not automatically the value or validity of your real-world solution. A penalty may make an invalid state expensive, but your application must still test feasibility explicitly.

Choose the right first model and sampler

A BQM contains binary or spin variables and linear and quadratic terms. A QUBO is the binary form of that model, commonly written as a quadratic expression in variables restricted to 0 or 1. You use coefficients to represent the real objective and, when necessary, penalties for violating constraints.

Problem shape Typical Ocean model Beginner submission route Important consideration
Unconstrained binary decisions with linear and pairwise interactions BQM or QUBO LeapHybridSampler or the version-specific LeapHybridBQMSampler Encode all desired trade-offs in the objective; validate feasibility afterward.
Explicit constraints and possibly binary, integer, or other supported variables Constrained quadratic model (CQM) The Leap hybrid CQM sampler that is available to your project Use a sampler that accepts CQM; a BQM sampler will reject the model.
Discrete variables with more than two values Discrete quadratic model (DQM) The matching Leap hybrid DQM sampler Confirm the solver’s current variable and interaction requirements.
Higher-order or non-quadratic terms Nonlinear model, where supported The corresponding hybrid nonlinear sampler Availability and limits vary; inspect the current solver list before submission.
Experiment that specifically requires QPU access BQM/QUBO mapped to hardware topology DWaveSampler wrapped by EmbeddingComposite Logical variables must be minor-embedded into the physical QPU graph.

For a first experiment, a hybrid BQM submission is usually the least surprising path. Leap manages a cloud workflow that combines classical processing with quantum resources, so you can focus on modeling and result interpretation instead of hardware topology. Direct QPU use is appropriate when you need QPU-specific control or are studying embedding and sampling behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Ocean and configure Leap authentication

  1. Create the environment. Use a virtual environment, a development container, or a supported cloud IDE. Keeping Ocean isolated avoids conflicts with unrelated Python packages.
  2. Run the interactive setup. In a terminal, run dwave setup. The documented workflow can install the Ocean SDK, offer optional contributor tools, authorize Leap, and create the local configuration used by samplers.
  3. Sign in and choose a project. Follow the authorization flow, then select the Leap project associated with the token you intend to use. A token belongs to a project; a valid token for a different project is not a substitute.
  4. Verify access before submitting a large job. Inspect the configured profile and the solvers visible to that project. Solver names, availability, quotas, and service policies can change, so use the current Leap dashboard and documentation rather than hard-coding an old solver identity.
  5. Protect the credential. Use Ocean’s configuration or the SAPI-supported environment-variable mechanism in deployment. Never commit the token to Git, place it in a notebook cell that will be published, or print the complete configuration in logs.

The referenced Ocean documentation identifies version 9.5.0. Treat that number as a dated reference, not a guarantee that it is the version installed in your environment. If an import or solver name differs, check the package reference and the solver list associated with your project.

Run a minimal BQM on a Leap hybrid solver

The following tiny model uses a helper that encodes the Boolean relation y1 = x1 AND x2. It is useful as a connectivity and authentication test because it is small enough to inspect manually.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
from dimod.generators import and_gate
from dwave.system import LeapHybridSampler

# A tiny BQM encoding y1 = x1 AND x2
bqm = and_gate("x1", "x2", "y1")

sampler = LeapHybridSampler()
sampleset = sampler.sample(bqm)
print(sampleset)

Run the file from the same environment in which dwave setup created or selected your configuration. The returned binary sampleset has one column for each variable and an energy column. A typical first inspection is:

best = sampleset.first
print("assignment:", dict(best.sample))
print("energy:", best.energy)
print("occurrences:", best.num_occurrences)

sampleset.first is ordered by the sampler’s reported energy, so it is a convenient candidate—not a proof that your application objective has been met. For the AND relation, decode the three bits and confirm that the output bit equals the logical AND of the two input bits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Depending on the installed Ocean release, the BQM hybrid class may be exposed as LeapHybridSampler or LeapHybridBQMSampler. If the import fails, do not change the model blindly: inspect the current dwave-system package reference and the solvers available to the active project, then use the class documented for that release.

Submit your own small QUBO

A QUBO is commonly represented as a mapping from a variable or variable pair to a coefficient. The diagonal terms represent linear costs; off-diagonal terms represent pairwise interactions. The sampler minimizes the resulting energy. If your original problem is a maximization, convert it consistently—for example, by negating the objective before adding any penalties.

Here is a self-contained pattern using a dictionary-based QUBO. The coefficients are illustrative; replace them with values derived from your problem.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord | 6.35mm Jack, Durable Design, Stage and Home Studio Use, Low Noise Shielded Electric Cord for Bass, Keyboard, Amp, Mixer
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
from dwave.system import LeapHybridSampler

# Minimize: 2*x0 + 1*x1 - 3*x0*x1
Q = {
    ("x0", "x0"): 2.0,
    ("x1", "x1"): 1.0,
    ("x0", "x1"): -3.0,
}

sampler = LeapHybridSampler()
sampleset = sampler.sample_qubo(Q)

for row in sampleset.data(fields=["sample", "energy", "num_occurrences"]):
    print(row)

best = sampleset.first.sample
print("best assignment:", dict(best))

Before trusting the result, write down the original objective separately from the encoded QUBO. Recalculate the original objective from the returned assignment, check all hard constraints, and record any penalty violations. This catches sign errors, missing variables, incorrect penalty weights, and decoding mistakes that an energy value alone cannot reveal.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When and how to use the QPU directly

Direct QPU submission adds a hardware-mapping step. Your logical QUBO graph rarely matches the QPU’s physical connectivity exactly, so an embedding composite maps logical variables to chains of physical qubits and manages the associated interactions.

from dwave.system import DWaveSampler, EmbeddingComposite

Q = {
    ("x0", "x0"): 2.0,
    ("x1", "x1"): 1.0,
    ("x0", "x1"): -3.0,
}

sampler = EmbeddingComposite(DWaveSampler())
sampleset = sampler.sample_qubo(Q, num_reads=5000)
print(sampleset)

DWaveSampler selects a QPU according to your configured or explicitly selected solver. EmbeddingComposite performs the minor embedding from the logical problem to that QPU’s topology. The num_reads=5000 value is an example from the documented pattern, not a universal requirement or a promise of a particular runtime or solution quality.

Inspect QPU results for more than the lowest energy. Embedding-related fields and diagnostics can indicate broken chains or other mapping issues. Experiment with one change at a time—such as read count or an embedding-related setting—and keep the model, solver identity, and configuration with your result so the run can be reproduced while that solver remains available.

Hybrid versus direct QPU: a practical decision

Decision point Leap hybrid BQM route Direct QPU route
Best first use Learning the model/sample workflow or solving a small-to-medium supported model without hardware-mapping work Studying QPU behavior, embedding, annealing parameters, or a workload that specifically calls for QPU access
Model support Use the hybrid sampler matching BQM, CQM, DQM, or nonlinear input Typically submit a QUBO/BQM accepted by the selected QPU sampler
Constraints Some hybrid model types represent constraints natively; confirm the selected solver Constraints generally must be converted into objective penalties before QPU submission
Embedding Handled within the cloud hybrid workflow Required for a general logical graph; use an embedding composite or an explicit embedding
Hardware controls Less direct control over individual QPU parameters More direct access to QPU sampling controls, subject to solver and API limits
Diagnostics Inspect energies, samples, counts, and model-specific fields Also inspect embedding, chain, and QPU timing diagnostics
Baseline development Easy to compare with a local classical sampler while building the model Still compare with a classical baseline; a QPU result is not automatically optimal
Availability and quota Depends on the project and current hybrid solver policies Depends on QPU access, project permissions, current solver availability, and QPU scheduling

Validate a returned solution correctly

Use a validation function that knows the original problem, not just the encoded coefficients. A robust validation pass should:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
  • Convert the sample into ordinary domain values, such as selected routes, machines, or items.
  • Check every hard constraint independently, including capacity, assignment, coverage, and integrality rules.
  • Recompute the original objective in its original units and direction.
  • Separate penalty energy from business cost so you can tell whether a low-energy state is actually feasible.
  • Compare the candidate with a classical sampler or exact method on small instances. Agreement is a useful modeling check even when the production problem will be larger.
  • Inspect duplicate samples and occurrence counts; a frequently returned state can be useful evidence, but frequency is not a proof of optimality.

For constrained models, a feasible state with a slightly higher encoded energy may be preferable to an infeasible state with the lowest raw energy. The acceptance rule belongs to your application, so implement it explicitly rather than relying on row order alone.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot the first submission

Authentication or authorization failure

Confirm that the active configuration points to the intended Leap project, that the token has not expired or been revoked, and that the token was not copied with extra whitespace. Re-run the Ocean authorization flow if necessary. Tokens are project-specific, so switching projects can make an otherwise valid token appear unauthorized.

No solver is available

Open the current Leap dashboard and inspect the solvers exposed to the project. Solver identities, maintenance windows, access rules, quotas, and training-plan policies change. Do not assume that a solver name from an old code sample remains available or has the same limits.

The model is rejected

Check the sampler’s accepted model type and requirements. A BQM sampler cannot accept a CQM, DQM, or nonlinear model merely because all of them are optimization problems. Also verify variable labels, coefficient types, constraint forms, and any size or time limits documented for that solver.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The import or class name is missing

Print the installed Ocean and dwave-system versions, then consult the current package reference. The BQM hybrid class name may differ by release, and a project may expose a different set of solver classes than an older tutorial.

The result is unexpected or infeasible

Run the same model with a classical sampler during development. Recalculate the original objective, inspect penalties and scaling, and verify that variable names decode to the intended domain fields. For QPU runs, inspect embedding and chain diagnostics. A poor result may be a modeling error, an inadequate penalty, an embedding problem, or ordinary heuristic variation.

The job times out or exceeds a project limit

Check the current project quota and solver limits, reduce the test instance, and submit asynchronously for production workloads rather than blocking an interactive process indefinitely. Preserve the problem identifier and implement polling, timeout handling, retries where safe, and clear failure reporting.

Turn the experiment into a dependable application

A script that prints a sampleset is a useful first test but not yet an integration. A production flow should separate model construction, submission, result retrieval, and validation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Preprocess inputs: normalize units, remove impossible choices, and create stable variable labels.
  2. Build and record the model: retain the objective, penalty weights, variable map, model type, and software version used for the submission.
  3. Select a solver at runtime: discover or configure an accessible solver rather than assuming a permanent solver identity.
  4. Submit asynchronously when appropriate: persist the submission identifier, poll for completion, and handle service errors, timeouts, and cancellation according to current SAPI guidance.
  5. Validate and rank results: filter infeasible samples, recompute the domain objective, and retain diagnostics alongside the selected assignment.
  6. Maintain a classical baseline: test small and representative instances locally so regressions in encoding or decoding are visible before cloud usage grows.

Keep credentials and result data under separate controls. A token should authorize service access; it should not be embedded in application data, model files, or logs that are shared with analysts.

A first-run checklist

  • Leap account created and the correct project selected.
  • Project token configured through Ocean setup or the documented SAPI environment mechanism.
  • Ocean SDK installed in the environment that runs the script.
  • Current project dashboard checked for accessible hybrid and QPU solvers.
  • Problem expressed as the model type accepted by the chosen sampler.
  • Hybrid BQM example run successfully before attempting direct QPU access.
  • Lowest-energy sample decoded and checked against every original constraint.
  • Original objective recomputed and compared with a classical baseline on small cases.
  • For QPU work, embedding and chain diagnostics recorded with the result.
  • For production, asynchronous handling, polling, timeouts, retries, and credential protection implemented.

The shortest reliable path is therefore: configure a Leap project, run a tiny BQM through the available hybrid sampler, validate the assignment in your own problem language, and only then move to a direct QPU submission when embedding or QPU-specific controls are part of the experiment.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

D-WaveLEAPOcean SDKoptimizationPythonQuantum ComputingQubo

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.