How do I do probabilistic logging?

I’m currently doing all my logging like this:

{ "loss": loss, "step": step }, commit=should_commit())
# step increments with each batch

def should_commit():
    return random.randint(0, 100) == 0

The goal is to only sync metrics to the server once every 100 or so calls to log. I’m doing this because otherwise my training speed is halved, if I just do the default.

But, I notice this isn’t working. My charts look very odd for some reason.
What is the correct way to only sync all my metrics every so often?

To be clear, I want the end result to be such that all my metrics are on the server for every time-step, however, I want to do the syncing infrequently instead of every time I call wandb.log, because that’s slow.

@vroomerify ,

Our global step must always increase and we will automatically increment it if you don’t specify it or set commit=False in wandb.init. If you want to log metrics against multiple x-axis you can log those axis as separate metrics, I.E.

wandb.log({“loss”: 0.3, “batch”: 1000, “epoch”: 2})

Then you can choose a custom x-axis in the ui to be whatever you’ve logged against your metrics.

Additionally, we allow for Stepwise and Incremental Logging, see here for more details on how to do so.

@vroomerify , since we have not heard back from you we are going to close this request. If you would like to re-open the conversation, please let us know!