pySLM2

pySLM2: A full-stack python package for holographic beam shaping - Published in JOSS (2024)

https://github.com/qiti/pyslm2

Science Score: 96.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 10 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
  • Institutional organization owner
    Organization qiti has institutional domain (qiti.iqc.uwaterloo.ca)
  • JOSS paper metadata
    Published in Journal of Open Source Software

Scientific Fields

Artificial Intelligence and Machine Learning Computer Science - 83% confidence
Last synced: 4 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: QITI
  • License: apache-2.0
  • Language: Python
  • Default Branch: master
  • Size: 28.7 MB
Statistics
  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • Open Issues: 2
  • Releases: 1
Created over 5 years ago · Last pushed about 1 year ago
Metadata Files
Readme Contributing License

README.md

pySLM2

Test Build Documentation HTML status

We are writing a paper for Journal of Open Source Software (JOSS)! Read the manuscript here: https://drive.proton.me/urls/T92N7SMT5M#nBvZvODDgZCc

pySLM2 is a Python package designed for using spatial light modulators (SLMs) in holographic beam shaping. It includes modules for hologram generation, simulation, and hardware control, making it a comprehensive toolkit for high-quality optical control.

The goal of pySLM2 is to provide a tool box for for engineering high-quality optical controls, which are essential for various scientific and engineering applications. These applications include atom trapping, addressing individual quantum objects, preparing exotic quantum states, and multi-beam laser machining. pySLM2 was originally developed for and is actively used in the trapped ion quantum information processing research at the Quantum Information with Trapped Ions Lab at the University of Waterloo.

  • API Docs: https://pyslm2.pages.dev/

Instructions to build documentation locally can be found in docs/README.md.

To cite the work, please use DOI

Dependencies

pySLM2 supports Python 3.9+.

The dependencies of pySLM2 in includes: numpy, scipy, matplotlib, and tensorflow.

Installation

pySLM2 installation with setuptools

If you prefer the development version from GitHub, download it here, cd to the pySLM2 directory, and use: pip install .

Or, if you wish to edit the pySLM2 source code without re-installing each time

pip install -e .

GPU Support via Tensorflow

Tensorflow installation tips

pySLM2 primarily relies on tensorflow for most of its numerical computations. For machines with compatible hardware, tensorflow can seamlessly utilize GPU acceleration to enhance performance, provided it is installed correctly.

The exact package dependencies vary depending on each system configuration and the GPU card. For details about machine compatibility and correct version of tensorflow, please refer to the Tensorflow's website, which provides installation guide for different operating systems. Another authors' recommended tensorflow installation guide can also be found in this website which provides thorough information about package dependecies such as cuda and cudnn versions.

As a reference, in our setup with Windows 10 Build 17763 and an NVIDIA Quadro M4000 GPU, we executed the following commands to install tensorflow-related packages in a Conda environment with python=3.7. ``` conda install -c conda-forge cudnn==7.6.5 conda install -c conda-forge cudatoolkit==10.1.243

pip install tensorflow==2.1 pip install tensorflow-gpu==2.1 ```

Runtime Benckmarking: CPU vs GPU

Several runtime benchmarking scripts for iterative hologram generations algorithms are included in a separate folder pySLM2/runtime_benchmark. Instructions for running those tests can be found in pySLM2/runtime_benchmark/README.md.

Runtime Benckmarking Example

Algorithm performance comparision: Intel Core i9-9900K CPU vs NVidia Quadro M4000 GPU

Our machine has Windows 10 Build 17763 with Intel Core i9-9900K CPU and an NVidia Quadro M4000 GPU. Key package dependencies are: - python: 3.7.1 - tensorflow: 2.1.0 - tensorflow-gpu: 2.1.0 - cudnn: 7.6.5 - cudatookkit: 10.1.243

From our testing, we observed: | | Case 1 (gs) | Case 2 (mraf) | Case 3 (ifta) |-------------|-------------|-------------|-------------| | CPU |$225.11 \pm 3.98$ s | $221.64 \pm 1.78$ s | $206.44 \pm 0.49$ s| | GPU | $6.48 \pm 0.29$ s | $8.29 \pm 0.31$ s |$6.76 \pm 0.50$ s|

These findings show that the iterative algorithms can be greatly accelerated by GPU usage.

Optional Dependencies for Hardware Controls

pySLM2.util includes provides an universal interface for interacting with different SLM controllers from different vendors. pySLM2.util itself doesn't implement the communication protocol. Instead, it relies on different libraries and wraps them with a universal interface.

Vialux

The DMDs from Vialux are communicated with the ALP library and a python binding, ALP4lib.

  • To install the ALP library, visit the vendors website: https://vialux.de/en/download.html
  • The python binding, ALP4lib, can be installed from PyPi: pip install ALP4lib

Visitech

The DMD from Visitech are communicates with UDP, and therefore no driver is needed to be installed. pySLM.util relies on the Luxbeam library which can be installed from PyPi: pip install Luxbeam

Notes for LCOS-SLMs

For LCoS-SLMs, most models can be directly controlled via standard monitor connections. To display holograms, one might consider using slmPy. Since pySLM2 calculates hologram values in radians, one will need a conversion table to determine the corresponding grayscale values for output. This conversion typically varies based on the light wavelength and the specific model of the LCoS-SLM.

Floating Point Precision

Since not all the graphic cards are optimized for double-precision computation, the default precision of pySLM2 is set to single-precision. If you wish to use double-precision, you can configure the backend right after you import the package : pySLM2.BACKEND.dtype = pySLM2.BACKEND.TENSOR_64BITS

In practice, the single-precision is sufficient for most of the applications. However, if you are suspecting the precision is not enough, you can change the precision to double-precision and see if the results are different.

Research using pySLM2

If you used pySLM2 in your research, we'd like to hear from you!

  • Shih, Chung-You, et al. "Reprogrammable and high-precision holographic optical addressing of trapped ions for scalable quantum control." npj Quantum Information 7.1 (2021): 57. https://doi.org/10.1038/s41534-021-00396-0

  • Motlakunta, S., Kotibhaskar, N., Shih, CY. et al. Preserving a qubit during state-destroying operations on an adjacent qubit at a few micrometers distance. Nat Commun 15, 6575 (2024). https://doi.org/10.1038/s41467-024-50864-2

Owner

  • Name: Quantum Information with Trapped Ions
  • Login: QITI
  • Kind: organization
  • Location: Institute for Quantum Computing, Waterloo ON.

JOSS Publication

pySLM2: A full-stack python package for holographic beam shaping
Published
December 11, 2024
Volume 9, Issue 104, Page 6315
Authors
Chung-You Shih ORCID
Institute for Quantum Computing and Department of Physics and Astronomy, University of Waterloo, 200 University Ave. West, Waterloo, Ontario N2L 3G1, Canada
Jingwen Zhu ORCID
Institute for Quantum Computing and Department of Physics and Astronomy, University of Waterloo, 200 University Ave. West, Waterloo, Ontario N2L 3G1, Canada
Rajibul Islam ORCID
Institute for Quantum Computing and Department of Physics and Astronomy, University of Waterloo, 200 University Ave. West, Waterloo, Ontario N2L 3G1, Canada
Editor
Rohit Goswami ORCID
Tags
Python optics trapped ions physics quantum information

GitHub Events

Total
  • Create event: 1
  • Release event: 1
  • Issues event: 1
  • Watch event: 1
  • Issue comment event: 1
  • Push event: 17
  • Pull request event: 2
  • Fork event: 1
Last Year
  • Create event: 1
  • Release event: 1
  • Issues event: 1
  • Watch event: 1
  • Issue comment event: 1
  • Push event: 17
  • Pull request event: 2
  • Fork event: 1

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 259
  • Total Committers: 5
  • Avg Commits per committer: 51.8
  • Development Distribution Score (DDS): 0.247
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Gilbert Shih l****0@g****m 195
MJZ0001 8****a 54
silsouvik 1****k 7
iqcqiti 3****i 2
gilbert -****l 1

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 11
  • Total pull requests: 19
  • Average time to close issues: 4 months
  • Average time to close pull requests: about 2 months
  • Total issue authors: 4
  • Total pull request authors: 4
  • Average comments per issue: 3.0
  • Average comments per pull request: 0.89
  • Merged pull requests: 18
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 4 days
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • brandondube (4)
  • wavefrontshaping (3)
  • ldes89150 (1)
  • sidihamady (1)
Pull Request Authors
  • marvelousmonicaaa (14)
  • ldes89150 (11)
  • HaoZeke (2)
  • iqcqiti (1)
Top Labels
Issue Labels
JOSS (7)
Pull Request Labels

Dependencies

.github/workflows/pytest.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/sphinx.yml actions
  • JamesIves/github-pages-deploy-action 4.1.1 composite
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
pyproject.toml pypi
  • matplotlib > 3
  • numpy > 1
  • scipy >1
  • tensorflow >2
docs/requirements.txt pypi
  • furo *
  • m2r2 *
  • matplotlib *
  • sphinx *
  • sphinx-math-dollar *
  • sphinx_pyproject *