tqdm: disable single-batch h_bar/vjp bars, equal intervals (token-efficient-logging)

Single-batch persona lists made instant 1/1 bars that print a completion
line regardless of interval; disable those. Both intervals 120 for the
multi-batch fit/pullback case.

Co-Authored-By: Claudypoo <288921227+claudypoo@users.noreply.github.com>
This commit is contained in:
wassname
2026-07-12 10:38:56 +08:00
co-authored by Claudypoo
parent da680901eb
commit e90de299f4
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -124,8 +124,10 @@ def _h_bar_final(model, tok, prompts: list[str], *, batch_size: int = 8,
lm = from_hf(model, tok) # layout detection only
target_layer = lm.n_layers - 1
acc, n = None, 0
# single-batch persona lists (<= batch_size) make a useless 1/1 bar that still prints
# a completion line; disable those. Both intervals equal for the multi-batch case.
for i in tqdm(range(0, len(prompts), batch_size), desc=f"h_bar {label}",
mininterval=30, maxinterval=60):
disable=len(prompts) <= batch_size, mininterval=120, maxinterval=120):
batch = prompts[i:i + batch_size]
enc = tok(batch, return_tensors="pt", padding=True, truncation=True,
max_length=max_length, padding_side="right").to(model.device)
+1 -1
View File
@@ -57,7 +57,7 @@ def pullback_vjp(model, tok, prompts: list[str], layers, cotangent: Tensor, *,
G = {l: torch.zeros(d, dtype=torch.float32, device=model.device) for l in layers}
count = 0
for i in tqdm(range(0, len(prompts), batch_size), desc="pullback_vjp",
mininterval=30, maxinterval=60):
disable=len(prompts) <= batch_size, mininterval=120, maxinterval=120):
batch = prompts[i:i + batch_size]
enc = tok(batch, return_tensors="pt", padding=True, truncation=True,
max_length=max_length, padding_side="right").to(model.device)