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 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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分
マージ済み PR(30日)
10

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

lanl/PyBNF のほかの issue

lanl/PyBNF の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。