Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4432
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 4 Unrelated FailuresAs of commit bbcdfdc with merge base 66dc3fc ( NEW FAILURE - The following job has failed:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
theap06
force-pushed
the
transformer-cache-fixes
branch
from
September 18, 2026 21:00
7b672c5 to
a3206a2
Compare
theap06
force-pushed
the
transformer-cache-fixes
branch
from
September 18, 2026 22:59
a3206a2 to
600f369
Compare
theap06
marked this pull request as draft
September 18, 2026 23:50
Collector.update_policy_weights_ only notified the policy from _maybe_fallback_update, which the legacy weight_updater path bypasses; a compiled TransformerModule skips the parameter-version fallback and kept a stale cache after a VanillaWeightUpdater sync. Collector.load_state_dict had the same hole. The notification now happens once in update_policy_weights_ after whichever path applied the weights, and after a checkpoint restore. A first cached step under torch.inference_mode() allocated inference tensors that later ordinary steps could not update in place, and an episode reset did not recover. The cache and positions are now allocated under torch.inference_mode(False). Dynamo traces that context manager from torch 2.2, so on older torch a compiled step keeps allocating in the caller's mode (implement_for dispatch). CausalTransformer documented new_kv_cache(batch_size, device=None) while the module always passes dtype. The contract now documents dtype and the constructor rejects a backbone whose new_kv_cache does not accept it.
theap06
force-pushed
the
transformer-cache-fixes
branch
from
September 18, 2026 23:56
600f369 to
3481a67
Compare
The autocast helper caught TypeError to support torch<2.4, which dynamo cannot trace; dispatch with implement_for instead. Fullgraph compile of a TensorDictModule needs a recent dynamo (tensordict's dispatch is not traceable on torch 2.1), so the compile tests are skipped below torch 2.5. These failures predate this PR: pytorch#4193 never ran the olddeps suite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #4193, addressing the post-merge review there.
Cache invalidation after weight updates (P1)
Collector.update_policy_weights_only notified the policy from_maybe_fallback_update, which the legacyweight_updaterpath bypasses. A compiledTransformerModuleskips the parameter-version fallback, so after aVanillaWeightUpdatersync it kept attending to keys and values computed with the previous weights (an updater built over.datamisses in eager too).Collector.load_state_dicthad the same hole. The notification now happens once inupdate_policy_weights_, after whichever path applied the weights, and after a checkpoint restore. The multiprocess worker path already routes through this method, so it is covered without further changes.Cache allocated under inference mode (P2)
A first cached step under
torch.inference_mode()allocated inference tensors, and the next ordinary step failed inreset_kv_cachewithInplace update to inference tensor outside InferenceMode is not allowed;is_init=Truedid not recover. The cache and position counters are now allocated undertorch.inference_mode(False), so they accept in-place writes in both modes. Dynamo only traces that context manager from torch 2.2, so on older torch a compiled step keeps allocating in the caller's mode (implement_fordispatch); eager is fixed everywhere.Backbone contract (P2)
CausalTransformerdocumentednew_kv_cache(batch_size, device=None)while the module always passesdtype=. The contract now documentsdtype(the autocast dtype, orNoneoutside autocast; a backbone may ignore it) and the constructor rejects a backbone whosenew_kv_cachedoes not accept the keyword, instead of failing on the first cached step.Tests
test_collector_weight_update_restarts_streamsnow covers the default sync, a legacyVanillaWeightUpdaterandload_state_dict, eager and compiled. Against the unfixed code the legacy case fails in both modes and the checkpoint restore fails when compiled.test_inference_mode_step_keeps_cache_usable: an inference-mode step followed by ordinary steps and an episode reset matches a module run entirely in ordinary mode.test_custom_backboneuses an independent minimal backbone and checks thedtypehanded to it outside and under autocast;test_errscovers the constructor rejection.Labelled
ci/olddepsso the torch < 2.2 branch of the allocation runs in CI.Olddeps
With the label on, the olddeps shard showed the transformer compile tests failing on torch 2.1. That predates this PR (#4193 never ran the suite): the autocast helper's
try/except TypeErroris not traceable by dynamo, and fullgraph compile of aTensorDictModuleneeds a newer dynamo than 2.1 (theissubclassin tensordict's dispatch). The second commit dispatches the autocast query withimplement_forand skips the compile tests below torch 2.5, in line with the rest of the suite. The remaining red olddeps and GPU jobs are the same ones failing on main at this PR's base.