--- id: pytorch-seed version: "0.2.0" license: Copyright (c) 2023 University of Michigan ARM Lab Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) license_treatment: permissive maintenance: abandoned --- # pytorch-seed — RNG seeding and context management for pytorch License: permissive · Maintenance: abandoned · Downloads: 124.1K/mo ## 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 above — verify before relying. Provides reproducible random number generation for PyTorch by seeding Python, NumPy, and all CUDA RNGs together, plus context managers to isolate or save RNG state. 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 pip install pytorch-seed uv add pytorch-seed poetry add pytorch-seed ## Installing pytorch-seed 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. 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 Requires PyTorch 1.0+ and Python 3.6+. CUDA RNG seeding only works if CUDA is available. 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: Copyright (c) 2023 University of Michigan ARM Lab Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) (permissive) - Python support: supports_current - Install friction: low - Maintenance: abandoned - Downloads: 124.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytorch reproducible seeding, torch rng seed everything, pytorch random state management, deterministic pytorch training, torch cuda rng control, pytorch reproducibility utilities, reproducibility, rng-seeding [View on SkillFed](https://skillfed.io/packages/pytorch-seed) · [View on PyPI](https://pypi.org/project/pytorch-seed/)