In this post I am going to show you that you just need to know a little Numpy to use a LightOn OPU. I will introduce LightOnML, the Python framework to perform fast large-scale random projections with light. By the end, you will have the knowledge needed to take advantage of LightOn OPUs right away when you access LightOn Cloud.
Some years ago, I thought you needed to be some kind of wizard to run computations on graphics cards (GPUs). That was before I discovered Theano (RIP 😢), TensorFlow, Torch (RIP 😢) and PyTorch, and quickly realized using GPUs could be easy.
In the same way, you may think doing Optical Computing is complicated, and you need a degree in Physics to really understand what is going on. Maybe you associate it with Quantum Computing and weird names, like Bloch sphere.
Without further ado, let me show you how it works 👇
The code in Figure 1 shows the essence of LightOnML. What is happening there? We performed y = |Rx|², where x is a 3.000×1.000.000 matrix and R is a 1.000.000×1.000.000 complex Gaussian matrix. The matrix R would be about 8 TB in single precision!
numpyto create our input data, and the
- Create some “dummy” data for demonstration purposes. The input of current LightOn OPUs must be binary and uint8.
- Create an
OPUMapobject that is responsible for talking to the hardware accelerator, and select the output size of the projection
- Perform the optical transformation using the
opu.transformmethod. The output is an array of uint8, with elements in [0, 255].
It all boils down to sending and retrieving
numpy.ndarrays. Actually, that works with
torch.Tensors too! Similarly to running GPU computations without any idea about warps, lanes, registers and threads, it is possible to run computations with LightOn OPUs having no idea about Maxwell’s equations.
Nice! But what is that thing about a binary input? Indeed, the input for an OPU needs to be binary, we provide some fixed and data-adaptive encoders in
lightonml.encoding.models. Alternatively, you can devise your own encoding scheme.
Some other nice features of the library:
OPUMapscikit-learn wrapper can be placed in
Pipelineand it will play just fine with cross-validation tools.
- The low-level code performs an automatic optimization for the output Signal-to-noise-Ratio.
- It is possible to input bit-packed data.
There are other interesting nuggets in the library, but we don’t want to take away all the fun from you, do we?
Sparked your curiosity and want to know more about LightOnML features? Browse the library documentation.
Want to discover real applications of this library and research work by LightOn? Check our blog posts on Reinforcement Learning, Transfer Learning, the Double Descent Curve and more... and their associated lightonai GitHub repositories.
LightOn is a hardware company that develops new optical processors that considerably speed up Machine Learning computation. LightOn’s processors open new horizons in computing and engineering fields that are facing computational limits. Interested in speeding your computations up? Try out our solution on LightOn Cloud! 🌈
Thanks to Victoire Louis for reviewing this blog post.