-
Notifications
You must be signed in to change notification settings - Fork 52
Dynamic State Preparation #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Dynamic State Preparation #306
Conversation
| # n is static (known at compile time), so we can use normal numpy here | ||
| n = int(np.log2(target_array.shape[0])) | ||
|
|
||
| thetas, u_params, phases = _preprocess(target_array) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This classical preprocessing function for n=20 takes 0.3 seconds on my laptop (each layer is vectorized with vmap). Therefore, most of the time is spent in the quantum part, which basically just calls qswitch (with a bit reverse operation, as we cannot slice a DynamicQubitArray backward)
|
|
||
| int_encoder(self, self.encoder(value)) | ||
|
|
||
| def init_state_qswitch(self, state_array, method="auto"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@positr0nium Instead of having a separate init_state_qswitch method, what about modifying the existing init_state in such a way that the workflow is dispatched with different implementations depending on the type of the provided argument?
That is, if a dict is provided, the qiskit implementation is used, which is currently based on a different (and currently more efficient) algorithm, while if an array is provided we dispatch to the implementation introduced in this PR. Please let me know what you think : )
Context: This PR implements the state preparation algorithm based on the technique using multiplexers. However, instead of the latter, we use the
qswitchfunction.Description of the Change: As above. For a description of the algorithm, we refer to the documentation.
Benefits: Qrisp can now initialize a quantum circuit without resorting to
qiskit.Possible Drawbacks: None that I can think of, although we can probably implement a more efficient algorithm in the future. The reason is that the
qswitchfunction introduces several auxiliary qubits, which can easily cause overhead.Related GitHub Issues: None