fix(numeric): support legacy PyTorch autocast fallback - #185
Open
PinkTulips139 wants to merge 2 commits into
Open
fix(numeric): support legacy PyTorch autocast fallback#185PinkTulips139 wants to merge 2 commits into
PinkTulips139 wants to merge 2 commits into
Conversation
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.
Summary
Adds a backward-compatible autocast-disabled context for legacy PyTorch versions that do not provide the top-level
torch.autocastAPI.The issue was observed in the repository's Python 3.8 / PyTorch 1.8 CI environment, where existing Mixture, MoA, and MoT tests failed with
AttributeError: module 'torch' has no attribute 'autocast'.Changes
torch.autocast(device_type=..., enabled=False)path on modern PyTorch.torch.cuda.amp.autocast(enabled=False)for legacy CUDA environments.nullcontext()for legacy CPU, MPS, and unsupported device types.disabled_autocast()rather than patching individual Mixture modules.Scope
This PR does not change:
It only provides a compatibility fallback for the shared numerical helper.
Validation
8 passedintests/test_torch_legacy_compat.py13 passedin the previously affected Mixture test filesgit diff --checkpassedNo GPU is required for the regression tests; the legacy CUDA path is validated with mocks.