Skip to content

Divide-and-conquer implementation for Dicke states - #767

Draft
JiriGuthJarkovsky wants to merge 12 commits into
eclipse-qrisp:mainfrom
JiriGuthJarkovsky:dicke_dnc
Draft

Divide-and-conquer implementation for Dicke states#767
JiriGuthJarkovsky wants to merge 12 commits into
eclipse-qrisp:mainfrom
JiriGuthJarkovsky:dicke_dnc

Conversation

@JiriGuthJarkovsky

Copy link
Copy Markdown

Description

This adds a new implementation to the function dicke_state from dicke_state_prep.py. This is based on a newer (allegedly more efficient) algorithm.

Related Issues

Closes #755

Type of Change

  • Feature (new functionality)
  • Change Request (modification of existing functionality)
  • Bug Fix
  • Refactoring (no behavior change)
  • Performance improvement
  • Documentation
  • CI / Build

Breaking Change?

  • Yes
  • No

What was changed?

  • The function dicke_state was given a new input parameter method which decided which method to use.
  • The previous functionality from dicke_state was separated into a helper function _apply_dicke_unitary and re-used in both implementation methods.
  • For the divide-and-conquer method, a new helper function _divide was added.
  • All new code is closely following the algorithm from the paper https://arxiv.org/pdf/2112.12435

How was it tested?

At the moment, no new tests were added. The default value for method was set to "divide-and-conquer", so that the new method is tested using the tests previously used.

More tests to be added later and old tests to be expanded to cover both methods.

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review
  • I have added/updated tests (referencing issue Test-IDs)
  • All tests pass locally and in CI
  • I have updated the documentation
  • I have added a changelog entry to changelog-dev.rst
  • Breaking changes are documented with migration path

Reviewer Notes

  • I have noticed that the older code doesn't follow strict coding standards, namely the helper function split_cycle_shift is not prepended with an underscore _ and its internal variables highIndex and lowIndex use camelCase, which they shouldn't. I have not changed this as that's out of scope for this PR, but now the code style is somewhat inconsistent (I have prepended the new helper functions with underscores).

  • Currently, two of the jasp-related tests fail. I don't know what jasp is and how to work with it. I would appreciate any advice:

FAILED tests/primitives_tests/test_dicke_states.py::test_dicke_state_balanced_jasp - jax.errors.TracerBoolConversionError: Attempted boolean conversion of traced array with shape bool[].
FAILED tests/primitives_tests/test_dicke_states.py::test_dicke_state_balanced_jasp_inverse - jax.errors.TracerBoolConversionError: Attempted boolean conversion of traced array with shape bool[].


# If k > n/2, it is easier to create D(n, n-k) instead of D(n, k), and then apply the X gate to all qubits.
large_k = k > n // 2
if large_k:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you cannot use this because in jasp mode it is a dynamic value. See if #598 is helpful, it is still incomplete FYI.

x(qv[n - k : k]) # Partially undo the initial state, reducing its Hamming weight from k to n-k.
k = n - k

if method == "deterministic":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings are always static, so this conditional is fine :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a new implementation of creating Dicke states

3 participants