dwavesystems / dwavesystems/dwave-cloud-client
``reformat_parameters()`` method enables initial_state in list format
- Dominant language
- Python
- Stars
- 63
- Forks
- 44
- Avg merge
- 13h 45m
- Merged PRs (30d)
- 1
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](https://github.com/dwavesystems/dwave-system/blob/edaef2714744d1a1b185f4b9a5f92ed02bbb52f1/dwave/system/composites/embedding.py#L293)
```
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](https://docs.dwavequantum.com/en/latest/quantum_research/solver_parameters.html#initial-state) "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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.