perf: replace pandas with polars in the setup-stage scan #93
Reference in New Issue
Block a user
Delete Branch "warm-cache-polars-scan"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
giant.pipeline.run_setup_stage (used by both giant train and dwarf
warm-cache) previously opened and fully read each parquet file 4-6
separate times via pandas, with per-row Python loops padding the
secondary list columns on every chunk of the normalizer-fitting pass.
padding is now a single vectorized polars expression instead of a
per-row Python loop (including a .iloc[i] loop for directions).
index, pdg/material vocab, process counts, and pooled-pdg counts in
one pass per file instead of one pass per section. Frequency-ranking
ties are now an explicit (-count, first_seen) contract instead of an
accident of pandas' value_counts iteration order.
for every section first, then issue one combined scan request for
whatever's missing.
to dev (only test fixtures still use it).
for this scan, mirroring profile_analysis_costs.py's pattern.
Also fixes a real deadlock this surfaced: DataLoader worker
subprocesses fork() on Linux, and polars' native thread pool doesn't
survive a fork — a worker touching polars after the parent already had
hangs instantly. giant/pipeline.py's train/val DataLoaders now use
multiprocessing_context="spawn" whenever num_workers>0.
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01DdT32YWNEwnVLZUHsgdeSC