fix: reconcile posterior device after mapped load - #1972
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis change fixes stale device state after ChangesDevice reconciliation on posterior load
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
4d27ba5 to
5e7083f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1972 +/- ##
==========================================
- Coverage 88.98% 88.83% -0.15%
==========================================
Files 139 139
Lines 13604 13658 +54
==========================================
+ Hits 12105 12133 +28
- Misses 1499 1525 +26
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
@janfb created new pr sorry for closing that Thanks Jan for the detailed review. I addressed the remaining VI issue by calling |
|
@coderabbitai is it covering all the issue and jan review in #1959 |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '=== PR `#1959` review comments and conversation ==='
gh api --paginate repos/sbi-dev/sbi/pulls/1959/comments \
--jq '.[] | {user: .user.login, path, line, original_line, body, html_url}'
gh api --paginate repos/sbi-dev/sbi/issues/1959/comments \
--jq '.[] | {user: .user.login, body, html_url}'
echo '=== Current PR changed files ==='
gh pr view 1972 --repo sbi-dev/sbi --json files --jq '.files[] | "\(.path) (+\(.additions)/-\(.deletions))"'
echo '=== Source maps ==='
ast-grep outline sbi/inference/posteriors/base_posterior.py --items all --match '__setstate__|to|NeuralPosterior'
ast-grep outline sbi/inference/posteriors/vi_posterior.py --items all --match '__setstate__|to|VIPosterior'
ast-grep outline sbi/utils/torchutils.py --items all --match 'infer_tensor_device'
echo '=== Relevant implementations ==='
rg -n -A75 -B12 'def __setstate__|def infer_tensor_device' \
sbi/inference/posteriors/base_posterior.py \
sbi/inference/posteriors/vi_posterior.py \
sbi/utils/torchutils.py
echo '=== New mapped-load tests ==='
rg -n -A55 -B8 'map_location|infer_tensor_device|reconcile|loaded.*device' \
tests/inference_on_device_test.pyLength of output: 59358
Covered items:
One validation limit remains: I can verify the implementation and test coverage from the PR, but I cannot independently confirm local GPU-marked test execution, full You are interacting with an AI system. |
|
@janfb may I know how you would prefer for easy testing my local venv taking more time your suggestion will be helpful thanks! |
you need to test locally only the specific GPU tests that are affected by your changes, not the entire test suite. I hope this helps. |
|
thanks for the suggestion $ pytest tests/inference_on_device_test.py -k "pickle_map_location" -v |
Summary
Fix stale posterior device state after loading with
torch.load(..., map_location=...).Changes
VIPosteriorrestoration through the base reconciliation and its ownto()method.Closes #1954 Supersedes #1959
Ran them locally on MPS since CI skips gpu-marked tests.