You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
apex still references the deprecated torch.cuda.amp APIs in 5 files, 10 references at HEAD (9e3568a6). PR #1813 ("deprecate uses of torch.cuda.amp", merged 2024-06-29) migrated 16 files, and the open PR #1867 only covers cudnn_gbn/batch_norm.py (stale since 2024-12, currently not mergeable). The remaining sites below are still unaddressed:
File
Line
Usage
apex/_autocast_utils.py
26
torch.cuda.amp.autocast_mode._cast(...) — private internal API, the core AMP interop path: _cast_if_autocast_enabled is imported by 5 production modules (apex/fused_dense/fused_dense.py:5, apex/mlp/mlp.py:8, apex/normalization/fused_layer_norm.py:10, apex/contrib/layer_norm/layer_norm.py:5)
apex/contrib/cudnn_gbn/batch_norm.py
5
from torch.cuda.amp import custom_bwd, custom_fwd (covered by stale PR #1867)
apex/contrib/optimizers/distributed_fused_adam.py
2343, 2398
torch.cuda.amp.grad_scaler.OptState — private module symbol
torch.cuda.amp.autocast_mode.autocast(...) — private internal API
Deprecation status — torch.cuda.amp.autocast / custom_fwd / custom_bwd are deprecated since torch 2.4, GradScaler since torch 2.3. Verified on torch 2.11 that even the private autocast_mode._cast is deprecated-wrapped and emits the FutureWarning:
FutureWarning: `torch.cuda.amp.autocast_mode._cast(value, dtype)` is deprecated. Please use `torch.amp.au...
torch.cuda.amp.grad_scaler.OptState is a private module symbol with no warning at all — it would break silently when the module is removed. The deprecation notice says these APIs "will be removed in a future release".
No version guard, floor-only constraints
None of the sites has any guard: no LooseVersion, no hasattr(torch.amp, ...), no try/except fallback around them.
setup.py:142-148 only enforces a floor (TORCH_MAJOR==0 and TORCH_MINOR<4 → error; anything ≥0.4 passes), and requirements.txt:8torch>=2.6.0 is also floor-only (added by Require torch>=2.6 #1972, 2025-12).
pip metadata does not depend on torch at all: setup.py:916install_requires=["packaging>20.6"].
README.md:22-24 recommends "the latest stable release … or nightly" — so users run current torch, where every site above warns (or silently depends on a private symbol).
Fix direction — precedent already exists in-repo
torch.amp is already used in fused_layer_norm.py:674-720, fused_dense.py:63-75, conv_bias_relu.py:11-89, examples/imagenet/main_amp.py:151 — the migration direction is established. Remaining work:
Route _autocast_utils.py through torch.amp.autocast (with device_type="cuda", which the old API defaulted to implicitly).
Replace custom_fwd/custom_bwd with torch.amp.custom_fwd(device_type='cuda') / custom_bwd(...).
Guard or replace torch.cuda.amp.grad_scaler.OptState in distributed_fused_adam.py (the only non-deprecated-wrapped but private symbol).
Summary
apex still references the deprecated
torch.cuda.ampAPIs in 5 files, 10 references at HEAD (9e3568a6). PR #1813 ("deprecate uses of torch.cuda.amp", merged 2024-06-29) migrated 16 files, and the open PR #1867 only coverscudnn_gbn/batch_norm.py(stale since 2024-12, currently not mergeable). The remaining sites below are still unaddressed:apex/_autocast_utils.pytorch.cuda.amp.autocast_mode._cast(...)— private internal API, the core AMP interop path:_cast_if_autocast_enabledis imported by 5 production modules (apex/fused_dense/fused_dense.py:5,apex/mlp/mlp.py:8,apex/normalization/fused_layer_norm.py:10,apex/contrib/layer_norm/layer_norm.py:5)apex/contrib/cudnn_gbn/batch_norm.pyfrom torch.cuda.amp import custom_bwd, custom_fwd(covered by stale PR #1867)apex/contrib/optimizers/distributed_fused_adam.pytorch.cuda.amp.grad_scaler.OptState— private module symbolapex/contrib/optimizers/distributed_fused_adam.pytorch.cuda.amp.GradScalertype annotationsapex/contrib/test/optimizers/test_distributed_fused_lamb.pyfrom torch.cuda.amp import GradScalertests/L0/run_mlp/test_mlp.pytorch.cuda.amp.autocast_mode.autocast(...)— private internal APIDeprecation status —
torch.cuda.amp.autocast/custom_fwd/custom_bwdare deprecated since torch 2.4,GradScalersince torch 2.3. Verified on torch 2.11 that even the privateautocast_mode._castis deprecated-wrapped and emits the FutureWarning:torch.cuda.amp.grad_scaler.OptStateis a private module symbol with no warning at all — it would break silently when the module is removed. The deprecation notice says these APIs "will be removed in a future release".No version guard, floor-only constraints
LooseVersion, nohasattr(torch.amp, ...), no try/except fallback around them.setup.py:142-148only enforces a floor (TORCH_MAJOR==0 and TORCH_MINOR<4→ error; anything ≥0.4 passes), andrequirements.txt:8torch>=2.6.0is also floor-only (added by Require torch>=2.6 #1972, 2025-12).setup.py:916install_requires=["packaging>20.6"].Fix direction — precedent already exists in-repo
torch.ampis already used infused_layer_norm.py:674-720,fused_dense.py:63-75,conv_bias_relu.py:11-89,examples/imagenet/main_amp.py:151— the migration direction is established. Remaining work:_autocast_utils.pythroughtorch.amp.autocast(withdevice_type="cuda", which the old API defaulted to implicitly).custom_fwd/custom_bwdwithtorch.amp.custom_fwd(device_type='cuda')/custom_bwd(...).torch.cuda.amp.grad_scaler.OptStateindistributed_fused_adam.py(the only non-deprecated-wrapped but private symbol).Reference