Skip to content

q_state.bsz is not fix! #305

Description

@s110m

Consider the following cell in the sec1_basic.ipynb file:

# q_state = tq.QuantumState(n_wires=2)
q_state = tq.QuantumDevice(n_wires=2, bsz=1, device="cpu")
print(q_state)

# q_state.set_states(torch.tensor([[0, 0, 1, 0], [0, 1, 0, 0]]))
q_state.set_states(torch.tensor([[0, 0, 1, 0], [0, 1, 0, 0], [-5, 2, 5, 7]], dtype=torch.complex64))
print(q_state)

q_state.x(wires=0)
print(q_state)

bitstring = tq.measure(q_state, n_shots=1024, draw_id=2)
print(bitstring)

Although q_state.bsz is initially set to 1, it is still possible to pass more than one state to

q_state.set_states(torch.tensor([[0, 0, 1, 0], [0, 1, 0, 0], [-5, 2, 5, 7]], dtype=torch.complex64))

Is this behavior intentional (by design)?
It seems more consistent if the number of states matched bsz. Am I correct?

Also, we have the state [-5, 2, 5, 7] which is not normalized. Shouldn't we normalize this state when we want to consider this as a state?

Thank you.

Activity

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

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