from sklearn.model_selection import train_test_split
train_test_split(X, y)
R101 · warning · line 2: sklearn.model_selection.train_test_split has no explicit non-None random_state.
One explicit alternative
from sklearn.model_selection import train_test_split
train_test_split(X, y, random_state=seed)
No covered finding in this snippet. This is not proof of repeatability.
The covered split omits random_state. An explicit seed makes the intended policy visible; global RNG initialization can also matter and should be reviewed.
Shuffle indices from a seeded generator instead of unseeded global state.
Before
import numpy as np
indices = np.arange(len(X))
np.random.shuffle(indices)
R111 · review · line 3: numpy.random.shuffle draws from NumPy's global RNG, which this file never seeds.
One explicit alternative
import numpy as np
rng = np.random.default_rng(seed)
indices = np.arange(len(X))
rng.shuffle(indices)
No covered finding in this snippet. This is not proof of repeatability.
np.random.shuffle draws from NumPy's global RNG, and nothing in this file seeds it. A Generator created with the experiment's seed keeps the policy local and visible. Seeding may also happen in another module; this is a review item, not a defect finding.
import numpy as np
np.random.seed()
indices = np.arange(len(X))
np.random.shuffle(indices)
R111 · review · line 4: numpy.random.shuffle draws from NumPy's global RNG, which this file never seeds.
One explicit alternative
import numpy as np
np.random.seed(seed)
indices = np.arange(len(X))
np.random.shuffle(indices)
No covered finding in this snippet. This is not proof of repeatability.
np.random.seed() and seed(None) draw OS or clock entropy, so they do not make a later shuffle repeatable. Pass the experiment's seed, or switch to a Generator created with that seed.
R112 · review · line 2: random.shuffle draws from Python's global random module, which this file never seeds.
One explicit alternative
import random
rng = random.Random(seed)
rng.shuffle(items)
No covered finding in this snippet. This is not proof of repeatability.
random.shuffle draws from Python's module-level generator, and this file never seeds it. A dedicated Random instance keeps the experiment's policy visible; seeding may also happen elsewhere, so this remains a review item.
No covered finding in this snippet. This is not proof of repeatability.
For the covered CPU configuration, deterministic mode also needs an explicit histogram choice. Select row-wise or column-wise construction for your workload; the example uses column-wise.
No covered finding in this snippet. This is not proof of repeatability.
torch.randn draws from PyTorch's global RNG, which this file never seeds. torch.manual_seed with the experiment's seed makes the initialization repeatable on one device; cuDNN kernels and data loading still need their own review.
from torch.utils.data import DataLoader
DataLoader(dataset, shuffle=True)
R106 · review · line 2: torch.utils.data.DataLoader samples data without an explicit seeded generator.
One explicit alternative
import torch
from torch.utils.data import DataLoader
DataLoader(dataset, shuffle=True, generator=torch.Generator().manual_seed(seed))
No covered finding in this snippet. This is not proof of repeatability.
A missing generator needs review because RNG state may be managed elsewhere. The example makes generator ownership explicit; worker initialization and dataset behavior still need attention.
from torch.utils.data import DataLoader, RandomSampler
DataLoader(dataset, sampler=RandomSampler(dataset))
R106 · review · line 2: torch.utils.data.RandomSampler samples data without an explicit seeded generator.
One explicit alternative
import torch
from torch.utils.data import DataLoader, RandomSampler
DataLoader(dataset, sampler=RandomSampler(dataset, generator=torch.Generator().manual_seed(seed)))
No covered finding in this snippet. This is not proof of repeatability.
DataLoader does not shuffle when a sampler is passed, so an unseeded RandomSampler is invisible to the shuffle check. The sampler draws from the global RNG until generator= is a seeded torch.Generator. SequentialSampler is not random and is not flagged.
import torch
from torch.utils.data import DataLoader
DataLoader(dataset, shuffle=True, generator=torch.Generator())
R106 · review · line 3: torch.utils.data.DataLoader samples data without an explicit seeded generator.
One explicit alternative
import torch
from torch.utils.data import DataLoader
DataLoader(dataset, shuffle=True, generator=torch.Generator().manual_seed(seed))
No covered finding in this snippet. This is not proof of repeatability.
DataLoader accepts a generator object, but the constructor draws OS entropy until manual_seed is given a value. Chain manual_seed with the experiment's seed. A generator variable is still accepted without proving that it was seeded.
No covered finding in this snippet. This is not proof of repeatability.
Benchmarking can select different convolution algorithms between runs. Turning it off addresses this setting, but does not establish deterministic execution.
Decide whether determinism is required or advisory.
Before
from lightning.pytorch import Trainer
Trainer(deterministic='warn')
R109 · review · line 2: lightning.pytorch.Trainer does not request strict determinism with benchmarking disabled.
One explicit alternative
from lightning.pytorch import Trainer, seed_everything
seed_everything(seed, workers=True)
Trainer(deterministic=True, benchmark=False)
No covered finding in this snippet. This is not proof of repeatability.
Warning-only mode allows operations without a deterministic implementation to proceed. Strict mode can raise errors, so review the choice and its effect on training.
Make unsupported deterministic operations visible.
Before
import os
import torch
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":4096:8"
torch.use_deterministic_algorithms(True, warn_only=True)
R110 · review · line 4: torch.use_deterministic_algorithms allows operations without a deterministic implementation.
One explicit alternative
import os
import torch
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":4096:8"
torch.use_deterministic_algorithms(True, warn_only=False)
No covered finding in this snippet. This is not proof of repeatability.
With warn_only=True, an unsupported operation can continue. Strict mode changes that behavior and may stop a run; it is a policy decision, not a universal fix.
These are saved static results from the same checker as the CLI. To scan your own code, use the live check below. seed is a value you choose for your experiment.
Useful for your next experiment? Keep Repro Lens in your GitHub stars so you can find it again.
The same checker as the CLI, running in this tab. Your code is not uploaded anywhere.
◎ LIVE CHECKPython in your browser / nothing uploaded
⌘/Ctrl + Enter to check
Press Check code. The first check downloads Python for this page (about 13 MB, once).
LIVE, IN YOUR BROWSER
Runs the analyzer from this build with Pyodide, served from this site. It screens selected APIs as text and never runs your code. A clean result is not proof of repeatability.