[BugFix] Fix missing raise, incorrect __torch_function__ return, and off-by-one in RayCollector#3530
Conversation
…r_ids 1. collectors/_runner.py: Add missing `raise` before `RuntimeError(MPS_ERROR)`. The exception was constructed but never raised, silently allowing execution to continue when tensors are on MPS devices. 2. data/tensor_specs.py: Fix `__torch_function__` to return `NotImplemented` instead of `return NotImplementedError(...)`. The previous code returned an exception object as a value rather than following the standard `__torch_function__` protocol. 3. collectors/distributed/ray.py: Fix off-by-one in `_async_iterator` where `collector_index + 1` was passed to `update_policy_weights_()`. `collector_index` is already 0-indexed from `pending_tasks.pop(future)`, so the +1 causes weight updates to target the wrong worker. Fixes pytorch#3000
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3530
Note: Links to docs will display an error until the docs builds have been completed. ❌ 6 New Failures, 5 Pending, 21 Unrelated FailuresAs of commit faa0a24 with merge base ab0a445 ( NEW FAILURES - The following jobs have failed:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @jashshah999! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary
Fixes three independent bugs found during code review:
collectors/_runner.py:RuntimeError(MPS_ERROR)is constructed but never raised, silently allowing execution to continue when tensors are on MPS devices instead of failing with a clear errordata/tensor_specs.py:TensorSpec.__torch_function__returns aNotImplementedError(...)instance instead of theNotImplementedsentinel, violating the__torch_function__protocol and causing downstream confusion since the caller receives an exception object as a valid return valuecollectors/distributed/ray.py:update_policy_weights_()is called withcollector_index + 1, butcollector_indexis already 0-indexed (it comes frompending_tasks.pop(future)), so the +1 causes weight updates to target the wrong workerChanges
All three fixes are minimal:
raisebeforeRuntimeError(MPS_ERROR)in_runner.py:490return NotImplementedError(...)withreturn NotImplementedintensor_specs.py:1232+ 1fromcollector_index + 1inray.py:1013Fixes #3000