fix(callbacks): wrap visualisation forwards in the precision plugin's autocast context - #114
Conversation
0630fb4 to
67a60f5
Compare
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughChangesVisualization precision handling
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No merge-blocking visualization precision risk was identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Run all three visualization forwards in the Lightning precision context and convert predictions to float32 for NumPy rendering. Adapted from the original fix proposed by David W. Romero in PR #114. Signed-off-by: dafidofff <davidwessels15@gmail.com>
Signed-off-by: dafidofff <davidwessels15@gmail.com>
67a60f5 to
aedecfa
Compare
|
🤖 Completed: Generate docstrings for PR #114 — View commit |
…n visualization docstrings
Summary
Visualization callbacks invoke the model outside Lightning's training/validation step precision context. In mixed-precision runs, the logged predictions can therefore differ from the predictions used to calculate validation loss.
Wrap the forward in
trainer.precision_plugin.forward_context()in the sequence, image and volume visualization callbacks, then convert predictions to float32 for NumPy/matplotlib. Standard FP32 precision uses the plugin's no-op context.Rebased onto main at
dcf169ca02bb0aeba5efbf50363fbf4ea123abe1. The production change is limited to three forward sites across two existing files: 12 added lines and 6 removed lines. The refreshed commits are signed off, credit David W. Romero's original fix, and keep regression tests in a separate commit.Validation
python -m pytest tests/test_visualization_precision.py tests/test_image_grid_callback.py -q -o addopts=''— 22 passed.Summary by CodeRabbit
Bug Fixes
Tests