Repository navigation
ignition: tune discrete CompilePool sizing and scale Inductor compile threads - #639
original-el8 wants to merge 1 commit into
Conversation
… threads Why: Discrete GPU compiler workers retain ~672 MiB of device memory for CUDA context initialization and TorchInductor constant folding and exit before runtime allocations. Reserving 1 GiB per worker and subtracting full runtime headroom_bytes from device free memory under-allocates compile workers when large runtime reserves are configured. On high-core-count CPU hosts, setting compile_threads=1 in CompilePool and ForwardCache.prepare_many also leaves host cores idle, and workers inside SubprocPool require worker_start_method="subprocess" on POSIX to parallelize TorchInductor without daemonic multiprocessing errors. What: - ignition/preparation/compile_pool.py: - Before: _DISCRETE_WORKER_DEVICE_BYTES was 1 << 30 (1 GiB), compiler_resources subtracted full headroom_bytes on both integrated and discrete GPUs, and CompilePool.__init__ set compile_threads=1 without setting worker_start_method. - After: _DISCRETE_WORKER_DEVICE_BYTES is 704 << 20 (704 MiB). compiler_resources reserves full headroom_bytes on integrated GPUs with shared physical memory and caps the discrete device reserve at 1 GiB (min(headroom_bytes, 1024 << 20)). CompilePool.__init__ sets compile_threads = max(1, min(8, (cpu_count or 1) // max(1, self.workers))) and sets worker_start_method="subprocess" when os.name != "nt". - ignition/preparation/aot.py: - Before: ForwardCache.prepare_many patched torch._inductor.config.compile_threads=1. - After: ForwardCache.prepare_many patches torch._inductor.config.compile_threads=min(24, os.cpu_count() or 1). - tests/preparation/test_compile_pool.py and tests/preparation/test_forward_compile_options.py: - Update discrete worker sizing, 1 GiB discrete compile-reserve, and thread-partitioning expectations, and add coverage for ForwardCache.prepare_many compile_threads scaling. Result: Discrete GPUs size compile workers against a 704 MiB per-worker footprint and at most a 1 GiB device compile reserve, while CompilePool workers and ForwardCache.prepare_many scale TorchInductor CPU threads with host core count. Verification and limitations: - Isolated CPU-only unit tests (CUDA_VISIBLE_DEVICES="", pytest): - tests/preparation/test_forward_compile_options.py, test_compile_pool.py, test_forward_artifact_sharing.py, test_host_memory.py: 146 passed, 0 failed. - tests/preparation/test_aot_guards.py, test_preparation_reclamation.py, test_core_boundary.py, test_runtime_core.py, test_capture_graph_metadata.py: 56 passed, 14 CUDA-gated tests skipped, 0 failed. - Combined-stack GB300 (SM103) model exports: DeepSeek-V4.1 preparation compiled 101/101 model forwards in 359.8 s and Inkling-2-Small preparation compiled 148-graph forwards without SubprocPool daemonic multiprocessing errors or device OOM. - Limitations: GPU-gated preparation unit tests (FLARE_RUN_CUDA_TESTS=1) were not executed in the CPU-only run. Design-Signed-Off-By: Jason Cook <1637905+original-el8@users.noreply.github.com>; design-review=2e5b
|
A case file has been opened for 639. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThis draft PR targets a legitimate compilation-throughput bottleneck in shared
Walkthrough
Merge Risk: High · up to
|
Why
Discrete GPU compiler workers initialize a CUDA context and run TorchInductor constant folding, consuming ~672 MiB of device memory and exiting before runtime allocations. Reserving
1 GiBper discrete worker and subtracting the full runtime/KVheadroom_bytesfrom device free memory under-allocates compile workers when large runtime reserves are configured.On high-core-count CPU hosts, pinning each
CompilePoolworker tocompile_threads=1and patchingForwardCache.prepare_manytocompile_threads=1leaves most host CPU cores idle during compilation and fallback artifact binding. In addition,CompilePoolworkers run inside spawnedSubprocPoolprocesses, where TorchInductor requiresworker_start_method="subprocess"on POSIX to spawn nested compile workers without hitting daemonic multiprocessing restrictions.What changed
ignition/preparation/compile_pool.py:_DISCRETE_WORKER_DEVICE_BYTESwas1 << 30(1 GiB),compiler_resourcessubtracted the fullheadroom_byteson both integrated and discrete GPUs, andCompilePool.__init__forcedcompile_threads=1without configuringworker_start_method._DISCRETE_WORKER_DEVICE_BYTESis704 << 20(704 MiB).compiler_resourcescontinues to reserve fullheadroom_byteson integrated GPUs with shared physical memory, and caps the discrete device-side compile reserve at1 GiB(min(headroom_bytes, 1024 << 20)).CompilePool.__init__partitions host CPU threads across admitted workers (max(1, min(8, (os.cpu_count() or 1) // max(1, self.workers)))) and setsworker_start_method="subprocess"whenos.name != "nt"(preserving"spawn"on Windows).ignition/preparation/aot.py:ForwardCache.prepare_manypatchedtorch._inductor.config.compile_threadsto1.ForwardCache.prepare_manypatchestorch._inductor.config.compile_threadstomin(24, os.cpu_count() or 1).tests/preparation/test_compile_pool.pyandtests/preparation/test_forward_compile_options.py:1 GiBdiscrete compile reserve, and CPU thread-partitioning expectations, and added unit coverage forForwardCache.prepare_manycompile_threadsscaling.Result
Discrete GPUs admit compile workers against their
704 MiBper-worker footprint and<= 1 GiBcompile-time device reserve, whileCompilePoolworkers andForwardCache.prepare_manyscale TorchInductor CPU compilation threads with host core count.Verification
CUDA_VISIBLE_DEVICES="",pytest):tests/preparation/test_forward_compile_options.py,tests/preparation/test_compile_pool.py,tests/preparation/test_forward_artifact_sharing.py,tests/preparation/test_host_memory.py: 146 passed, 0 failed.tests/preparation/test_aot_guards.py,tests/preparation/test_preparation_reclamation.py,tests/preparation/test_core_boundary.py,tests/preparation/test_runtime_core.py,tests/preparation/test_capture_graph_metadata.py: 56 passed, 14 skipped, 0 failed (skipped tests are gated onFLARE_RUN_CUDA_TESTS=1).SM103) model exports:101/101model forwards in359.8 s, and Inkling-2-Small preparation compiled148-graph forwards withoutSubprocPooldaemonic multiprocessing errors or device OOM (combined-stack export validation alongside the isolated CPU unit suite above).Limitations: GPU-gated preparation unit tests (
FLARE_RUN_CUDA_TESTS=1) were skipped in the CPU-only run.Discord: el8