[AUTO-MERGE] Handle None values in _inner_loop tensor conversion#689
[AUTO-MERGE] Handle None values in _inner_loop tensor conversion#689
Conversation
- Modified _inner_loop to check for None before converting to tensors - Added comprehensive tests for None handling in tuples, single values, and edge cases - All existing tests pass
mtauraso
left a comment
There was a problem hiding this comment.
This seems good to merge.
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash in Hyrax’s PyTorch Ignite integration when prepare_inputs returns None values (e.g., missing labels in supervised workflows) by skipping tensor conversion for None and adds regression tests to cover the new behavior.
Changes:
- Update
_inner_loopto avoid callingtorch.from_numpy()onNonevalues (both for tuple batches and single batches). - Add unit tests covering tuple-with-
None,Nonebatch, and standard conversion behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/hyrax/pytorch_ignite.py |
Adds None-aware tensor conversion logic in _inner_loop to prevent torch.from_numpy(None) crashes. |
tests/hyrax/test_pytorch_ignite.py |
Adds targeted tests validating _inner_loop behavior with None inputs and ensuring existing conversion paths still work. |
drewoldag
left a comment
There was a problem hiding this comment.
This appears correct to me. It adheres to assumption that what is returned from prepare_inputs is a tuple or a bare array, and seems to handle those cases just fine.
The tests seem to cover the various permutations.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #689 +/- ##
==========================================
+ Coverage 64.15% 64.17% +0.02%
==========================================
Files 61 61
Lines 5989 5990 +1
==========================================
+ Hits 3842 3844 +2
+ Misses 2147 2146 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Click here to view all benchmarks. |
Change Description
_inner_loopcrashes whenprepare_inputsreturnsNonevalues, which occurs in supervised models with missing labels. The function unconditionally callstorch.from_numpy()on all values, includingNone.Solution Description
Added None checks before tensor conversion in
_inner_loop:Added test coverage for tuple with None element, None batch, and regression cases.
Code Quality
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
www.cs.toronto.edu/usr/bin/python /usr/bin/python -m ipykernel_launcher -f /tmp/tmpu0iebvur.json --HistoryManager.hist_file=:memory: --from without_precedin--columns=500 --to rst --columns=500 pandoc --eo�� lf --from ve_divs+raw_html--columns=500 --to rst --columns=500 pandoc(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
prepare_datareturns aNone, pytorch_ignite will error #688💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.