THE FILE FIELD GUIDE
.pt

PyTorch Model / Checkpoint

AI & Machine Learning

PT is used for PyTorch data, but may contain a state dictionary, entire model, checkpoint or other payload. Identify the save method and required model definitions rather than guessing from the suffix.

What it is used for
Model weights, checkpoints and other saved data
What the file contains
Binary data
All sections, questions and sources

Content reviewed: · Editor:Kai

Opening steps

Choose your environment or purpose to see its steps.

Identify the purpose and distribution

Distinguish state dictionaries, checkpoints and TorchScript.

  1. Read the publisher instructions and license; record the producer, version and purpose.
  2. Inspect the save code to distinguish torch.save artifacts from torch.jit.save output.
  3. Retain the original and assemble configuration and companions in a working copy.
Inspect with the matching environment

Successful loading and correct inference are separate checks.

  1. Use trusted artifacts in an environment matching the producer’s dependencies and definitions.
  2. For compatible torch.save data, inspect using weights_only=True and an appropriate map_location.
  3. Inspect keys/shapes; for TorchScript use the specified torch.jit.load workflow.
Test with a known input

Match the input contract and compare with a reference.

  1. Instantiate the matching architecture and inspect load_state_dict mismatches for saved weights.
  2. For inference use evaluation mode and the intended inference settings with matching preprocessing.
  3. Compare against the reference and record environment, architecture and loader.

Menu labels and support vary by app, OS and version. Preserve the original before making changes.

Troubleshooting by symptom

  • Key/shape mismatch: compare architecture, version and parameter names.
  • Missing class: whole-model serialization can depend on the original definitions.
  • Restricted loading fails: identify the format/origin rather than disabling protections.
  • No CUDA available: consider supported CPU mapping rather than restoring to the saved GPU.
  • Restricted loading rejects it: identify serialization and objects instead of disabling it blindly.
  • Ignoring keys with strict=False: investigate architectural differences before accepting unloaded layers.

Use PT weights / export to ONNX or another format

  1. Load trusted weights into the correct architecture and validate inputs/results.
  2. Use a supported exporter and compare outputs, precision and memory requirements.
  3. Compare output shapes, values and timing with the same input before/after export; retain definitions and export settings.

Weights without an architecture may be insufficient; renaming PT to GGUF is not conversion.

Why the save code matters

The suffix can cover weight dictionaries, training checkpoints, whole models and TorchScript; choosing a loader by suffix can misidentify the artifact.

Obtain definitions and a loading example from the producer when save code is unavailable; avoid executing unknown files by trial and error.

Source for these steps:PyTorch Project · Saving and Loading Models / PyTorch Project · torch.load / PyTorch Project · Serialization semantics

Why loaded weights can give different predictions

Check evaluation behavior, preprocessing and label order; readable weights do not establish correct inference.

Retain architecture, versions, test input and output; training resumption also needs appropriate optimizer and other state.

Source for these steps:PyTorch Project · Saving and Loading Models / PyTorch Project · torch.load / PyTorch Project · Serialization semantics

Related-format differences

Related-format differences
FormatMain roleWhat to check
PT / PTHConventional PyTorch suffixesIdentify the save API
PT2Export/compiled packageUse the appropriate specialized loader
SAFETENSORSTensor storageDistinct from complete training state

Handling and security

Loading serialized data can involve code-execution risks depending on its format. Do not load untrusted PT; weights_only alone is not a complete safety guarantee.

Questions and answers

Is every PT a weight file?

It may hold weights, a whole model, checkpoints or other data.

Can weights alone run inference?

The correct architecture, configuration and preprocessing are needed.

Should I disable protections to fix loading?

No; inspect origin and save method first.

Is PT structurally different from PTH?

They are naming conventions; identify the format from the save API and documentation.

Does CPU mapping convert the model format?

It changes storage placement, not architecture or serialization format.

Format facts: name, steward and MIME type
Formal name
PyTorch checkpoint or producer-specific data
Steward / specification
PyTorch project / producing application
MIME type
Depends on the producer or server; an extension alone does not establish a MIME type.

Primary and official sources

  • Project documentationSaving and Loading Models

    Explains state dictionaries versus whole-model serialization.

    PyTorch Project · Link checked:
  • Project documentationtorch.load

    Documents weights_only, device mapping and untrusted-file warnings.

    PyTorch Project · Link checked:
  • Official documentationSerialization semantics

    Explains weights_only restrictions and untrusted artifacts.

    PyTorch Project · Link checked: