Scoring turns every exception into a failed evaluation (#388's catch-all), so a configuration error, a data error or a bug in a postprocess script ends a fit with exit 0 and a random draw as its best fit

Đang mở
#995 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Start with Job.run_simulation in pybnf/algorithms/core.py (around lines 390-414) and score_result in pybnf/algorithms/base.py (around lines 936-953), where the catch-all turns exceptions into FailedSimulation or inf. Reproduce with the parabola demo and a postprocess script containing a typo, and confirm that the run currently exits 0. Done means that PybnfError, AttributeError, TypeError, KeyError, NameError and postprocess-script exceptions end the run with a non-zero exit, both scoring paths behave the same, and tests cover an error that fails every evaluation.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Scoring a parameter set catches every exception and turns it into a failed evaluation, on both scoring paths:

  • Workers: Job.run_simulation (pybnf/algorithms/core.py:390-414). An exception while normalizing or scoring becomes a FailedSimulation. An exception in the postprocess script becomes res.score = inf.
  • Master (local_objective_eval = 1): score_result (pybnf/algorithms/base.py:936-953). Both cases become res.score = inf.

The comments cite #388. That issue was a crash ('tuple' object has no attribute 'score') when an evaluation failed. The catch-all that fixed it does not tell a simulation that failed at one parameter set from an error that will fail at every parameter set:

  • a configuration or data error (PybnfError);
  • a bug in PyBNF (AttributeError, TypeError, KeyError);
  • a bug in the user's postprocessing script.

Each of those is penalized one parameter set at a time. The run then ends in one of two ways. It may stop after 100 failures with "Your simulations are failing to run", which points at the simulator, although no simulation failed. Or, under that count, it prints "Fitting complete" and exits 0, and sorted_params_final.txt lists random draws, each with objective inf, the first one as the best fit.

AGENTS.md rules this out: "A configuration or data error is not a simulation failure. ... Let it end the run. Only a genuine simulation failure, such as an integrator that cannot proceed, is scored as a failed simulation." Known instances that reach this path:

  • #961: a noise formula naming a fixed model parameter raises a PybnfError on every evaluation.
  • #990 item 3: normalization = scale under neg_bin raised AttributeError on every evaluation. #994 refuses that at load, but the catch-all stays.
  • Any exception from a postprocess script (reproduction below).

Failure scenario

The demo parabola fit with a postprocess script containing a typo (simdata.dta for simdata.data):

  • All 8 evaluations raise AttributeError: 'Data' object has no attribute 'dta'.
  • The console prints the traceback and "User-defined post-processing script failed" 8 times, then "Stop criterion satisfied with objective function value of inf" and "Fitting complete".
  • The exit code is 0, and out/Results/sorted_params_final.txt lists four random draws, each with objective inf.

Expected: the run stops at the first evaluation with the script's error and a non-zero exit code.

Reproduction

PyBNF main (f5ff92bf), from a folder with examples/demo/parabola.bngl and examples/demo/par1.exp copied in.

pp.py:

def postprocess(simdata):
    simdata.dta[:, 1] *= 1.0   # typo: Data has .data, not .dta
    return simdata

job.conf:

output_dir = out
model = parabola.bngl : par1.exp
fit_type = de
objfunc = chi_sq
uniform_var = v1__FREE 0 10
uniform_var = v2__FREE 0 10
uniform_var = v3__FREE 0 10
population_size = 4
max_iterations = 2
postprocess = pp.py par1
verbosity = 1

pybnf -c job.conf -o; echo exit=$?:

      8 User-defined post-processing script failed
      8 AttributeError: 'Data' object has no attribute 'dta'. Did you mean: 'data'?
      1 Stop criterion satisfied with objective function value of inf
      1 Fitting complete
exit=0

(These are the console lines, counted with sort | uniq -c.)

Possible fix

  • Let anything that is not a recognized per-parameter-set numerical failure propagate and end the run: a PybnfError, an AttributeError / TypeError / KeyError / NameError, and any exception from a postprocess script.
  • Keep the penalty only for the failures that really depend on the parameter set. NaN and Inf predictions already have their own path (unusable_score), and a simulator failure is already a FailedSimulation before scoring starts.
  • Make both scoring paths behave the same, and test each with an error that fails every evaluation.
Ngôn ngữ chính
Python
Star
25
Fork
25
Merge trung bình
4 giờ 5 phút
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của lanl/PyBNF

Tất cả issue của lanl/PyBNF

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.