Skip to content

fix(engram): stop allocations that leave 50 GiB or less of host RAM - #1852

Open
xingleixu123 wants to merge 3 commits into
mindspore-ai:masterfrom
xingleixu123:codex/engram-host-capacity
Open

xingleixu123 wants to merge 3 commits into
mindspore-ai:masterfrom
xingleixu123:codex/engram-host-capacity

Conversation

@xingleixu123

@xingleixu123 xingleixu123 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Paired: GitHub #1852 ↔ GitCode !2178

What type of PR is this?

/kind bug

What does this PR do / why do we need it:

Read OS-visible host RAM with psutil.virtual_memory() and sum the pending Engram shard bytes on each physical host. Before allocating weights or building the two SparseAdam moments, stop all startup ranks when a nonempty plan would leave 50 GiB or less available. Recovery checks only the replacement worker's missing weights. No configuration is required.

If a rank cannot read RAM, its shard still counts when its host is known. A peer on that host can supply the reading. An unreadable probe produces one warning per collective check. Hosts without a usable reading are skipped while other hosts remain checked. Independent container memory limits are outside the physical-host budget. The probe boundary retains its broad exception handling so every rank can still report its planned shard when a platform-specific probe fails. Pylint W0718 is locally suppressed at this boundary; the runtime behavior is unchanged.

Which issue(s) this PR fixes:

Follow-up to #1807 for issue #43680.

What scenarios were tested, and what were the verification results(Function, performance, reliability, etc.):

Area Verification Result
Original issue and boundary Original table shapes on 8 × 910B4. Separate weight, optimizer and recovery tests at the byte boundary. 2,929.77 GiB planned on a 1,509.32 GiB host. All 8 candidate ranks stopped before allocation. A projected 50 GiB + 1 byte passed. Exactly 50 GiB and 50 GiB − 1 byte stopped.
Probe failures Permission denied, unsupported or invalid readings, restricted host identity, and a failed probe on one rank The old revision stopped on a denied read. This revision warned and continued. A readable peer still caught a combined over-budget plan. Two-rank HCCL jobs on both 910B3 and 910B4 completed eight training steps with all RAM reads denied.
Placement and portability Two real hosts with Gloo ranks split 3 + 1 and HCCL ranks split 2 + 2, plus 16 Gloo processes and two sibling Docker containers Uneven and empty shards were counted per host. One over-budget host stopped the whole job. Siblings with different hostnames shared one host ID. The RAM probe matched the OS on x86-64 Linux (QEMU) and arm64 macOS.
Function and accuracy 30 existing unit and system tests. Three paired 25-step runs on 8 × 910B4 with DP2/CP2/TP2/EP2. All 30 passed. All 24 rank digests matched for outputs, sparse gradients, global norm, final weights and both moments.
Performance and device memory Three rounds of 5 warmups and 20 timed steps per revision, using the slowest of 8 ranks for each step Base → candidate median 40.75 → 40.49 ms, P95 50.57 → 49.21 ms, peak NPU allocation 32.01 → 32.01 MiB. Initial weight materialization took 4.64 → 14.39 ms. No probe ran during training steps.

Nine committed unit tests cover host-memory reporting, distributed host budgets, recovery, and the admission boundaries before weight and optimizer allocation. On Linux CPU with PyTorch 2.10.0, all 27 targeted tests passed, including 18 existing Engram and recovery tests. Additional admission regressions ran outside the source tree. Physical 910C 16-DIE hardware was unavailable.

Self-checklist:(Please check carefully,and mark an x in the [] brackets. We will review your completion status.)

  • Design: Has the solution corresponding to the PR been reviewed by the Maintainer, and have all review comments been replied to and revised
  • Test: Has the code in the PR been fully covered by UT/ST test cases, and have the newly added test cases been uploaded to the repository along with this PR or already uploaded.
  • Verification: Does the PR description contains a detailed description of the verification results regarding the achievement of the expected goals for the Feature, Refactor, and Bugfix to this PR.
  • Interface: Does it involve changes to external interfaces? The corresponding changes have been approved by the interface review organization, and the annotation information for the API has been correctly refreshed.
  • Document: Does it involve modifications to the official website documentation? If so, please submit the materials to the Doc repository in a timely manner.

@xingleixu123
xingleixu123 force-pushed the codex/engram-host-capacity branch from 6305ea8 to 2709545 Compare December 3, 2026 14:57
@xingleixu123 xingleixu123 changed the title fix(engram): check per-node host memory before allocating owner shards fix(engram): check per-host RAM before allocating weights and optimizer state Dec 3, 2026
@xingleixu123
xingleixu123 force-pushed the codex/engram-host-capacity branch from 2709545 to b964b5b Compare December 4, 2026 04:47
@xingleixu123 xingleixu123 changed the title fix(engram): check per-host RAM before allocating weights and optimizer state fix(engram): reject allocations at the projected host memory limit Dec 4, 2026
@xingleixu123 xingleixu123 changed the title fix(engram): reject allocations at the projected host memory limit fix(engram): enforce host and container memory limits before allocation Dec 4, 2026
@xingleixu123
xingleixu123 force-pushed the codex/engram-host-capacity branch from b964b5b to ed8a4a4 Compare December 4, 2026 06:19
@xingleixu123 xingleixu123 changed the title fix(engram): enforce host and container memory limits before allocation fix(engram): stop allocations at the projected host RAM limit Dec 4, 2026
@xingleixu123
xingleixu123 force-pushed the codex/engram-host-capacity branch from ed8a4a4 to a2d9ab8 Compare December 4, 2026 11:14
@xingleixu123 xingleixu123 changed the title fix(engram): stop allocations at the projected host RAM limit fix(engram): stop allocations that leave 50 GiB or less of host RAM Dec 4, 2026
@xingleixu123
xingleixu123 force-pushed the codex/engram-host-capacity branch from a2d9ab8 to 77090b7 Compare December 4, 2026 11:40
@xingleixu123

Copy link
Copy Markdown
Contributor Author

/check-pr

@xingleixu123

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

Gate trigger failed: please fix the /check-pr findings and obtain the pr-check-pass label before retrying.

@xingleixu123

Copy link
Copy Markdown
Contributor Author

/check-pr

@xingleixu123

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #2816 is running. Please wait a moment... (Link)

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ❌ FAILURE 2816
Check_Pylint FAILURE 2816

@mindspore-ai-bot

Copy link
Copy Markdown

@xingleixu123, your gate pipeline failed at the code check stage. You can configure some code check tools locally following the (pre-push quick guide), to enable automatic checking when you push your code every time. Tools included are: Check_CMakelint, Check_Codespell, Check_Cpplint, Check_Lizard, Check_Pylint, Check_ClangFormat, Check_ShellCheck.

@xingleixu123

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #2817 is running. Please wait a moment... (Link)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants