[BUG]: bench_sizes.py leaks prefetch threads on early break and crashes on short streams or CPU

Aperta
#379 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@panshularora ci sta già lavorando.

Dal 25/11/2026.

  • #382 di @panshularora — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, pytorch
Ambito
performance

Direzione di ricerca

Start in simple/bench_sizes.py, lines 34-51, where the prefetch loop breaks early and calls torch.cuda functions. Compare with how ovl.py closes its prefetch iterator after #308. Done means the iterator is closed on break, short streams fail with a clear message, and CUDA calls are guarded by ovl.DEV. Pull request #382 is already open against this issue, so check it before starting.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

simple/bench_sizes.py has two bugs when iterating over ovl.prefetch(...) across the 5 model sizes in SIZES:

  1. Leaked prefetch producer threads on early break: for b, _ in ovl.prefetch(a.data, "wikipedia", [0, 0]): breaks out of the loop after a.seconds without closing the prefetch iterator (unlike ovl.py, which was fixed in #308). Because bench_sizes.py loops over 5 progressively larger models in one process, each timed break leaves a live producer thread blocked in q.put() holding queued batch tensors.
  2. Crash on short streams (<= 30 updates): If ovl.prefetch(...) yields 30 or fewer batches, t0 remains None (or n - 30 == 0), so ms = 1000 * (time.time() - t0) / (n - 30) crashes with TypeError: unsupported operand type(s) for -: 'float' and 'NoneType' or ZeroDivisionError.
  3. Unconditional CUDA calls: torch.cuda.synchronize(), torch.cuda.max_memory_allocated(), torch.cuda.empty_cache(), and torch.cuda.reset_peak_memory_stats() are called without checking ovl.DEV == "cuda".

Source

  • simple/bench_sizes.py (lines 34–51)

Expected Behavior

  • Wrap the ovl.prefetch(...) iterator in contextlib.closing(...) so the producer thread is cancelled and joined when the loop breaks or exits.
  • Fail cleanly with a clear error message if fewer than 31 updates are available in the stream.
  • Guard torch.cuda.* calls with ovl.DEV == "cuda".
Lingua principale
Python
Stelle
27
Fork
72
Merge medio
2g 19h
PR unite (30g)
45

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AOSSIE-Org/OpenVerifiableLLM

Tutte le issue di AOSSIE-Org/OpenVerifiableLLM

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.