---
source: https://iinventedlight.com/library/notes/pytorch-reproducibility.md
title: "Reproducibility in PyTorch"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-style (pytorch/pytorch LICENSE; Copyright (c) 2016-present, Facebook Inc.; https://github.com/pytorch/pytorch/blob/main/LICENSE); docs only, not the tutorials repo; PyTorch name and logo not licensed; prose restates or closely paraphrases cited source lines"
license_family: pytorch-bsd
rule_check: "needs rule check (family not in auto-publish rule; check.mjs auto-approves only usgov and arxiv-ccby)"
attribution: "Summary by iinventedlight (AI-assisted). Sources: PyTorch docs, Reproducibility — PyTorch 2.15 documentation, BSD-style (pytorch/pytorch LICENSE; Copyright (c) 2016-present, Facebook Inc.; https://github.com/pytorch/pytorch/blob/main/LICENSE); docs only, not the tutorials repo; PyTorch name and logo not licensed; PyTorch docs, torch.manual_seed — PyTorch 2.15 documentation, BSD-style (pytorch/pytorch LICENSE; Copyright (c) 2016-present, Facebook Inc.; https://github.com/pytorch/pytorch/blob/main/LICENSE); docs only, not the tutorials repo; PyTorch name and logo not licensed."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: PyTorch"
tags: ['pytorch', 'reproducibility', 'determinism']
sources:
  - id: S1
    title: "Reproducibility — PyTorch 2.15 documentation"
    publisher: PyTorch docs
    url: https://docs.pytorch.org/docs/2.15/notes/randomness.html
    accessed: 2026-11-04
    license: "BSD-style (pytorch/pytorch LICENSE; Copyright (c) 2016-present, Facebook Inc.; https://github.com/pytorch/pytorch/blob/main/LICENSE); docs only, not the tutorials repo; PyTorch name and logo not licensed"
  - id: S2
    title: "torch.manual_seed — PyTorch 2.15 documentation"
    publisher: PyTorch docs
    url: https://docs.pytorch.org/docs/2.15/generated/torch.manual_seed.html
    accessed: 2026-11-04
    license: "BSD-style (pytorch/pytorch LICENSE; Copyright (c) 2016-present, Facebook Inc.; https://github.com/pytorch/pytorch/blob/main/LICENSE); docs only, not the tutorials repo; PyTorch name and logo not licensed"
---
# Reproducibility in PyTorch

**Answer:** Results may not be reproducible between CPU and GPU executions, even when using identical seeds. However, there are some steps you can take to limit the number of sources of nondeterministic behavior for a specific platform, device, and PyTorch release. (S1)

## Two levers

- First, you can control sources of randomness that can cause multiple executions of your application to behave differently. (S1)
- Second, you can configure PyTorch to avoid using nondeterministic algorithms for some operations, so that multiple calls to those operations, given the same inputs, will produce the same result. (S1)
- torch.manual_seed sets the seed for generating random numbers on all devices. (S2)
- Some applications and libraries may use NumPy Random Generator objects, not the global RNG, and those will need to be seeded consistently as well. (S1)

## Trade-off

- Deterministic operations are often slower than nondeterministic operations, so single-run performance may decrease for your model. (S1)
- However, determinism may save time in development by facilitating experimentation, debugging, and regression testing. (S1)

## Claims
- id: C1
  claim: CPU and GPU results may differ.
  source: S1
  evidence: "reproducible between CPU and GPU executions"
- id: C2
  claim: manual_seed seeds all devices.
  source: S2
  evidence: "Sets the seed for generating random numbers on all devices."
- id: C3
  claim: Deterministic ops are often slower.
  source: S1
  evidence: "Deterministic operations are often slower than nondeterministic operations"
- id: C4
  claim: Determinism helps debugging.
  source: S1
  evidence: "save time in development by facilitating experimentation, debugging, and"

## Sources
- [S1] Reproducibility — PyTorch 2.15 documentation. PyTorch docs. https://docs.pytorch.org/docs/2.15/notes/randomness.html . License: BSD-style (pytorch/pytorch LICENSE; Copyright (c) 2016-present, Facebook Inc.; https://github.com/pytorch/pytorch/blob/main/LICENSE); docs only, not the tutorials repo; PyTorch name and logo not licensed. Accessed 2026-11-04.
- [S2] torch.manual_seed — PyTorch 2.15 documentation. PyTorch docs. https://docs.pytorch.org/docs/2.15/generated/torch.manual_seed.html . License: BSD-style (pytorch/pytorch LICENSE; Copyright (c) 2016-present, Facebook Inc.; https://github.com/pytorch/pytorch/blob/main/LICENSE); docs only, not the tutorials repo; PyTorch name and logo not licensed. Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
