Description
The compute_standardization_stats.py script hangs indefinitely when run with default settings on Linux. The script gets stuck at 0% progress during the data loading phase and never completes.
Steps to Reproduce
- Install neural-lam from main branch on Linux
- Download and extract the MEPS example dataset
- Place the datastore config in the correct location:
cp data/meps.datastore.yaml
- Run the standardization stats computation:
python -m neural_lam.datastore.npyfilesmeps.compute_standardization_stats \
--datastore_config_path data/meps_example/meps.datastore.yaml
Expected Behavior
The script should compute mean and standard deviation statistics for the dataset and complete within a few minutes for the small example dataset.
Actual Behavior
The script hangs indefinitely at:
Computing mean and std.-dev. for parameters...
0%| | 0/1 [00:00<?, ?it/s]
- No progress is made
- CPU usage drops to near zero
- Process must be killed manually (Ctrl+C)
- Tested for over 1 hour with no completion
Root Cause
This is a fork-safety deadlock specific to Linux, caused by PyTorch DataLoader using fork() after Dask has initialized thread pools.
It is NOT caused by Dask spawning processes inside workers.
What Actually Happens:
- The main process initializes Dask arrays
- Dask creates internal thread pools
- PyTorch DataLoader with
num_workers > 0 uses fork() on Linux (default multiprocessing start method)
fork() copies the entire memory space and lock states, but does NOT copy running threads
- Worker processes inherit locks that appear "held" by threads that don't exist in the child
- When Dask tries to acquire those locks in the worker, it blocks forever waiting for non-existent threads
- Result: Workers freeze, progress bar stays at 0%
Why This Only Happens on Linux:
| Platform |
Default Start Method |
Behavior |
| Linux |
fork |
💀 Deadlock (inherits broken locks) |
| Windows |
spawn |
✅ Works (fresh interpreter per worker) |
| macOS |
spawn |
✅ Works (fresh interpreter per worker) |
Environment
- OS: Linux (Ubuntu)
- Python: 3.11
Description
The
compute_standardization_stats.pyscript hangs indefinitely when run with default settings on Linux. The script gets stuck at 0% progress during the data loading phase and never completes.Steps to Reproduce
python -m neural_lam.datastore.npyfilesmeps.compute_standardization_stats \ --datastore_config_path data/meps_example/meps.datastore.yamlExpected Behavior
The script should compute mean and standard deviation statistics for the dataset and complete within a few minutes for the small example dataset.
Actual Behavior
The script hangs indefinitely at:
Root Cause
This is a fork-safety deadlock specific to Linux, caused by PyTorch DataLoader using
fork()after Dask has initialized thread pools.It is NOT caused by Dask spawning processes inside workers.
What Actually Happens:
num_workers > 0usesfork()on Linux (default multiprocessing start method)fork()copies the entire memory space and lock states, but does NOT copy running threadsWhy This Only Happens on Linux:
forkspawnspawnEnvironment