Search Blogs

Tuesday, March 19, 2024

Stochastic Bits

We are all familiar with a bit, a 0 or 1, a false or true, that describes a discrete binary outcome. We can also think of a probabilistic bit, representing a continuous probability between 0 and 1. We then have quantum bits, which represents the superposition state $\vert\Psi\rangle = a\vert 0 \rangle + b\vert1\rangle$, with the probability of measuring a $\vert 0 \rangle$ or $\vert 1 \rangle$ given by the probability amplitude squared. But what if we have the scenario where randomness is introduced to the information state?

s-bit

A stochastic bit, s-bit, which is a bit which experiences random dynamics (i.e., stochastic) between two states:

$$ \begin{equation} s(t) = \begin{cases} 0 & p(t) \\ 1 & 1-p(t) \end{cases} \label{eq:sbit_discrete} \end{equation} $$

This says that the state at any given time of an s-bit, $s(t)$, is 0 or 1 given the probability $p(t)$. The signal, $s(t)$, could look something like:

Stochastic bit.

If we had a continuous scenario where we deal with nats1, we can write this as:

$$ \begin{equation} s(t) = \int_{-\infty}^{\infty} x \cdot p(x,t) \, dx \label{eq:sbit_cont} \end{equation} $$

with $x$ being a random variable with probability density $p(x,t)$ corresponding to the signal state and $t$ the stochastic dynamic time variable. We can get something like:

Stochastic unit.

This is emblematic of random-walk or Brownian motion, that is, a drift in the signal due to random motion (i.e. noise). Typically when it includes time domain processes, it is usually called the continuous-time stochastic process or Wiener process.

Why use s-bit

As Patrick J. Coles puts it in his good overview video [1], some ideas are to think about how stochasticity can be used as a resource in ML and AI. He gives some examples on how random neuron dropout is used to prevent overfitting and sampling for generative AI uses random noise. Moreover, the interesting thing is the shift from discrete to continuous variables, since in ML/AI the weights, features, and probabilities are over continuous values. The idea is to use the stochastic behavior of physical systems to process information. In the video Patrick calls these s-units which seems fitting. All this obviously leads to thermodynamic computing which I'm diving into2.

Footnotes


  1. When dealing with continuous variables we use nats, a natural unit of information, which can be calculated from the Shannon entropy as $H(s) = -\int_{-\infty}^{\infty} s(t) \ln(s(t)) \, dt$ 

  2. See my post on my recent focus on thermodynamic computing

References

[1] Thermodynamic AI and the Fluctuation Frontier | Qiskit Seminar Series with Patrick Coles, Qiskit Quantum Seminar, 2023. URL (accessed March 19, 2024).

[2] P.J. Coles, C. Szczepanski, D. Melanson, K. Donatella, A.J. Martinez, F. Sbahi, Thermodynamic AI and the fluctuation frontier, (2023). arXiv.


Reuse and Attribution

Thursday, March 14, 2024

Shifting focus for a little

Recently my intellectual curiosity has driven me towards the topics of stochastic thermodynamics, analog computing, and probabilistic ML all connected to the the recent pop in thermodynamic computing by start-ups Extropic and Normal Computing. I can't say I know enough to really explain what the value is, other than knowing that these types of computing paradigms are extremely energy efficient and are one of the best prospects for scalable AI. Therefore in light of this, I'm going to pull a little back from my self-learning activities on graph NN (😒) and focus on these topics; I have no idea for how long or how much steam I'll maintain. My future post will probably be on these topics, or I might just keep with posting on new "tools" I'm exploring.

How am I going to achieve some baseline knowledge? Well I already know thermodynamics pretty well, but it's all from an equilibrium perspective with thermodynamic potentials and state variables. What I need is to study a bit more non-equilibrium thermodynamics, which is the focus on the time evolution of the state variables. But in particular to thermodynamic computing is stochastic1 thermodynamics, which is the non-equilibrium dynamics due to random fluctuations that occur on small collection/subset. In other words, the study of random dynamics in microscopic/mesoscopic collections of particles. The reason this is different that just non-equilibrium thermo, at least I think, is that when you deal with small collections of micro/meso-scopic systems, the statistical law of large numbers does not guarantee the same convergence of ensemble averages to thermodynamic values as in macroscopic systems. Meaning that expectation values remain meaningful but must be interpreted with consideration of significant fluctuations around these values. For instance, temperature can still be considered as an average kinetic energy of the ensemble, but with an increased importance of understanding the distribution and fluctuations of these energies.

Futhermore, stochastic thermodynamics distinguishes itself by explicitly accounting for the random, fluctuating dynamics of individual particles or small assemblies of particles. One of the key concepts in stochastic thermodynamics is that the fluctuation theorem, which quantifies the probability of observing fluctuations away from the average behavior in non-equilibrium systems, is dominant. These theorems provide a deep understanding of the irreversibility and the second law of thermodynamics in a statistical sense, showing that while the second law holds on average, there are observable, albeit rare, violations on the microscopic scale due to thermal fluctuations.

In essence, stochastic thermodynamics provides a comprehensive framework to study the energetics and dynamics of systems where fluctuations cannot be ignored, making it crucial for understanding processes at the molecular and nanoscale, especially in biological systems and nanotechnology.

Warning

This is what I think it all means! I'll find out if I am wrong or right as I learn more.

So what do I need to do? Well I have the following set of books that I'm going to read through:

  1. L. Peliti, S. Pigolotti, Stochastic Thermodynamics: An Introduction, Princeton University Press, 2021. URL.
  2. Ulmann, Bernd. Analog Computing, Berlin, Boston: De Gruyter Oldenbourg, 2022. DOI
  3. K.P. Murphy, Probabilistic Machine Learning: An introduction, MIT Press, 2022. URL.

I'm going to read 1 and 2 in tandem, and will read 3 over the next 6 months. The goal is to understand stochastic thermodynamics and analog computing thoroughly. Then I'll read through the papers [1-3] on thermodynamic computing. Finally I'll try to connect 3 to 1 and 2.

In the process of this learning, I'm going to write my notes up in a small handbook using the latex format graciously provide by Francois Fleuret[4]. No promises on the quality of the book, only that it will contain my notes on 1 and 2. I'll also write blog post, but these will most likely be renditions of my notes in to book. I'll probably make my notes available on my website if I'm happy with the final result.

Footnotes


  1. The use of the term "stochastic" refers to random fluctuations in non-equilibrium thermodynamic processes at microscale. 

References

[1] T. Conte, et al., Thermodynamic Computing, (2019). https://doi.org/10.48550/arXiv.1911.01968.

[2] P.J. Coles, et al. Thermodynamic AI and Thermodynamic Linear Algebra, in: Machine Learning with New Compute Paradigms, 2023. https://openreview.net/forum?id=6flkWTzK2H.

[3] A.B. Boyd, J.P. Crutchfield, M. Gu, F.C. Binder, Thermodynamic Overfitting and Generalization: Energetic Limits on Predictive Complexity, (2024). https://doi.org/10.48550/arXiv.2402.16995.

[4] FranΓ§ois Fleuret’s git - littlebook.git/tree. https://fleuret.org/git/littlebook (accessed March 13, 2024).


Reuse and Attribution

Thursday, March 7, 2024

A Multiphase Polycrystalline Utility

During graduate school, I had to write several utility scripts to prepare the structures used for simulations. One such script [1] generated polycrystalline samples of SiC using Voronoi tessellation. The script worked, but was brute-force and slow.

Fortunately, after my time in this space, several other fast and feature-full codes/packages continued to grow. Two of them in particular: atomsk and ASE [2-3]. I've recently been writing about ASE in several post; it's a great tool! So is atomsk.

A Refresh

About two year's ago I worked on a script that leveraged these two packages to generate polycrystalline samples in a similar fashion that I had done. I forgot about it and recently stumbled back on it. I decided to refresh it a bit and use Linux AppImage to make it portable for others (just download the AppImage and run in command line, no setup 🀞).

The Bash Script

The refreshed script, called PolyCrysGen.sh, is a bash script and basically contains the workflow to connect atomsk and ASE to generate multiphase polycrystalline LAMMPS data files. Of course one could do this manually using these tools, but the value added by this script is that the logic is in place to make the use syntax very friendly and convenient. All one has to do is type:

chmod +x ./PolyCrysGen.sh ./PolyCrysGen.sh --size "150 150 150" --phases "Fe:6 Mg:2 Cr:2 "

And this will generate a polycrystalline simulation cell with 6 Iron, 2 Magnesium, and 2 Chromium grains using the ground-state crystal structure. It looks like the following LAMMPS data file:

Multiphase Fe-Mg-Cr polycrystal LAMMPS data configuration

The particular logic that is included is to handle the template for the multi-phase polycrystal. This requires randomly generating the node locations for the grains, assigning the grains to each phase (i.e., element/compounds), and then removing and combining grains based on the assignment using the -select prop, -rmatom, and --merge flags in atomsk.

One thing I really appreciate is how fast2 atomsk is at doing this. You can easily do 10's of grains and have millions of atoms in your simulation cell.

Improving portability 🀞

On thing with workflows that leverage pre-built or configured tools is that not every computer (linux specifically) will be the same. Environmental paths and variables could be totally different. Additionally the tools might not be installed/available or the user isn't entirely sure how to compile and configure. For this specific instance both atomsk and ASE are easy to setup, however, I want to try and make this bash script a bit more portable and decided to investigate the use of containers, specifically the AppImage setup.

For the most part I think I was successful, and now anyone with a linux system should be able to download the latest release AppImage, change the permissions to run, and then utilize the scrip without having to setup atomsk or ASE. The only caveat seems to be that the Filesystem in Userspace has to be installed1, 😒.

Remarks

I haven't exhaustively tested every case, for example, with four phases it seems the alphabetic ordering matters, in that should be from a to z. I'm not sure though, as the logic I have seems to be πŸ‘Œ.

The other features I need to eventually add is the ability to place the grain center/nodes in predefined superlattice, like placing the grains in FCC patter with the phases alternating in a desired fashion. I also need to add the ability to generate amorphous grains. This may require actually using some kind of Monte carlo algorithm where I just specify min and max distances between pairs of atoms. In other words, I won't try to minimize the distance based on minimizing the interaction energy.

Feel free to test the utility out and open up an issue or pull request if you see bugs or add new features to the script.

Footnotes


  1. This is kind-of annoying in my opinion. Someone needs to find a way to make it so you can bundle a linux environment, package it, and then deploy for execution on any x86-64 Linux box. Probably exist, but I don't know about it and it would need to be as easy as the AppImage approach. 

  2. I believe this is because it is using OpenMP to speed things up but I'm not entirely sure. If you want you can try to test by setting OMP_NUM_THREADS=1 and then OMP_NUM_THREADS=4 and see what happens. 

References

[1] S. Bringuier, NaivePolyCrys, (2020). https://doi.org/10.5281/ZENODO.3925791.

[2] P. Hirel, Atomsk: A tool for manipulating and converting atomic data files, Computer Physics Communications 197 (2015) 212–219. https://doi.org/10.1016/j.cpc.2015.07.012.

[3] A. Hjorth Larsen, et al., The atomic simulation environment—a Python library for working with atoms, J. Phys.: Condens. Matter 29 (2017) 273002. https://doi.org/10.1088/1361-648X/aa680e.


Reuse and Attribution