starting_params is not checked at load: an out-of-box value leaves am stuck outside the box for the whole run, extra values are dropped, too few crash with IndexError

未关闭
#1,013 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend, testing

调研方向

Start with Configuration._check_starting_params in pybnf/config.py and compare its checks with the existing start_point validation. Read the sampler initialization in pybnf/algorithms/samplers/base.py to understand how values are assigned, then find or add tests for parameter count, bounds, and the continue_run combination. Done means each invalid configuration is rejected at load with an error naming the cause.

由索引模型根据 Issue 内容生成。

描述

bug silent-incorrectness

At load, starting_params is checked for only one thing: whether the job_type reads it (Configuration._check_starting_params in pybnf/config.py, added for #559). Its values are never checked, neither their count nor their bounds. The sampler base then copies them into every chain by position (pybnf/algorithms/samplers/base.py, lines 375–378). Three easy mistakes give three different wrong outcomes, and only one of them stops the run.

Every run below uses an analytical objective (objective = expression) with parameters declared kcat [0.5, 50], Km [1, 500], alpha [0.1, 20], and population_size = 2.

1. A value outside its box is accepted, and am then reports a posterior that sits outside the box

job_type = am, max_iterations = 300, starting_params = 69.99 70 3 (kcat is above its upper bound of 50):

exit status 0, no warning
Results/start_point.txt            kcat  69.99  sampled  0.5  50
Results/samples.txt                590 rows; every one is (kcat 69.99, Km 70, alpha 3), Ln_probability -inf
Results/credible68.0_final.txt     kcat  69.99  69.99

Neither chain ever moves. am rejects any proposal that leaves the box (_propose, pybnf/algorithms/samplers/adaptive_mcmc.py; #709). From a start about 20 units outside, essentially every proposal does leave it, so each iteration records the start point again. The run finishes normally, and its histograms and credible intervals describe a single point outside the parameter's own support.

With job_type = mh (step_size = 0.2), the same line is reflected back inside instead. The chain wanders from a point the user did not choose (credible68.0_final.txt: kcat 29.28 to 29.64 after 30 iterations).

start_point refuses the same value at load. Its docs say "A value outside the parameter's declared bounds is refused, not moved." starting_params gets no such check.

The likely way to get here is the one docs/config_keys.rst warns about: pasting a row from samples.txt or sorted_params*.txt. Those files sort their columns by name, while starting_params follows declaration order.

2. Extra values are silently dropped

job_type = am, starting_params = 7 70 3 99 (four values for three parameters):

exit status 0, no warning
Results/start_point.txt   kcat 7   Km 70   alpha 3

The 99 is ignored. A plausible cause is a parameter that was deleted from the conf while its value stayed in the line. Then every value after the deleted parameter's position lands on the wrong parameter.

3. Too few values crash with an error that does not name the cause

job_type = am, starting_params = 7 70:

Sorry, an unknown error occurred: IndexError: list index out of range

4. Also worth deciding: continue_run = 1 together with starting_params

The docs say continue_run = 1 "overrides starting_params entirely", and it does: every chain starts from adaptive_files/MLE_params.txt. But a config that sets both is accepted without a word, so the user gets no sign that the line they wrote did nothing. AGENTS.md asks that a combination like this be refused at load.

Expected

_check_starting_params should refuse at load, with an error that names the cause:

  • a count that differs from the number of free parameters, listing the parameters in declaration order;
  • a value outside its declared box, naming the parameter, its value and its bounds (the same check start_point already gets);
  • probably continue_run = 1 together with starting_params.

Each refusal needs a test.

A separate question is whether am should ever record a sample whose Ln_probability is -inf. A chain that cannot leave its start fails silently however it got there.

Found during the review of #984.

主要语言
Python
星标
25
派生
25
平均合并
4 小时 5 分钟
30 天内合并 PR
10

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

lanl/PyBNF 的其他 Issue

查看 lanl/PyBNF 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。