KEMBAR78
Blochsphere Visualization by prateekchawla168 · Pull Request #1763 · NVIDIA/cuda-quantum · GitHub
Skip to content

Conversation

@prateekchawla168
Copy link
Contributor

@prateekchawla168 prateekchawla168 commented Jun 5, 2024

Description

Fixes #1639 by adding a visualization for Bloch sphere for single-qubit states.
Significant changes:

  • Added QuTiP as an optional dependency in pyproject.toml
  • Added bloch_visualize module in python/cudaq/visualization with code to handle Bloch sphere generation and management. Docstrings are contained within the code itself. Tested with Jupyter notebooks.
  • Modified Python initialization init.py to import QuTiP, and if successful, load the visualization functionality.
  • REST server cannot be built on Singularity containers because CMake is never able to find ZLib/Minizip, especially if the program must search manually. Corrected the corresponding CmakeLists.txt so it searches in the correct places.

This is a submission for Unitary Hack 2024.

I have read the Contributor License Agreement and I hereby accept the Terms.

@copy-pr-bot
Copy link

copy-pr-bot bot commented Jun 5, 2024

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions
Copy link

github-actions bot commented Jun 5, 2024

CLA Assistant Lite bot All Contributors have signed the CLA.

@prateekchawla168
Copy link
Contributor Author

I have read the Contributor License Agreement and I hereby accept the Terms.

@prateekchawla168
Copy link
Contributor Author

recheck

Copy link
Collaborator

@khalatepradnya khalatepradnya left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution. This is looking good.
Recommend the following enhancements for completeness:

@khalatepradnya
Copy link
Collaborator

Can you add screenshots to this PR of how the output will look like for - (a) one Bloch sphere, (b) side by side rendering of multiple Bloch spheres?

@khalatepradnya
Copy link
Collaborator

For CI failures:

  1. Add license header to the new file python/cudaq/visualization/bloch_visualize.py
  2. For python formatting run yapf. First install it pip install yapf and then run with yapf --style google --recursive -i <filename>
  3. Run the spell checker script and update accordingly.

@prateekchawla168
Copy link
Contributor Author

Added functionality in the latest commit:

@prateekchawla168
Copy link
Contributor Author

Screenshots for Visualisation on Bloch sphere:

Screenshot from 2024-06-06 13-46-31
Screenshot from 2024-06-06 13-46-18
Screenshot from 2024-06-06 13-45-52

@prateekchawla168
Copy link
Contributor Author

Implemented @amccaskey 's suggestion: If import qutip fails, then a helpful error message is printed to the screen whenever the user attempts to call any of the visualization functions.

@khalatepradnya
Copy link
Collaborator

Thanks for the updates and addressing review comments.
Can you fix the 2 CI failures (code formatting, and spell check)?

@freifrauvonbleifrei
Copy link
Contributor

Hi, a comment from my work on #1723 : I am introducing a folder python/cudaq/display/ which semantically looks similar to your python/cudaq/visualization/. Maybe we could coordinate on a joint folder name.

@prateekchawla168
Copy link
Contributor Author

prateekchawla168 commented Jun 7, 2024

@freifrauvonbleifrei Absolutely! I had used the name visualization simply because I meant to put in multiple files there, as I had planned to work on the $\LaTeX$ rendering next, but it seems like you've got it handled already, which is awesome!

Fixed docstrings in python/cudaq/visualization/bloch_visualize.py
Copy link
Collaborator

@khalatepradnya khalatepradnya left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. Requesting changes on spell check.

@freifrauvonbleifrei
Copy link
Contributor

@freifrauvonbleifrei Absolutely! I had used the name visualization simply because I meant to put in multiple files there, as I had planned to work on the LATEX rendering next, but it seems like you've got it handled already, which is awesome!

@prateekchawla168 I had chosen display instead of visualize because the amount of data shown is rather limited (both for the circuits and the bloch sphere), which better suits the notion of display. If you agree with the naming, feel free to rename your folder to avoid merge conflicts further upstream :)

Copy link
Collaborator

@khalatepradnya khalatepradnya left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution.
One open Q in comments.
CI failure will be addressed separately (see 6328008)

@khalatepradnya
Copy link
Collaborator

khalatepradnya commented Jun 17, 2024

/ok to test

Command Bot: Processing...

@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Jun 17, 2024
@khalatepradnya
Copy link
Collaborator

khalatepradnya commented Jun 17, 2024

/ok to test

Command Bot: Processing...

@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Jun 17, 2024
@khalatepradnya
Copy link
Collaborator

@prateekchawla168: Please add a comment on the issue #1639 so it can be assigned to you.

@khalatepradnya
Copy link
Collaborator

khalatepradnya commented Jun 18, 2024

/ok to test

Command Bot: Processing...

@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Jun 18, 2024
khalatepradnya and others added 2 commits June 18, 2024 11:35
  image so that it available to run the new functionality
out-of-the-box. Also addresses the CI failure on notebook validation.
@khalatepradnya
Copy link
Collaborator

khalatepradnya commented Jun 18, 2024

/ok to test

Command Bot: Processing...

 -- updated toml file to reflect qutip<5
 -- updated notebook to use default target (optionally set
'density-matrix-cpu')
 -- removed redundant comments and fixed one occurence of 'CUDA-Q'
@khalatepradnya
Copy link
Collaborator

khalatepradnya commented Jun 18, 2024

/ok to test

Command Bot: Processing...

@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Jun 18, 2024
@bettinaheim bettinaheim merged commit ccf9713 into NVIDIA:main Jun 19, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 19, 2024
@bettinaheim bettinaheim added the enhancement New feature or request label Jul 29, 2024
@bettinaheim bettinaheim added this to the release 0.8.0 milestone Jul 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bloch sphere visualization for single-qubit operations

5 participants