Skip to content

Use colors to signal bad sampling

Vicentini Filippo requested to merge pv/colors into master

Created by: PhilipVinc

This was a little weekend's experimentation.

I don't have the time to finish this now but would love some feedback on it...

The idea is to prevent users to completely ignore when sampling is going bad. We currently have 2 metrics: variational_state.sampler_state.acceptance (which is displayed in the repr of variational state) and R_hat of the energy.

I tried using rich to interpolate between green (R_hat==1) and red ((1-R_hat)>>0). Similar coloring is used for sampler_state.acceptance. The color curve is a sigmoid, and was just chosen pretty much arbitrarily. I chose rich because it's the only python package that supports arbitrary colors (and not only 16 colors) that i could find. This works in python repl and in jupyter notebooks.

Interestingly, rich also has advanced support for progress bars with crazy displays so we could use it to also display additional data during training. In this PR there is an experimental progress bar with rich.

You can see the result here (the progress bar normally displays correctly and not on a new line, but the recorder does not like progress bars..) asciicast

Ideally i'd like an opinion on colors. On what curve to use for R_hat/acceptance (when should the value turn redd-ish) and what stuff we could add to the progress bar diplay. And if you like that or not. And what can we do for color-blind people.

Also, this should be tested with MPI and slurm, as i don't know if they will work nicely togethre (i think they should... but to be tested).

Merge request reports