Skip to content

Pass candidate GPUs into filter_world_sizes during planning - #635

Open
nero- wants to merge 1 commit into
NVIDIA:mainfrom
nero-:fix/planning-filter-gpus
Open

nero- wants to merge 1 commit into
NVIDIA:mainfrom
nero-:fix/planning-filter-gpus

Conversation

@nero-

@nero- nero- commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Why this change is needed and why this approach

Before this change, ignition.planning.plan() called params.filter_world_sizes(world_sizes, pre_context) with pre_context.gpus == () both when computing plan_sizes and inside candidates(). Recipes whose valid tensor-parallel world sizes depend on GPU architecture—such as cross-host SM121 (GB10) RoCE tensor parallelism versus single-host SM120 PCIe collectives—could not inspect context.gpus during world-size filtering, even though fit() already populates context.gpus.

Resolving supported and chosen GPUs—and checking that explicitly selected GPUs have supported architectures—ahead of params.filter_world_sizes() exposes the same GPU metadata to world-size filtering without changing RecipeParameters signatures, introducing model-specific logic into ignition.planning, or turning an unsupported-hardware CapacityError (exit 4) into a misleading parameter UsageError (exit 2).

What changed

  • ignition/planning.py: constructed supported directly as a tuple, moved explicit --gpus bounds checks and the if not gpu.supported: CapacityError check ahead of params.filter_world_sizes(), passed replace(pre_context, gpus=filter_gpus) where filter_gpus is chosen when explicitly selected or supported otherwise, and passed replace(pre_context, root=candidate_params, gpus=filter_gpus) inside candidates(). Pre-GPU params.validate(pre_context) and out-of-range --gpus error behavior are unchanged.
  • ignition/parameters.py: documented the context.gpus and context.world_size contract on ParameterGroup.filter_world_sizes.
  • tests/cli/test_planning.py: added test_filter_world_sizes_receives_selected_or_supported_gpus (reusing _recipe() and _gpu()) covering automatic and explicit --gpus planning across SM120, SM121, and unsupported SM90 GPUs.

Claimed benefit

Recipes can gate valid tensor-parallel world sizes on GPU capability during both automatic and explicit --gpus planning while preserving CapacityError classification for unsupported hardware and backward compatibility for recipes that ignore context.gpus.

Supporting evidence and material limitations

  • CPU unit tests: CUDA_VISIBLE_DEVICES="" pytest -q tests/cli/test_planning.py tests/cli/test_commands.py tests/cli/test_parameters.py tests/cli/test_gpu_discovery.py passed (29 passed, 0 failed), exercising automatic and explicit --gpus selection across SM120, SM121, and unsupported SM90 GPUs alongside all existing CLI planning, command, parameter, and discovery tests.
  • Limitation: these unit tests run on CPU with synthetic Gpu descriptors. Live 3-node SM121 export, qualification, and flare run serving validation using this hook are provided in the companion DeepSeek V4.1 TP3 PR: Enable cross-host SM121 RoCE TP3 for DeepSeek V4.1 local-inference-lab/hyperflare-recipes#103.

Discord: nero

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 635.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. enhancement New feature or request triage:review Proposed change needs code review; this does not imply merge readiness. labels Nov 30, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The layering is right — resolving candidate GPUs before RecipeParameters.filter_world_sizes() keeps ignition.planning model-agnostic, matches the existing ParameterContext.gpus contract from fit(), and cleanly enables SM120/SM121 capability-dependent TP sizing on single- and multi-host paths. One concrete defect in the reordered prologue needs fixing: explicit --gpus forwards unsupported GPUs into filter_world_sizes() before the architecture check runs, turning a hardware CapacityError (exit 4) into a misleading parameter UsageError (exit 2).

  • Blockers: 0 · Should fix: 1 · Subtract/Simplify: 2 · Nits: 2
Walkthrough
  • ignition/planning.py:566-577: Moves supported GPU filtering and explicit --gpus index bounds checking ahead of params.filter_world_sizes(), passing replace(pre_context, gpus=filter_gpus) where filter_gpus is chosen when selected is not None and tuple(supported) otherwise.
  • ignition/planning.py:578-591: Re-enters if chosen is not None: after world-size filtering for the existing len(chosen) not in plan_sizes validation/capacity error and the if not gpu.supported: check.
  • ignition/planning.py:611-613: Passes gpus=tuple(supported) into candidate_params.filter_world_sizes(...) inside candidates() on the automatic planning path.
  • tests/cli/test_planning.py:568-596: Adds test_filter_world_sizes_receives_selected_or_supported_gpus, exercising automatic and explicit --gpus planning on synthetic 4×SM120 and 3×SM121 Gpu tuples with a CapabilityAwareParams subclass.
Merge Risk: Low · up to c2ef797
  • Touches a single CLI planning function (ignition/planning.py:565-614) used only during one-shot setup (ignition/cli/preparation.py:70, ignition/cli/serve.py:200, 422, ignition/cli/bench.py:186); no serving hot path, concurrency, memory-budget, or manifest/schema surface changes.
  • Fully backward compatible for recipes whose filter_world_sizes() ignores context.gpus (verified across both in-repo overrides at tests/cli/test_planning.py:81-85 and tests/cli/test_commands.py:55-59).
  • Risk is confined to error classification when a capability-aware recipe filters context.gpus on an explicitly selected unsupported GPU.
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings
  • ✅ Security / malicious screen: Small, transparent Python-only change in ignition/planning.py and its unit test; no I/O, deserialization, subprocess, or unsafe code introduced.
  • ✅ Charter & value fit: Keeps hardware/TP policy in recipe RecipeParameters subclasses without adding model branches or flags to core ignition, supporting the charter's SM120/SM121 single- and cross-node goals.
  • ✅ Related / duplicate / conflict check: Direct completion of the ParameterContext.gpus hook introduced in ignition: introduce compositional RecipeParameters and dynamic CLI #545; rebase-clean against main (no conflicting commits since branch point).
  • ⚠️ Tests & verification evidence: The new CPU test is well-isolated and exercises both call sites (:574 and :611-613), but no unsupported-GPU explicit --gpus case is tested, and python-cpu.yml CI should be confirmed green on the PR head before merge (live 3-node SM121 validation is disclosed as living in local-inference-lab/hyperflare-recipes#103).

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

Before this change, `ignition.planning.plan()` called
`params.filter_world_sizes(world_sizes, pre_context)` with `pre_context.gpus == ()`
both when computing `plan_sizes` and inside `candidates()`. Recipes whose valid
tensor-parallel world sizes depend on GPU architecture—such as cross-host SM121
RoCE tensor parallelism versus single-host SM120 PCIe collectives—could not
inspect `context.gpus` during world-size filtering, even though `fit()` already
populates `context.gpus`. Resolving `supported` and `chosen` GPUs—and validating
that explicitly selected GPUs have supported architectures—ahead of
`filter_world_sizes()` exposes the same GPU metadata to world-size filtering
without changing `RecipeParameters` signatures, introducing model-specific logic
into `ignition.planning`, or turning unsupported-hardware `CapacityError` (exit 4)
into a misleading parameter `UsageError` (exit 2).

In `ignition/planning.py`, built `supported` directly as a tuple, moved explicit
`--gpus` bounds checks and the `if not gpu.supported:` `CapacityError` check
ahead of `params.filter_world_sizes()`, passed `replace(pre_context,
gpus=filter_gpus)` where `filter_gpus` is `chosen` when explicitly selected or
`supported` otherwise, and passed `replace(pre_context, root=candidate_params,
gpus=filter_gpus)` inside `candidates()`. Documented the `context.gpus` and
`context.world_size` contract on `ParameterGroup.filter_world_sizes` in
`ignition/parameters.py`. Added
`test_filter_world_sizes_receives_selected_or_supported_gpus` to
`tests/cli/test_planning.py` reusing `_recipe()` and `_gpu()` to cover automatic
and explicit `--gpus` planning across SM120, SM121, and unsupported SM90 GPUs.

Recipes can now gate valid tensor-parallel world sizes on GPU capability during
both automatic and explicit `--gpus` planning while preserving hardware
`CapacityError` classification for unsupported GPUs and backward compatibility
for recipes that ignore `context.gpus`.

Validated with `CUDA_VISIBLE_DEVICES="" pytest -q tests/cli/test_planning.py
tests/cli/test_commands.py tests/cli/test_parameters.py
tests/cli/test_gpu_discovery.py` (29 passed, 0 failed), covering automatic and
explicit `--gpus` selection across SM120, SM121, and unsupported SM90 GPUs.
Limitation: these unit tests run on CPU with synthetic `Gpu` descriptors; live
3-node SM121 export and `flare run` serving validation using this hook are
provided in `local-inference-lab/hyperflare-recipes#103`.

Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
Signed-off-by: Jonathan Gutierrez <phialpha0@gmail.com>
@nero-
nero- force-pushed the fix/planning-filter-gpus branch from c2ef797 to 3c3c4df Compare November 30, 2026 11:16
@nero-

nero- commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Addressed all review items from the Autobot report:

  • Should fix: Moved the if not gpu.supported: CapacityError check ahead of params.filter_world_sizes(...) so explicitly selected unsupported GPUs always raise CapacityError (exit 4) rather than leaking into capability-gated filter_world_sizes() and triggering UsageError (exit 2), and added an explicit SM90 test case covering this path.
  • Simplify / Nits: Constructed supported directly as a tuple and reused filter_gpus in candidates(); simplified test_filter_world_sizes_receives_selected_or_supported_gpus to reuse _recipe() and _gpu() without redundant reserve_bytes=0; documented the context.gpus / context.world_size contract on ParameterGroup.filter_world_sizes.

Re-verified tests/cli/{test_planning,test_commands,test_parameters,test_gpu_discovery}.py (29 passed, 0 failed). @flare-autobot

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Ready To Merge

The Round 1 should-fix and cleanup items are cleanly addressed at head 3c3c4df; no correctness, safety, concurrency, or system-level regressions were introduced. Confirm python-cpu.yml CI is green on 3c3c4df before merging.

  • Blockers: 0 · Should fix: 0 · Subtract/Simplify: 1 · Nits: 2
Walkthrough
  • ignition/planning.py:566-577: Constructs supported directly as a tuple, resolves chosen, checks both --gpus index bounds (UsageError) and gpu.supported (CapacityError) ahead of params.filter_world_sizes(), and passes gpus=filter_gpus using chosen when selected or supported otherwise.
  • ignition/planning.py:581-591: Retains the post-filtering plan-size validation and automatic capacity check after removing the relocated gpu.supported loop.
  • ignition/planning.py:611-613: Threads gpus=filter_gpus into candidate_params.filter_world_sizes() so automatic planning and capacity-relief candidates see the same supported GPU set.
  • ignition/parameters.py:560-565: Documents the context.gpus and context.world_size contract on ParameterGroup.filter_world_sizes.
  • tests/cli/test_planning.py:568-599: Adds coverage for automatic and explicit planning on SM120, SM121, and unsupported SM90, including a guard that fails if unsupported GPUs reach filter_world_sizes().
Merge Risk: Low · up to 3c3c4df
  • Scoped to a single one-shot CLI planning function (ignition/planning.py:565-614) invoked only during setup; zero impact on serving hot paths, concurrency/locks, memory budgets, or serialized manifests/wire formats.
  • Backward compatible with recipes whose filter_world_sizes() ignores context.gpus, verified against both in-repo overrides (tests/cli/test_planning.py:81-85, tests/cli/test_commands.py:55-59).
  • Preserves CapacityError (exit 4) over UsageError (exit 2) for explicitly selected unsupported GPUs (ignition/planning.py:573-575, ignition/errors.py:13-22, ignition/cli/__init__.py:373-377).
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings
  • ✅ Security / malicious screen: Small, pure-Python change across planning, docstrings, and unit tests; no I/O, subprocesses, deserialization, or untrusted input handling added.
  • ✅ Charter & value fit: Keeps hardware/TP policy inside recipe RecipeParameters subclasses with no model-specific branches or flags in core ignition, supporting SM120/SM121 single- and cross-node serving.
  • ✅ Related / duplicate / conflict check: Cleanly extends the ParameterContext.gpus hook introduced in ignition: introduce compositional RecipeParameters and dynamic CLI #545; no competing open PR and rebase-clean on main.
  • ⚠️ Tests & verification evidence: New CPU unit test covers plan_sizes, candidates() passthrough, and the SM90 CapacityError guard, but python-cpu.yml (.github/workflows/python-cpu.yml:30-33 (not opened)) should be confirmed green on 3c3c4df; live 3-node SM121 validation lives in external companion PR local-inference-lab/hyperflare-recipes#103.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. enhancement New feature or request triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants