Repository navigation
fix(ignition): expose current_source_roots and propagate source roots to tuning replicas - #678
brandonmmusic-max wants to merge 1 commit into
Conversation
|
A case file has been opened for 678. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThe spawn-boundary
Walkthrough
Merge Risk: Low · up to
|
… to tuning replicas Commit 2acc3f3 (NVIDIA#670) propagated bound external recipe `source_roots` across `mp.get_context("spawn")` in `ignition.preparation.rank_group`, reading private `_EXTRA_ROOTS.get()` directly in `rank_group.py` (matching `aot.py`). Two gaps remain on `main`: 1. `ignition/preparation/aot.py` and `ignition/preparation/rank_group.py` import private `_EXTRA_ROOTS` directly from `source_identity.py` instead of calling a public accessor. 2. `ignition/preparation/tuning_replicas.py` spawns local tuning replicas via `mp.get_context("spawn")` without propagating bound `source_roots`. Although `_replica` currently calls `prepare(..., compile_forwards=False)` and exits on `TuningComplete` without reaching an in-tree `ForwardCache` or `source_identity()` call today, binding `source_roots` in `_replica` gives local spawned tuning workers the same context invariant as `rank_group._peer` if a recipe or future preparation path inspects bound source roots during tuning. Before this change, `aot.py` and `rank_group.py` imported `_EXTRA_ROOTS` directly, `source_identity.py` had no public accessor for the active `ContextVar`, and `tuning_replicas._replica` ran with an empty `source_roots` context. After this change: - `ignition/preparation/source_identity.py` adds `current_source_roots() -> tuple[tuple[str, Path], ...]` returning `_EXTRA_ROOTS.get()`, and updates `source_roots`'s docstring to cover active CLI and spawned worker contexts. - `ignition/preparation/aot.py` and `ignition/preparation/rank_group.py` call `current_source_roots()` so `_EXTRA_ROOTS` stays private to `source_identity.py` (keeping `NVIDIA#670`'s narrow `with bind_source_roots(...)` scope in `rank_group._peer` untouched). - `ignition/preparation/tuning_replicas.py` captures `current_source_roots()` in `prepare_recipe`, passes `extra_source_roots` as a required argument to `_replica`, and binds `with source_roots(extra_source_roots), CoreStorage(...)` around replica preparation. - `tests/preparation/test_forward_cache_sources.py` switches `_record_source_roots_prepare` to `current_source_roots()`, adds `test_current_source_roots_reflects_active_scope`, and adds `test_prepare_recipe_propagates_source_roots_to_spawned_tuning_replica` asserting both `current_source_roots()` and `ForwardCache.root` agreement between replica 0 and spawned replica 1 against the unbound baseline. Claimed result: keeps `_EXTRA_ROOTS` encapsulated behind `current_source_roots()`, brings spawned local tuning replicas to spawn-boundary parity with `rank_group._peer`, and adds real-spawn CPU regression coverage for both helpers. No model core format, Helios ABI, or single-GPU preparation behavior changes are introduced. Validation and limitations (CPU, `CUDA_VISIBLE_DEVICES=""`): - `py_compile` clean across all five modified Python files; `git diff --check` clean; `git grep _EXTRA_ROOTS` confirms zero references outside `ignition/preparation/source_identity.py`. - `pytest -v tests/preparation/test_forward_cache_sources.py tests/preparation/test_forward_cache_concurrency.py tests/preparation/test_forward_cache_root.py tests/preparation/test_core_boundary.py tests/preparation/test_native_processes.py tests/preparation/test_tuning_shards.py tests/cli/test_recipe_injection.py`: 36 passed, 0 failed, 0 skipped. - Limitations: the tuning-replica CPU test stubs `torch.cuda.set_device`, `torch.cuda.synchronize`, and `CoreStorage` while exercising real `multiprocessing.get_context("spawn")` serialization and `source_roots` rebinding; multi-GPU CUDA tuning-replica runs were not executed on CPU. Design-Signed-Off-By: Brandon M. Music; design-review=2e5b Signed-off-by: Brandon M. Music <266531604+brandonmmusic-max@users.noreply.github.com>
e72ec0d to
90b0d31
Compare
|
Rebased onto
Validated with 36 passed, 0 failed across the 7 CPU test suites. @flare-autobot please re-review. |
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Ready To MergeRebased onto
Walkthrough
Merge Risk: Low · up to
|
Why this change is needed
External recipe entrypoints (such as
hyperflare_recipes.cli:main) bind recipe package directories throughignition.cli.main(..., source_roots=...), which stores(label, path)pairs inignition.preparation.source_identity._EXTRA_ROOTS(aContextVar). Without propagation acrossmp.get_context("spawn"), child processes start with an emptyContextVar, causing divergentForwardCacheroots (andFileNotFoundErroror cache misses onmainwhen loading rank 0's cache-relative paths, or explicit same-SKU cache-root mismatch errors when paired with unmerged PR #597).Merged PR #670 (
2acc3f3a) propagated bound source roots intoignition.preparation.rank_group._peerby importing private_EXTRA_ROOTSdirectly (matchingaot.py). Two gaps remain onmain:ignition/preparation/aot.pyandignition/preparation/rank_group.pyimport private_EXTRA_ROOTSdirectly fromsource_identity.pyinstead of using a public accessor.ignition/preparation/tuning_replicas.pyspawns local tuning replicas viamp.get_context("spawn")without bindingsource_roots. Although_replicacurrently invokesprepare(..., compile_forwards=False)and exits onTuningCompletewithout reaching an in-treeForwardCacheorsource_identity()call today, propagating bound source roots gives local tuning replicas spawn-boundary parity withrank_group._peer.What changed
Before this change,
aot.pyandrank_group.pyread_EXTRA_ROOTS.get()directly,source_identity.pyexposed no public accessor, andtuning_replicas._replicaexecuted with an emptysource_rootscontext.After this change:
ignition/preparation/source_identity.py: Addedcurrent_source_roots() -> tuple[tuple[str, Path], ...]returning_EXTRA_ROOTS.get(), and updatedsource_roots's docstring to cover active CLI and spawned worker contexts.ignition/preparation/aot.pyandignition/preparation/rank_group.py: Replaced direct_EXTRA_ROOTSimports withcurrent_source_roots(), keeping_EXTRA_ROOTSprivate tosource_identity.pyand leaving feat(helios,ignition): parameterize THINK_TAGS reasoning, add TAGGED_JSON tool parser, and propagate peer source roots #670's narrowwith bind_source_roots(...)block in_peeruntouched.ignition/preparation/tuning_replicas.py:prepare_recipecapturescurrent_source_roots()and passesextra_source_rootsas a required argument to_replica, which bindswith source_roots(extra_source_roots), CoreStorage(world=plan.world_size) as storage:around replica preparation.tests/preparation/test_forward_cache_sources.py: Switched_record_source_roots_preparetocurrent_source_roots()(retaining feat(helios,ignition): parameterize THINK_TAGS reasoning, add TAGGED_JSON tool parser, and propagate peer source roots #670's real-spawnForwardCache.rootagreement assertions between rank 0 and rank 1 against the unbound baseline), addedtest_current_source_roots_reflects_active_scope, and addedtest_prepare_recipe_propagates_source_roots_to_spawned_tuning_replicaasserting bothcurrent_source_roots()andForwardCache.rootagreement between replica 0 and spawned replica 1 against the unbound baseline.Claimed benefit and compatibility impact
_EXTRA_ROOTSbehindcurrent_source_roots(), gives spawned local tuning replicas defensive spawn-boundary parity withrank_group._peer, and adds real-spawn CPU regression coverage for bothcurrent_source_roots()andtuning_replicas.prepare_recipe.Supporting evidence and limitations
CUDA_VISIBLE_DEVICES=""):py_compileclean across all five modified Python files;git diff --checkclean;git grep _EXTRA_ROOTSconfirms zero references outsideignition/preparation/source_identity.py.pytest -v tests/preparation/test_forward_cache_sources.py tests/preparation/test_forward_cache_concurrency.py tests/preparation/test_forward_cache_root.py tests/preparation/test_core_boundary.py tests/preparation/test_native_processes.py tests/preparation/test_tuning_shards.py tests/cli/test_recipe_injection.py: 36 passed, 0 failed, 0 skipped.torch.cuda.set_device,torch.cuda.synchronize, andCoreStoragewhile exercising realmultiprocessing.get_context("spawn")serialization andsource_rootsrebinding; multi-GPU CUDA tuning-replica runs were not executed on CPU.Discord: Brandonmusic