Skip to content

initial_state documentation unclear, example error, no type checking for dictionaries. #597

@jackraymond

Description

@jackraymond

Description
When initial_state is provided as a dictionary invalid values are accepted. When presented as a list {-1,1,3} is checked by contrast.
Documentation gives an invalid example (spin values set to 0 and 1 in initial_state, but sample_ising called).
Documentation type is unclear, both a list and a dictionary are valid types, the documentation makes it seem like the correct type is a list of tuples.

To Reproduce
Documentation (accessed October 20th 2025):
https://docs.dwavequantum.com/en/latest/quantum_research/solver_parameters.html#parameter-qpu-initial-state

import random
from dwave.system import DWaveSampler
sampler = DWaveSampler()
J = {coupler: random.choice([-1, 1]) for coupler in qpu.edgelist}
initial = {qubit: random.randint(0, 1) for qubit in qpu.nodelist}
reverse_schedule = [[0.0, 1.0], [5, 0.45], [99, 0.45], [100, 1.0]]
reverse_anneal_params = dict(anneal_schedule=reverse_schedule,
                             initial_state=initial,
                             reinitialize_state=True)
sampleset = sampler.sample_ising(
    {}, J, num_reads=1000, **reverse_anneal_params)
sampleset.resolve()

Expected behavior
Clear documentation on accepted types, some type checking.

Environment:

  • OS: [Ubuntu 16.04.4 LTS]
  • Python version: [e.g. 3.7.0]

Additional context
Trying to fix this dependent issue: #587
D-Wave internal thread on issue: https://dwavesys.slack.com/archives/CBN3G5T60/p1760995879522169

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions