Skip to content

Shadows #966

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Shadows #966

wants to merge 1 commit into from

Conversation

gzemlevskiy17
Copy link

@gzemlevskiy17 gzemlevskiy17 commented Apr 22, 2025

PR Description

Implement a demo of the classical shadows algorithm.

I was unsure on how to use rebase or pre-commit.

Some notes

  • Please make sure that the notebook runs successfully with the latest Classiq version.

  • Please make sure that you placed the files in an appropriate folder

    • And that the file names are clear, descriptive, and match the notebook content.
      • Note that we require the file names of .ipynb and .qmod to be unique across this repository.
    • Plus, please make sure that all required files are included: .qmod, .synthesis_options.json, .metadata.json
    • And that images are embedded inside the notebook, not added as external files
  • If applicable, please include link to the paper on which the notebook is based, in the notebook itself.

  • Please use rebase on your branch (no merge commits)

  • Please link this PR to the relevant issue

  • Please make sure to run pre-commit when commiting changes

    • If you're using git in the terminal, make sure to install pre-commit via running pip install pre-commit followed by pre-commit install
    • Note that Classiq runs automatic code linting. Meaning that one of the tests verifies the output of pre-commit.
    • Also note that pre-commit may minorly alter some files. Make sure to git add the changes done by pre-commit

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@@ -0,0 +1,512 @@
{
Copy link
Member

@TomerGoldfriend TomerGoldfriend Apr 24, 2025

Choose a reason for hiding this comment

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

Thank you @gzemlevskiy17 for this PR! Please provide details in Markdown about the code so we can review it properly.

  • Short introduction about what is implemented.
  • Explain major code blocks, and how they are related to parts of the implementation.
  • Add a snapshot of the quantum part from Classiq visualization.

Reply via ReviewNB

@@ -0,0 +1,512 @@
{
Copy link
Member

@TomerGoldfriend TomerGoldfriend Apr 24, 2025

Choose a reason for hiding this comment

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

If you like, we have a function in our open-library that prepares a bell state. You can use it as well if you want.

https://github.com/Classiq/classiq-library/blob/main/functions/qmod_library_reference/classiq_open_library/special_state_preparations/prepare_bell_state.ipynb


Reply via ReviewNB

@TomerGoldfriend
Copy link
Member

@gzemlevskiy17 are you still working on this?

@gzemlevskiy17
Copy link
Author

@TomerGoldfriend Yes, sorry I was working on developing the Classiq challenge for the FLIQ hackathon. I will update this PR soon.

@NadavClassiq
Copy link
Collaborator

Hi @gzemlevskiy17 !
Still plan to complete this project?

@gzemlevskiy17
Copy link
Author

Hi @NadavClassiq. Yes! The project is finished, but I am still figuring out how to adhere to the contributing guidelines. I actually have a few questions:

I ran pre-commit and one test did not pass, specifically:

Auto add test............................................................Failed
- hook id: auto-add-tests
- exit code: 1

Executable `.internal/pre_commit_tools/auto_add_tests.py` is not executable

What should I do about this?

Also, since classical shadows involves applying random unitary gates, the circuit, and thus the quantum model, vary, so I don't know if I should generate a .qmod file as per the guidelines.

Finally, I am unsure of the git workflow I should follow, particularly where rebase comes in.

@NadavClassiq
Copy link
Collaborator

Hi @gzemlevskiy17!

  1. Custom auto tests are not required in the community/paper_implementation_project/, which is where you should first contribute. We might later on move the notebook to a different location, and take care the testing issue.

  2. Regarding the qmods, if you can make it work in a reproducible way, using a random seed, that would be great :)
    Anyway, qmods are required, at least the final one. Whenever you are done, I will take a closer look and, worst case, will give a note.

  3. Regarding the GitHub workflow, you don't really need to rebase at the moment, as only you work on these files. Rebase is used to take your branch and add newer changes that were rebased and merged while you were still working.

Lmk if you need further help :)

@NadavClassiq NadavClassiq added the Paper Implementation Project Implement a paper using Classiq label Jun 30, 2025
@gzemlevskiy17
Copy link
Author

gzemlevskiy17 commented Jun 30, 2025

@NadavClassiq Thank you!

If I am contributing to community/, what would I write for the qmod_type and level tags in the metadata.json file? Also, the paper name is "Predicting Many Properties of a Quantum System from Very Few Measurements", which is very long. Should I use that name for the filenames or is it fine if I named all the files "classical_shadows..."

@NadavClassiq
Copy link
Collaborator

Hi @gzemlevskiy17 !

You can use a shorter name, just write the full name with a proper link in the notebook.
Regarding the metadata.json, just keep it as it is from the algorithm you have copied it from.

Lmk if you need anything else :)

@gzemlevskiy17 gzemlevskiy17 reopened this Jul 12, 2025
@gzemlevskiy17
Copy link
Author

@NadavClassiq I've pushed my latest changes.

One part of my code uses a list of PauliTerms as a Hamiltonian, but since that has been deprecated as input for ExecutionSession.estimate(), it generates a warning. I decided to keep it, because another part of my code uses hamiltonian_to_matrix(), which needs a PauliTerm.

@NadavClassiq
Copy link
Collaborator

Great Job @gzemlevskiy17 !

I'll be reviewing it soon, maybe with feedback and suggestions for improvement.

Thanks for the efforts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Paper Implementation Project Implement a paper using Classiq
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants