Skip to content

Commit 1f58cb4

Browse files
fixes for logger + added some other logging
1 parent d788a3e commit 1f58cb4

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

varipeps/ctmrg/routine.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,8 @@ def calc_ctmrg_env_fwd(
898898
Internal helper function of custom VJP to calculate the values in
899899
the forward sweep.
900900
"""
901+
if logger.isEnabledFor(logging.DEBUG):
902+
logger.debug("Custom VJP: Starting forward CTMRG calculation.")
901903
new_unitcell, last_truncation_eps, norm_smallest_S = calc_ctmrg_env_custom_rule(
902904
peps_tensors, unitcell, _return_truncation_eps=True
903905
)
@@ -952,7 +954,7 @@ def _ctmrg_rev_while_body(carry):
952954
count += 1
953955

954956
if logger.isEnabledFor(logging.DEBUG):
955-
jax.debug.callback(lambda cnt, msr: logger.debug(f"Custom VJP: Step {cnt}, Measure {msr}"), count, measure, ordered=True)
957+
jax.debug.callback(lambda cnt, msr: logger.debug(f"Custom VJP: Step {cnt}: {msr}"), count, measure, ordered=True)
956958
if config.ad_custom_verbose_output:
957959
jax.debug.callback(print_verbose, verbose_data, ordered=True, ad=True)
958960

@@ -1023,6 +1025,8 @@ def calc_ctmrg_env_rev(
10231025
Internal helper function of custom VJP to calculate the gradient in
10241026
the backward sweep.
10251027
"""
1028+
if logger.isEnabledFor(logging.DEBUG):
1029+
logger.debug("Custom VJP: Starting reverse CTMRG calculation.")
10261030
unitcell_bar, _ = input_bar
10271031
peps_tensors, new_unitcell, input_unitcell, last_truncation_eps = res
10281032

varipeps/optimization/optimizer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,12 @@ def autosave_function(
204204
auxiliary_data: Optional[Dict[str, Any]] = None,
205205
) -> None:
206206
if counter is not None:
207+
logger.info(f"💾 Autosaving to {str(filename)}.{counter}")
207208
unitcell.save_to_file(
208209
f"{str(filename)}.{counter}", auxiliary_data=auxiliary_data
209210
)
210211
else:
212+
logger.info(f"💾 Autosaving to {str(filename)}")
211213
unitcell.save_to_file(filename, auxiliary_data=auxiliary_data)
212214

213215

varipeps/utils/logging_config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ def init_logging(cfg: Any | None = None) -> None:
3434
root.setLevel(_to_py_log_level(getattr(cfg, "log_level_global", logging.INFO)))
3535
root.propagate = False
3636

37+
# fmt = logging.Formatter(
38+
# fmt="%(asctime)s %(levelname)s %(name)s: %(message)s",
39+
# datefmt="%H:%M:%S",
40+
# )
41+
3742
fmt = logging.Formatter(
38-
fmt="%(asctime)s %(levelname)s %(name)s: %(message)s",
43+
fmt="%(asctime)s %(levelname)s %(message)s",
3944
datefmt="%H:%M:%S",
4045
)
4146

0 commit comments

Comments
 (0)