Skip to content

fix(ignition): forward recipe b12x_environment to multi-host peer ranks - #675

Closed
Reederey87 wants to merge 1 commit into
NVIDIA:mainfrom
Reederey87:fix/multi-host-b12x-environment
Closed

Reederey87 wants to merge 1 commit into
NVIDIA:mainfrom
Reederey87:fix/multi-host-b12x-environment

Conversation

@Reederey87

Copy link
Copy Markdown

Why this change is needed

During multi-host preparation (ignition export --ranks and ignition debug-serve --ranks paired with ignition join), rank zero applies plan.recipe.b12x_environment via environment.apply in ignition/cli/serve.py. Remote peer ranks running join call environment.apply(configuration, (gpu,)) with an empty b12x mapping before calling knock(). Because environment.apply invokes runtime_patches.apply(), which imports b12x.preparation through workers.register_hooks(), recipe-declared B12X_* settings (such as B12X_W4A16_A4_PREFILL=1 in glm53 or B12X_W4A16_SMALL_M_HOST_BARRIER_RESET=0 in kimi3/kimi31) never reach remote peer ranks unless operators export them manually on every worker host. As a result, rank zero and remote ranks prepare and export with asymmetric b12x settings.

What changed

  • ignition/preparation/host_ranks.py
    • Added _validate_b12x_environment enforcing the same B12X_* key prefix and str value invariant as Recipe.__post_init__ (ignition/declaration.py).
    • Added an optional b12x_environment=() parameter to HostRendezvous.__init__ (validated before binding the listening socket) and included "b12x_environment" in the control-channel admission JSON reply in HostRendezvous._admit.
    • Updated knock to validate reply.get("b12x_environment", {}) (closing the control socket without opening an executor connection on rejection) and return (control, executor, b12x_environment).
  • ignition/cli/serve.py
    • Passed b12x_environment=model.recipe.b12x_environment to HostRendezvous in both _export_hosts and debug_serve.
    • Reordered join to compute source_identity() and complete knock(...) before calling environment.apply(configuration, (gpu,), b12x_environment)—matching rank zero's ordering—and closing both sockets if environment.apply raises.
  • tests/preparation/test_host_ranks.py
    • Added unit tests exercising multi-rank forwarding, pre-bind rejection of invalid mappings, peer-side rejection and socket cleanup on malformed replies, join applying received B12X_* variables before runtime_patches.apply() and serve_peer(), and socket cleanup on environment.apply failure.

Claimed benefit

Multi-host preparation and export sessions propagate recipe-declared b12x_environment settings to every peer rank before PyTorch, Triton, or b12x is imported, matching single-host rank inheritance with no manual per-host environment configuration and no new CLI flags.

Supporting evidence and limitations

  • Tested: Ran CUDA_VISIBLE_DEVICES="" pytest tests/cli tests/preparation/test_host_ranks.py tests/preparation/test_checkpoint_source.py on Linux aarch64 with flare_heliopause and protoc: 195 passed, 0 failed.
  • Scope: Unit tests run over real loopback TCP sockets through HostRendezvous, knock, and ignition.cli.serve.join, verifying both happy-path ordering and rejection without partial mutation or leaked sockets.
  • Limitations: Live multi-host CUDA export (FLARE_RUN_TP_CUDA_TESTS=1) was not re-executed on this commit.

Discord: no username provided

Why this change is needed:
Multi-host preparation (`ignition export --ranks` and `ignition debug-serve --ranks`
paired with `ignition join`) applies `plan.recipe.b12x_environment` on rank zero in
`ignition/cli/serve.py`, whereas remote peers running `join` call
`environment.apply(configuration, (gpu,))` with an empty b12x mapping before
contacting rank zero. `environment.apply` invokes `runtime_patches.apply()`, which
imports `b12x.preparation` through `workers.register_hooks()`, so recipe-declared
`B12X_*` settings (such as `B12X_W4A16_A4_PREFILL=1` on `glm53` or
`B12X_W4A16_SMALL_M_HOST_BARRIER_RESET=0` on `kimi3`/`kimi31`) never reach remote
ranks unless manually exported on every peer host. On multi-host tensor-parallel
exports this causes rank zero and remote ranks to prepare with asymmetric b12x
environment settings.

What changed:
- `ignition/preparation/host_ranks.py`:
  - Added `_validate_b12x_environment` enforcing the same `B12X_*` string-value
    contract as `Recipe.__post_init__` (`ignition/declaration.py`).
  - Added an optional `b12x_environment=()` parameter to `HostRendezvous.__init__`,
    validated before binding the listening socket, and included
    `"b12x_environment"` in the control-channel admission JSON reply in
    `HostRendezvous._admit`.
  - Updated `knock` to validate `reply.get("b12x_environment", {})` (closing the
    control socket without opening an executor connection on rejection) and return
    `(control, executor, b12x_environment)`.
- `ignition/cli/serve.py`:
  - Passed `b12x_environment=model.recipe.b12x_environment` into `HostRendezvous` in
    both `_export_hosts` and `debug_serve`.
  - Reordered `join` to compute `source_identity()` and call `knock(...)` before
    calling `environment.apply(configuration, (gpu,), b12x_environment)`—matching
    rank zero's ordering—and closing both sockets if `environment.apply` raises.
- `tests/preparation/test_host_ranks.py`:
  - Added tests covering multi-rank propagation, pre-bind rejection of invalid
    settings, peer-side rejection and socket cleanup on malformed replies, `join`
    applying received `B12X_*` variables before `runtime_patches.apply()` and
    `serve_peer()`, and socket cleanup when `environment.apply` fails.

Claimed benefit:
Every rank in a multi-host preparation or export session receives and applies the
recipe's declared `b12x_environment` before PyTorch, Triton, or `b12x` is imported,
matching single-host rank inheritance without manual per-host environment variables
or new CLI flags.

Evidence and limitations:
- Ran `pytest tests/cli tests/preparation/test_host_ranks.py tests/preparation/test_checkpoint_source.py`
  on Linux aarch64 with `flare_heliopause` and `protoc` (`CUDA_VISIBLE_DEVICES=""`):
  195 passed, 0 failed.
- Limitations: Live multi-host CUDA export (`FLARE_RUN_TP_CUDA_TESTS=1`) was not
  re-executed on this commit; CPU tests exercise the real `HostRendezvous`, `knock`,
  and `ignition.cli.serve.join` entry points over loopback sockets with stubbed GPU
  discovery and `serve_peer`.

Design-Signed-Off-By: Artem Matskevych; design-review=2e5b
Signed-off-by: Artem Matskevych <52060443+Reederey87@users.noreply.github.com>
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 675.
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

Copy link
Copy Markdown
Collaborator

Review Stopped

Auto-Review halted due to finding: Another open pull request already covers this change, or more of it.
Value Proposition Report

@flare-autobot flare-autobot added area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. bug Something isn't working duplicate This issue or pull request already exists performance Performance, latency, throughput, or memory-efficiency investigation or improvement. priority:P2 Normal bug priority: workflow failure or diagnosis with narrower impact or an available workaround. triage:review Proposed change needs code review; this does not imply merge readiness. labels Dec 2, 2026
@Reederey87

Copy link
Copy Markdown
Author

Closing as superseded by #668, which covers multi-host b12x_environment propagation alongside reconcile_selections, peer kernel_cache remapping, and ForwardCache hardening. Left a note and 2× DGX Spark GLM-5.3 TP2 confirmation on #668.

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. bug Something isn't working duplicate This issue or pull request already exists performance Performance, latency, throughput, or memory-efficiency investigation or improvement. priority:P2 Normal bug priority: workflow failure or diagnosis with narrower impact or an available workaround. 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