DeepSpeed 0.14.x Regression: 'Expected all tensors to be on the same device' (ZeRO-3 / Adam Offload)
After upgrading to DeepSpeed >0.14.0 (e.g. 0.14.2), ZeRO-3 / optimizer-offload training crashes with 'Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!'. A regression in the 0.14.x ZeRO-3 path left some tensors on CPU; upgrading past the fix (or downgrading) resolves it.
After upgrading to DeepSpeed >0.
- Symptom
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!- Root cause
- A regression introduced in DeepSpeed 0.14.x ZeRO-3/optimizer-offload code (a single line in stage3.
- Recommended fix
- Upgrade DeepSpeed to a release after the fix (master past 0.14.x / the commit that reverts stage3.py)
- How Denpex helps
- Denpex investigates DeepSpeed 0.14.x Regression: 'Expected all tensors to be on the same device' (ZeRO-3 / Adam Offload) using the evidence you provide or your connected workload collects. Earlier rank, host or application evidence is needed to distinguish an initiating failure from a downstream report.
What this failure is
DeepSpeed 0.14.x Regression: 'Expected all tensors to be on the same device' (ZeRO-3 / Adam Offload) is a Distributed Training failure seen during ML training runs. After upgrading to DeepSpeed >0.14.0 (e.g. 0.14.2), ZeRO-3 / optimizer-offload training crashes with 'Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!'. A regression in the 0.14.x ZeRO-3 path left some tensors on CPU; upgrading past the fix (or downgrading) resolves it. Common tags: Deepspeed, Zero 3, Optimizer Offload, Device Mismatch.
Is this what broke your run? Paste your log.
You're reading about DeepSpeed 0.14.x Regression: 'Expected all tensors to be on the same device' (ZeRO-3 / Adam Offload). Paste your own traceback and relevant evidence for an investigation of your workload, with a next action or a specific missing fact. A reference entry does not establish your cause. No account or card for the free diagnosis. Review data handling before submitting sensitive logs.
Before uploading, review cloud data handling and local options.
Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.
Why it happens (the mechanism)
A regression introduced in DeepSpeed 0.14.x ZeRO-3/optimizer-offload code (a single line in stage3.py) left some optimizer/parameter tensors on CPU while siblings moved to CUDA. The mismatched devices then collide during an elementwise/optimizer op; the line was later reverted/fixed on master. Taken together, these mechanisms explain why the failure is reproducible, why it tends to surface on specific workloads or scales, and why generic mitigation attempts often fall short without addressing the underlying cause.
What you'll observe
- Training that worked on 0.13.x crashes after upgrading DeepSpeed to 0.14.x
- Device-mismatch RuntimeError during the optimizer step or ZeRO-3 resume
- Adam offload / ZeRO-3 fp16/bf16 affected
Common symptoms and what they mean
Check possible explanations against the incident evidence. A matching symptom alone does not establish its cause.
| Symptom | Possible explanation |
|---|---|
| RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! | A regression introduced in DeepSpeed 0.14.x ZeRO-3/optimizer-offload code (a single line in stage3.py) left some optimizer/parameter tensors on CPU while siblings moved to CUDA |
| Traceback through deepspeed/runtime/zero/stage3.py | The mismatched devices then collide during an elementwise/optimizer op; the line was later reverted/fixed on master |
| Only on DeepSpeed >0.14.0 | A regression introduced in DeepSpeed 0.14.x ZeRO-3/optimizer-offload code (a single line in stage3.py) left some optimizer/parameter tensors on CPU while siblings moved to CUDA |
Which systems are affected
- DeepSpeed 0.14.x with ZeRO-3 and/or optimizer offload
- HF Trainer resume tests with ds_optim/ds_scheduler
- Mixed CPU-offload + CUDA optimizer state
How to confirm this is the problem
Use this checklist to test the hypothesis against a small reproduction. No single line proves the root cause, so preserve the preceding events and compare one variable at a time.
- ✓Reproduce the failure from a clean checkpoint/seed: the symptom must appear without warm-up state from a previous run.
- ✓Verified signal present: RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
- ✓Verified signal present: Traceback through deepspeed/runtime/zero/stage3.py
- ✓Verified signal present: Only on DeepSpeed >0.14.0
- ✓A targeted fix from the "How to fix it" section eliminates or substantially reduces the symptom within one validation pass.
Root cause
- A regression introduced in DeepSpeed 0.14.x ZeRO-3/optimizer-offload code (a single line in stage3.py) left some optimizer/parameter tensors on CPU while siblings moved to CUDA
- The mismatched devices then collide during an elementwise/optimizer op; the line was later reverted/fixed on master
The fix and how to prevent it
How to fix it
- Upgrade DeepSpeed to a release after the fix (master past 0.14.x / the commit that reverts stage3.py)
- Or downgrade to a known-good 0.13.x until you can move forward
- Verify with a ZeRO-3 resume smoke test; keep offload_optimizer/offload_param device settings consistent
Step-by-step remediation
- 1Upgrade DeepSpeed to a release after the fix (master past 0.14.x / the commit that reverts stage3.py)
- 2Or downgrade to a known-good 0.13.x until you can move forward
- 3Verify with a ZeRO-3 resume smoke test; keep offload_optimizer/offload_param device settings consistent
How to prevent it
- Pin DeepSpeed to a tested version and run a resume smoke test after upgrades
- Watch DeepSpeed release notes for ZeRO-3 offload regressions
- Avoid jumping onto a brand-new minor release for long runs
Save this diagnosis and catch the next crash automatically
All root cause, fix, and prevention steps above are free to read. Create a free account with any email or GitHub to keep your saved diagnosis history across the encyclopedia and run cloud checks, or use a work email below for the 30-day Team evaluation. No card required.
Or start a 30-day free Team trial (work email)
Verified work email unlocks all 14 fleet diagnostic tools, Slack alerts, and team history for 30 days. No card and no automatic charge.
Searchable error signature
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
Device-mismatch RuntimeError during the optimizer step or ZeRO-3 resumeUse this text as a lookup key in logs and upstream issue trackers. It is not presented as a captured customer log. Confirm the cause from your own preceding events, versions, configuration and the cited references.
Diagnose your own log automatically
The root cause and fix steps above stay free. Create a free account to analyze full job logs, attribute the first failed rank, and keep saved incident history.
Sign up free. Analyze your cluster logsNo credit card. Daily allowance follows verified trust tier. Instant access.
Diagnose this failure in VS Code
Select the traceback or open the failed terminal, then run Denpex locally to inspect matched failure patterns, supporting evidence and next checks without uploading the log. Verify recommendations against your workload before changing production.
Install the free VS Code extensionDeepSpeed errors in context
DeepSpeed changes when parameters, gradients and optimizer state are created, partitioned, gathered and offloaded. The hub separates ZeRO, memory, checkpoint and pipeline failures by lifecycle phase.
Compare related deepspeed errorsRelated failures to investigate next
Don't just read the fix, diagnose your run
The encyclopedia explains documented failure patterns. Denpex investigates your logs, configuration and stack, shows the supporting evidence, and asks for missing details when needed.