pytorch-seed
RNG seeding and context management for pytorch
Decision gist · record as of 2026-08-14
Yes, if you need simple, unified RNG seeding for PyTorch and are comfortable with an abandoned package. The code is straightforward and unlikely to break with minor PyTorch updates, but you should test it with your specific PyTorch version and consider forking if you need future fixes. For active projects requiring long-term support, evaluate whether PyTorch Lightning's seed utilities or manual seeding better fits your needs.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires PyTorch 1.0+ and Python 3.6+.
- CUDA RNG seeding only works if CUDA is available.
- Low friction install with only torch and numpy as runtime dependencies.
License · maintenance · safety
permissive license (permissive) — MIT license (permissive). You can use, modify, and distribute this package freely in commercial or private projects, with no warranty and no liability on the authors.
last release 2023-02-15 (1276 days) · last repo commit 2023-02-15 · 2 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 124,120 downloads/mo, #11,885 on PyPI
Alternatives
Verify before relying
pip install pytorch-seed
import pytorch_seed
pytorch_seed.seed(123) # Seeds Python, NumPy, torch CPU, and all CUDA RNGs
# Or use SavedRNG context manager to isolate RNG state:
with pytorch_seed.SavedRNG():
result = torch.rand(1) # Does not affect global RNG- Whether SavedRNG correctly handles all edge cases with newer PyTorch versions (package is abandoned since 2023-02-15).
- Compatibility with PyTorch versions released after the package's last update.
What it is and what it does
pytorch-seed is a lightweight utility for reproducible random number generation in PyTorch projects. It provides a single `seed()` function that simultaneously seeds Python's base RNG, NumPy's RNG, PyTorch's CPU RNG, and all CUDA RNGs—ensuring deterministic behavior across the entire stack. It also offers a `SavedRNG` context manager that lets you temporarily isolate RNG state, either to run code without affecting the global RNG or to maintain independent RNG streams that resume from where they left off.
The package is designed for researchers and practitioners who need reproducible training runs or experiments. Its API mirrors PyTorch Lightning's seeding utilities, making it familiar to users of that ecosystem. Installation is straightforward with only torch and numpy as dependencies, but note that the project is abandoned as of 2023-02-15 with no active maintenance.
Use it for
- Seed all RNGs at the start of a training script to ensure reproducible model initialization and data shuffling across runs.
- Use SavedRNG context manager to run stochastic operations (e.g., data augmentation) without affecting the main training RNG stream.
- Maintain separate RNG streams for different parts of an experiment (e.g., one for data generation, one for model dropout) that evolve independently.
- Verify that two seeded runs produce identical random sequences to validate experiment reproducibility.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need simple, unified RNG seeding for PyTorch and are comfortable with an abandoned package.
The code is straightforward and unlikely to break with minor PyTorch updates, but you should test it with your specific PyTorch version and consider forking if you need future fixes. For active projects requiring long-term support, evaluate whether PyTorch Lightning's seed utilities or manual seeding better fits your needs.
Install
pytorch-seed on PyPI
Before you install
Low friction install with only torch and numpy as runtime dependencies. However, the package is abandoned—last release was 2023-02-15 with no updates since, and the repository shows minimal activity (2 stars). Use only if you need this specific seeding pattern and are comfortable maintaining a fork if issues arise.
Requires PyTorch 1.0+ and Python 3.6+. CUDA RNG seeding only works if CUDA is available.
License in practice
MIT license (permissive). You can use, modify, and distribute this package freely in commercial or private projects, with no warranty and no liability on the authors.
Quickstart
pip install pytorch-seed
import pytorch_seed
pytorch_seed.seed(123) # Seeds Python, NumPy, torch CPU, and all CUDA RNGs
# Or use SavedRNG context manager to isolate RNG state:
with pytorch_seed.SavedRNG():
result = torch.rand(1) # Does not affect global RNG
Verify before relying
- Whether SavedRNG correctly handles all edge cases with newer PyTorch versions (package is abandoned since 2023-02-15).
- Compatibility with PyTorch versions released after the package's last update.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.6 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagestorchnumpy |
| Maintenance | Abandoned 1,276 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 124,120 / month, #11,885 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: Only |
Evidence: pytorch_seed-0.2.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pytorch reproducible seeding”
- pytorch-seedProvides reproducible random number generation for PyTorch by seeding…
- arm-pytorch-utilitiesProvides utility functions for PyTorch development, including random…
- snowfakerySnowfakery generates fake relational data from YAML recipes, writing…
Give your agent the search over MCP, or paste the wish link into any chat.
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.
Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.
Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.
Install it if you work with Hugging Face Hub models or datasets.
LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.
hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.
Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.
Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.
Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.
See also arm-pytorch-utilities · pytest-rng · torch · nvidia-curand · cuequivariance-ops-torch-cu12 · random2 · lovely-tensors · torch-audiomentations · pytorch · torchcodec