Skip to content

Weights-only load failed with an UnpicklingError when you resume an older checkpoint

A checkpoint that loaded without complaint for months starts failing after a framework upgrade. Nothing about the file changed. The loader now refuses by default to reconstruct any Python object that is not a plain tensor, and a training checkpoint carries several, the optimizer class among them, so the load stops on the first one it meets.

Quick answer

The checkpoint is fine; the loader got stricter. It refuses to rebuild Python objects like the optimizer class. Allowlist the exact class the error names, ideally through the scoped context manager, and expect one or two more behind it.

Symptom
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options
Root cause
Reconstructing a pickle can execute arbitrary code, because the format stores instructions for rebuilding objects rather than only their data. Restricting the loader to tensors and primitives by default closes that hole, and it is the right default for a file arriving from anywhere but your own cluster. A training checkpoint is not only tensors.
Recommended fix
Allowlist the specific classes the checkpoint legitimately contains, using the serialization allowlist the error message names. This keeps the protection for everything else and is the fix that is safe to leave in place.
How Denpex helps
Denpex investigates Weights-only load failed with an UnpicklingError when you resume an older checkpoint 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.
Checkpointing#weights-only#unpickling#torch-load#add-safe-globals#checkpoint#optimizer-state

What this failure is

A resume-time failure in which a checkpoint written under a permissive deserialization default is read under a restrictive one, so the loader refuses to reconstruct the non-tensor objects the checkpoint legitimately contains.

Live diagnosis, no signup

Is this what broke your run? Paste your log.

You're reading about Weights-only load failed with an UnpicklingError when you resume an older checkpoint. 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.

training_logs.txt
No log to hand? Try one:

Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.

3 free cloud diagnoses per day

Why it happens (the mechanism)

Deserialization of a pickle is code execution, so the safe default is to rebuild nothing but tensors. Training checkpoints have always stored more than tensors, because resuming needs the optimizer, the scheduler and the run configuration. Those two facts were compatible only while the default was permissive; once it flipped, every previously written checkpoint became a file the reader declines to fully trust.

What you'll observe

  • The file is intact and readable, so every corruption check comes back clean
  • The same file loaded successfully under the previous framework release
  • The message offers a way to disable the restriction, which is the fastest fix and the wrong default
  • It surfaces at resume, typically hours into a queue slot, on every rank at once

Common symptoms and what they mean

Check possible explanations against the incident evidence. A matching symptom alone does not establish its cause.

SymptomPossible explanation
_pickle.UnpicklingError: Weights only load failed, raised from inside the checkpoint loaderReconstructing a pickle can execute arbitrary code, because the format stores instructions for rebuilding objects rather than only their data. Restricting the loader to tensors and primitives by default closes that hole, and it is the right default for a file arriving from anywhere but your own cluster.
WeightsUnpickler error: Unsupported global, naming a class such as an optimizer that was not an allowed global by defaultA training checkpoint is not only tensors. It holds the optimizer, its parameter groups, the scheduler, the sampler position and the run's arguments, all of which are Python objects that the restricted loader will not rebuild. The first one encountered stops the load, so the reported class is whichever came first and not necessarily the only one.
A suggestion to call add_safe_globals or use the safe_globals context manager with the named classNothing is wrong with the checkpoint. It was written under a permissive default and is being read under a strict one, so the change of behaviour lives entirely in the reader. This is why file-level integrity checks all pass and why the same bytes still load in the older release.
Every rank raising the same error at the same point, because they are all reading the same common stateReconstructing a pickle can execute arbitrary code, because the format stores instructions for rebuilding objects rather than only their data. Restricting the loader to tensors and primitives by default closes that hole, and it is the right default for a file arriving from anywhere but your own cluster.

Which systems are affected

  • Resuming any training checkpoint written before the loader's default changed
  • Distributed checkpoint formats that store a common state dictionary alongside the sharded tensors
  • Optimizer state, which pickles the optimizer class itself rather than only its numbers
  • Learning-rate schedulers, dataloader samplers, and argument namespaces saved beside the weights

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.

  • ✓Read the class named after Unsupported global. If it is an optimizer, a scheduler or an argument container, this is the strict-loader change and not damage to the file.
  • ✓Load the same file with the restriction disabled once, in a scratch process. Success proves the bytes are fine and the reader's default is what moved.
  • ✓Check whether the checkpoint predates your current framework release. A file written under the permissive default is the whole precondition.

Root cause

  • Reconstructing a pickle can execute arbitrary code, because the format stores instructions for rebuilding objects rather than only their data. Restricting the loader to tensors and primitives by default closes that hole, and it is the right default for a file arriving from anywhere but your own cluster.
  • A training checkpoint is not only tensors. It holds the optimizer, its parameter groups, the scheduler, the sampler position and the run's arguments, all of which are Python objects that the restricted loader will not rebuild. The first one encountered stops the load, so the reported class is whichever came first and not necessarily the only one.
  • Nothing is wrong with the checkpoint. It was written under a permissive default and is being read under a strict one, so the change of behaviour lives entirely in the reader. This is why file-level integrity checks all pass and why the same bytes still load in the older release.

The fix and how to prevent it

How to fix it

  • Allowlist the specific classes the checkpoint legitimately contains, using the serialization allowlist the error message names. This keeps the protection for everything else and is the fix that is safe to leave in place.
  • Prefer the scoped context manager over a global registration when the allowlist is only needed around one load, so the relaxation does not outlive the call that needed it.
  • Read the whole error rather than the first line. It names the exact class it refused, and adding that one class is often the entire fix.
  • Where the checkpoint is your own and its provenance is not in question, disabling the restriction for that single load is defensible, but do it at the call site rather than as a process-wide setting.
  • Expect to repeat the allowlisting more than once: the load stops at the first unsupported class, so a second and third may appear behind it.

Step-by-step remediation

  1. 1Find the class after Unsupported global in the error; that is what the loader refused.
  2. 2Load once with the restriction disabled in a scratch process to prove the bytes are intact.
  3. 3Register the exact class through the serialization allowlist the message names.
  4. 4Use the context manager so the relaxation does not outlive the load.
  5. 5Re-run and allowlist any further class the loader stops on.

How to prevent it

  • Re-save checkpoints in the strict format once, at the point of a framework upgrade, so the allowlist is not needed on every future resume.
  • Separate the numeric state from the objects when writing: store optimizer tensors and a plain description of the configuration rather than the live objects.
  • Test a resume, not just a save, whenever the framework version changes, since the write path is unaffected and will not reveal this.

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.

Use your company email, for example alex@yourcompany.com.

Who qualifies?

Company email domains activate the free 30-day Team evaluation (up to 50 diagnoses a day) after an email and domain check, whatever mail provider you use. If we cannot verify your domain automatically, support reviews it: write to support@denpex.com. Free local diagnosis in the editor extension needs no account.

Using a personal email (Gmail, Outlook, Naver, QQ) or solo cluster? Create a free $0 account (no work email required) to save 7-day history and unlock AI fallback, or send a cluster crash log for a live walkthrough.
Already have an account? Sign in

Searchable error signature

search key
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options
WeightsUnpickler error: Unsupported global: GLOBAL torch.optim.adamw.AdamW was not an allowed global by default
Please use `torch.serialization.add_safe_globals([torch.optim.adamw.AdamW])` to allowlist this global
  File ".../megatron/training/checkpointing.py", in _load_base_checkpoint
    state_dict = dist_checkpointing.load_common_state_dict(checkpoint_name)

Use 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 logs

No credit card. Daily allowance follows verified trust tier. Instant access.

Why the recommended fix works

Allowlisting states, class by class, that you know what is in your own file. The loader keeps refusing everything you did not name, so the protection still applies to any checkpoint arriving from elsewhere. Disabling the restriction wholesale also loads the file, but it discards the protection for every object in it rather than for the one you inspected.

Best practices by model family

Model / StackRecommendationNotes
Your own cluster's checkpointAllowlist the named classesKeeps the restriction for everything you did not name.
One-off load in a scriptScoped safe-globals context managerThe relaxation ends with the call.
Checkpoint from an external sourceAllowlist only, never disableThis is exactly the case the default protects.
Fleet-wide upgradeRe-save once in the strict formatRemoves the need for an allowlist on future resumes.

With the fix vs without the fix

DimensionWith the fixWithout the fix
Is the checkpoint damagedNo, only read under a stricter defaultInvestigated as corruption
How many classes will it nameOne at a time, in the order encounteredAssumed to be the only one
Where to relax the ruleAt the single call siteAs a process-wide setting

Diagnostic note

“The message helpfully offers two routes and people take the first one, because it is a single argument and the job is already an hour into its allocation. That choice then propagates: it gets committed to the training script, and from there into every job on the cluster, including the ones loading checkpoints pulled from a model hub. Spend the extra minute on the allowlist. The class names are printed for you.”

Visual fingerprint

What a training checkpoint actually holds
  checkpoint
    ├── model tensors          -> rebuilt under the strict default
    ├── optimizer state
    │     └── class AdamW      -> REFUSED: unsupported global
    ├── lr scheduler
    └── run arguments

  load stops at the FIRST refusal; the ones below are not yet reported
Only the tensors are rebuilt without question. The load halts on the first Python object it will not reconstruct, so the class named in the error is the first of possibly several rather than the only one.

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 extension

Frequently asked questions

Questions engineers and on-call staff commonly ask about this failure.

Is my checkpoint corrupted?
No. The bytes are unchanged; the loader's default changed. Integrity checks pass because there is nothing wrong with the file.
Why not just disable the restriction?
It works, and it removes the protection for every object in the file rather than the one class you actually inspected. Once it is in the training script it applies to externally sourced checkpoints too.
I allowlisted the class and got another error.
Expected. The load stops at the first refusal, so the next unsupported class is only revealed once the first is permitted.
Can I stop this happening on every resume?
Re-save the checkpoint once under the strict format. Later resumes then contain nothing that needs allowlisting.

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.