[Bug]: loss is logged after 1 step, and logging (all) is off by 1 step
Is there an existing issue for this?
- [X] I have searched the existing issues and checked the recent builds/commits
What happened?
- Logging is off by 1 step, for the loss CSV, model, and previews
I put a counter which increments after optimizer.step(). I set the training to log every 10 steps, but it does so after 11.

This happened because step is defined by i (+ ititial_steps). i indicates the current step and is 0-indexed. It doesn't indicate the count of steps done. But the logging is done with step % save_hypernetwork_every == 0. So when it logs at step=10, it has actually done 11 steps (0-10).
- Loss logging is done after 1 step.
Loss log in CSV always starts with steps being 1. This happened because it uses step % training_write_csv_every, while step is 0-indexed as previously mentioned. Then it logs with step+1. So every next log is off by 1 step. It didn't check if step > 0 either.
Steps to reproduce the problem
- Set a value (10 here) for csv log in settings
- Set a value (10 here) for model and preview logs
- Train a hypernetwork or textual embedding
What should have happened?
Logging should be done every n steps as set by user.
Commit where the problem happens
737eb28
What platforms do you use to access UI ?
Other/Cloud
What browsers do you use to access the UI ?
Google Chrome
Command Line Arguments
--autolaunch --ckpt {workspace3}/novelai/final_pruned.ckpt --deepdanbooru --disable-safe-unpickle --no-half-vae
Additional information, context and logs
I'll try