Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

``reformat_parameters()`` method enables initial_state in list format

Open
#700 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
numpy, python
Domain
api, backend

Research direction

Start at dwave/system/composites/embedding.py line 293 and compare its initial_state handling with the linked solver-parameters documentation. Determine the intended accepted format and validation behavior, then update the relevant implementation and documentation so they agree and the supplied invalid list case is covered.

Written by the indexing model from the issue text.

Description

The StructuredSolver's reformat_parameters() method states that it "allows initial_state to be submitted as a dictionary mapping the qubits to their initial value" but due to this line

parameters['initial_state'] = {u: state[v]
                                           for v, chain in embedding.items()
                                           for u in chain}

when using an embedding composite (e.g., FixedEmbeddingComposite) you can set initial_state as any list.

sampleset = sampler.sample_ising({}, {(0,1): -1}, 
    anneal_schedule=[[0.0, 1.0], [0.1, 0.95], [0.2, 0.95], [0.3, 1.0]],
    reinitialize_state=True, 
    initial_state=[13, 32], 
    label="test initial 1", 
    num_reads=500)

This would be rejected were you to directly submit such a thing to the QPU:

>>> sampleset = qpu.sample_ising({}, {(0,1): -1}, anneal_schedule=[[0.0, 1.0], ...
SolverFailureError: Invalid length of initial_state

I'm not sure what the preferred behavior is but our documentation states "Specifies the initial classical state of all qubits. ... Provide (qubit, state) pairs..." so we should update the docs to what we want to enable and prevent initial states such as the above (initial_state=[13, 32]) from working.

The context is my finding the structure below being used and not understanding why it was working at first:

initial_state = ((1)**np.arange(N))

where N is the number of qubits in a ferromagnetic ring and `FixedEmbeddingComposite`` is used.

Dominant language
Python
Stars
63
Forks
44
Avg merge
2d 9h
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dwavesystems/dwave-cloud-client

All issues in dwavesystems/dwave-cloud-client

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.