Skip to content

fix: handle empty iter_data_new_exp in auto_prob generation#368

Open
SchrodingersCattt wants to merge 3 commits into
deepmodeling:masterfrom
SchrodingersCattt:fix/auto-prob-empty-iter-data
Open

fix: handle empty iter_data_new_exp in auto_prob generation#368
SchrodingersCattt wants to merge 3 commits into
deepmodeling:masterfrom
SchrodingersCattt:fix/auto-prob-empty-iter-data

Conversation

@SchrodingersCattt

@SchrodingersCattt SchrodingersCattt commented Jul 22, 2026

Copy link
Copy Markdown

Problem

When FP labeling fails on all conformations and continue_on_success_ratio allows the workflow to proceed, iter_data contains directory entries that expand to zero systems.

This causes auto_prob to generate prob_sys_size; 0:2:0.6; 2:2:0.4 (empty range 2:2) which crashes with ValueError: probabilities do not sum to 1.

Fix

Guard with if numb_new > numb_old + fallback to plain prob_sys_size + warning log.

Test

Added test_auto_prob_empty_new_iter_data.

Summary by CodeRabbit

  • Bug Fixes

    • Improved training configuration handling when an iteration adds no new systems.
    • Prevented invalid or empty probability ranges that could cause training failures.
    • Added a warning when no new systems are detected and a safe default is used.
  • Tests

    • Added coverage for training iterations with no newly labeled data.

When FP labeling fails on all conformations and
continue_on_success_ratio allows the workflow to proceed,
iter_data contains directory entries that expand to zero systems.
This caused auto_prob to generate an empty range like
"prob_sys_size; 0:2:0.6; 2:2:0.4" which crashes dp train with
"ValueError: probabilities do not sum to 1".

Fix: guard with `if numb_new > numb_old` before generating
the two-group auto_prob string. When there is no new data,
fall back to plain "prob_sys_size" and log a warning.

Fixes the scenario: extreme systems (e.g., energetic materials
at high temperature) where teacher model cannot label any
conformations from the first exploration iteration.
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Jul 22, 2026
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@SchrodingersCattt, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 39 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 93491908-81fa-4613-932a-f4f1eb914c35

📥 Commits

Reviewing files that changed from the base of the PR and between 6e574ea and 435b9bb.

📒 Files selected for processing (1)
  • tests/op/test_run_dp_train.py
📝 Walkthrough

Walkthrough

RunDPTrain.execute now avoids constructing an empty probability range when an iteration adds no systems, and a unit test covers the fallback behavior using an empty iteration-data directory.

Changes

Auto probability fallback

Layer / File(s) Summary
Probability selection and regression coverage
dpgen2/op/run_dp_train.py, tests/op/test_run_dp_train.py
RunDPTrain.execute uses the ratio-based probability range only when new systems are added, otherwise logs a warning and uses prob_sys_size; the regression test verifies this behavior for empty iteration data.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: handling empty iter_data_new_exp during auto_prob generation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/op/test_run_dp_train.py`:
- Around line 349-355: Update the test around RunDPTrain.execute to exercise the
production fallback rather than recomputing auto_prob locally. Mock run_command,
invoke execute with iter_data=[empty_iter], then inspect the generated training
script and assert its auto_prob value is "prob_sys_size"; remove the duplicate
numb_new/numb_old conditional and assertion based on it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e6873f7-f44c-48b1-a2b0-d1a2d779e58a

📥 Commits

Reviewing files that changed from the base of the PR and between b05af11 and 6e574ea.

📒 Files selected for processing (2)
  • dpgen2/op/run_dp_train.py
  • tests/op/test_run_dp_train.py

Comment thread tests/op/test_run_dp_train.py Outdated
Address review: replace local logic re-computation with an actual
call to RunDPTrain.execute() using mocked run_command, then inspect
the generated training script's auto_prob value.

This ensures the test fails if the production guard is removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant