Summary
Seven uses of the deprecated torch.cuda.amp.autocast in the core flagai/ package (not examples):
- flagai/model/predictor/predictor.py:21 — import, used at :459 (
with autocast():) — this is the public Predictor API
- flagai/model/mm/AltDiffusion.py:17
- flagai/model/mm/AltDiffusionM18.py:17,19
- flagai/model/mm/Unets/Unet.py:19
- flagai/model/mm/modules/diffusionmodules/openaimodel.py:10
- flagai/model/mm/modules/diffusionmodules/util.py:136 (
torch.cuda.amp.autocast(**ctx.gpu_autocast_kwargs))
torch.cuda.amp.autocast has been deprecated since torch 2.4 (and GradScaler since 2.3), scheduled for removal. On torch 2.4+ every call to these code paths (any Predictor-based inference, AltDiffusion inference/training) emits a FutureWarning; after removal it raises AttributeError/ModuleNotFoundError at import.
How to reproduce
pip install torch>=2.4
python -c "
import warnings; warnings.simplefilter('error', FutureWarning)
from torch.cuda.amp import autocast
"
FutureWarning: torch.cuda.amp.autocast is deprecated. Please use torch.amp.autocast('cuda', ...)
(Verified on torch 2.11; from torch.cuda.amp import autocast itself warns.)
Request
Migrate the seven core sites to torch.amp.autocast:
-from torch.cuda.amp import autocast as autocast
+from torch.amp import autocast
and for the kwargs form at util.py:136:
- torch.cuda.amp.autocast(**ctx.gpu_autocast_kwargs):
+ torch.amp.autocast("cuda", **ctx.gpu_autocast_kwargs):
torch.amp.autocast("cuda") is available since torch 2.0; requirements.txt declares no torch floor, so no compatibility concern. Note: the same deprecation also applies to the vendored examples/ca-lora/src/section-4.1/opendelta/ copy, but that is third-party embedded code and best fixed upstream.
References
Summary
Seven uses of the deprecated
torch.cuda.amp.autocastin the coreflagai/package (not examples):with autocast():) — this is the publicPredictorAPItorch.cuda.amp.autocast(**ctx.gpu_autocast_kwargs))torch.cuda.amp.autocasthas been deprecated since torch 2.4 (andGradScalersince 2.3), scheduled for removal. On torch 2.4+ every call to these code paths (anyPredictor-based inference, AltDiffusion inference/training) emits aFutureWarning; after removal it raisesAttributeError/ModuleNotFoundErrorat import.How to reproduce
(Verified on torch 2.11;
from torch.cuda.amp import autocastitself warns.)Request
Migrate the seven core sites to
torch.amp.autocast:and for the kwargs form at
util.py:136:torch.amp.autocast("cuda")is available since torch 2.0; requirements.txt declares no torch floor, so no compatibility concern. Note: the same deprecation also applies to the vendoredexamples/ca-lora/src/section-4.1/opendelta/copy, but that is third-party embedded code and best fixed upstream.References
torch.cuda.amp.autocastdeprecated since 2.4;torch.ampis the replacement namespace.