dream and p_dream never check max_iterations against burn_in (default 10000), so a short run reports "Fitting complete" with no samples, histograms or credible intervals, while mh, pt and am refuse the same conf
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 82/100
Direzione di ricerca
Inizia in pybnf/algorithms/samplers/dream.py, in DreamAlgorithm.start_run, quindi confronta i controlli esistenti in basic_mcmc.py e adaptive_mcmc.py. Riproduci la configurazione di esecuzione breve dell’issue per dream e p_dream e verifica che i valori non validi di max_iterations e burn_in vengano rifiutati prima del campionamento, invece di completare con un output vuoto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The fix for #356 (reported by a user in #344) is incomplete. The max_iterations <= burn_in check it added is only in BasicBayesMCMCAlgorithm.start_run (pybnf/algorithms/samplers/basic_mcmc.py:118), which covers mh and pt. am has its own check (pybnf/algorithms/samplers/adaptive_mcmc.py:154). DreamAlgorithm inherits directly from BayesianAlgorithm (pybnf/algorithms/samplers/dream.py:97). Its start_run (dream.py:250) calls only BayesianAlgorithm.start_run, which does not check this, and PDreamAlgorithm (pybnf/algorithms/samplers/pdream.py:32) inherits it unchanged.
Every dream sampling site requires iteration > burn_in (dream.py:520, 670, 730, 845). So when max_iterations <= burn_in, no draw reaches samples.txt. This includes the case where burn_in is left at its default of 10000 (pybnf/algorithms/samplers/base.py:145). update_histograms then writes 'No samples collected — skipping histogram generation' to the log file only and returns (base.py:575-577), so no histograms or credible-interval files are written. The run exits 0 and prints R-hat/ESS lines followed by "Fitting complete". Nothing on the console says that sampling never started.
No number in the output is wrong. The best fit and sorted_params_final.txt are correct. The R-hat/ESS window includes draws from before burn_in, but that is documented (diagnostics_every in docs/config_keys.rst). The defect is that the posterior output is missing while the run reports success.
This has a side effect: cr_adapt_end = burn_in // 2 (dream.py:119) and p_dream's default precondition_adapt = burn_in // 2 (dream.py:248) both come out to 5000. In such a run, CR adaptation never freezes and p_dream never switches to its whitened proposal. In the reproduction below, p_dream's console output is byte-identical to dream's.
Failure scenario
A user runs job_type = dream or p_dream with max_iterations = 400 and no burn_in line. Burn-in is therefore 10000. All 400 iterations run, and the console shows convergence diagnostics and "Fitting complete". But Results/samples.txt contains only its header, Results/Histograms/ is empty, and there are no credible68/credible95 files. With job_type = mh, the same conf is refused before any simulation.
Reproduction
This uses the tutorial model and data in examples/tutorial/32_prior_gallery/ (bateman_chain.bngl, bateman_chain.exp). Put this dream.conf in the same directory:
edition = 2
model: bateman_chain.bngl
bngl_backend = bngsim
output_dir = out_dream
job_type = dream
noise_model = normal, sigma = read_exp_file _SD
experiment: timecourse, data: bateman_chain.exp
uniform_var = k1 0.05 3.0
uniform_var = k2 0.02 2.0
population_size = 4
max_iterations = 400
sample_every = 2
parallel_count = 2
random_seed = 1234
Run pybnf -c dream.conf (PyBNF v1.8.1).
Observed with job_type = dream:
- Exit code 0. The console prints R-hat/ESS lines every 10 iterations. Its last lines are
Max R-hat: 1.5542 (4 chains)/Min bulk ESS: 8.5 Min tail ESS: 5.9/Stop criterion satisfied .../Information criteria (best fit): .../Fitting complete. No console line mentions samples or burn-in. wc -l out_dream/Results/samples.txtgives1(header only).Results/Histograms/is empty, andResults/has no credible-interval files.- The only notice is in
bnf_*.log: numpy'sgenfromtxt: Empty input filewarning, thenNo samples collected — skipping histogram generation.
Observed with job_type = p_dream (and output_dir changed): the result is the same. Exit code 0, a header-only samples.txt, no histograms and no credible files. The console output is identical to dream's.
Expected, which is what job_type = mh does with the same conf: exit code 1 before any simulation. After mh's deprecation notice, it prints
Error: max_iterations (400) must be greater than burn_in (10000), otherwise no samples will be collected.
Reachability
Any dream or p_dream conf with max_iterations <= burn_in hits this. That includes every conf that omits burn_in and sets max_iterations to 10000 or less. None of the existing guards catches it:
- the #356 check at
basic_mcmc.py:118runs only formh/pt; - the check at
adaptive_mcmc.py:154runs only foram; - nothing in the config or parser layer compares
burn_inwithmax_iterations(it only parses the key and supplies its default,base.py:145); - dream's own
kalman_burnin_fraccheck (dream.py:198) validates only that fraction.
The obvious fix is to raise the same PybnfError from DreamAlgorithm.start_run.
Where
pybnf/algorithms/samplers/dream.py:250:start_run, nomax_iterations/burn_incheckpybnf/algorithms/samplers/dream.py:520,670,730,845: sampling requiresiteration > burn_inpybnf/algorithms/samplers/dream.py:119,248:cr_adapt_endandprecondition_adaptboth default toburn_in // 2pybnf/algorithms/samplers/pdream.py:32: inherits dream'sstart_runpybnf/algorithms/samplers/basic_mcmc.py:118: the #356 check (mh/pt only)pybnf/algorithms/samplers/adaptive_mcmc.py:154: am's equivalent checkpybnf/algorithms/samplers/base.py:145:burn_indefault of 10000pybnf/algorithms/samplers/base.py:575-577: the log-only 'No samples collected' warning
Related: #356, #862, #860.
Found in a whole-codebase audit for silently wrong results (2026-09-23); the reproduction above was re-run independently of the original finding.
- Lingua principale
- Python
- Stelle
- 25
- Fork
- 25
- Merge medio
- 10h 54m
- PR unite (30g)
- 25
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di lanl/PyBNF
-
bug silent-incorrectness
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
I maintainer di solito rispondono entro 1 giorno
-
bug silent-incorrectness
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
bug silent-incorrectness
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
google-agentic-commerce/AP2#388 ·
-
area:codegen backend:cuda backend:hip bug direction:input
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
CrossGL/crosstl#3061 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
rlaope/oh-my-hermes#2304 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
mochan-tk/agentic-dev-kit-for-codex#64 ·
I maintainer di solito rispondono entro 1 giorno
-
Windows ARM memory-leakApertabug docs performance
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 3 giorni