Skip to content

fix(pd): raise the RLIMIT_MEMLOCK soft limit to the hard limit at server start - #3725

Open
Jasen2201 wants to merge 1 commit into
mainfrom
Jasen/raise-memlock-soft-limit
Open

Jasen2201 wants to merge 1 commit into
mainfrom
Jasen/raise-memlock-soft-limit

Conversation

@Jasen2201

Copy link
Copy Markdown
Collaborator

Ready for review. No blocking issues; the SemiAnalysis validation run is pending.

Why

On the SemiAnalysis MI355X cluster, Slurm starts job steps with an 8 MiB RLIMIT_MEMLOCK soft limit, and the container's root has no CAP_IPC_LOCK. Every Mooncake KV registration of an ATOM P/D worker then fails with ENOMEM at startup, which has failed every P/D eval of SemiAnalysisAI/InferenceX#5120 since 2026-11-20.

What changed

  • The server raises the RLIMIT_MEMLOCK soft limit to the hard limit before it spawns the engine processes, which inherit it: raise_memlock_limit in atom.utils, called next to set_ulimit in atom.entrypoints.openai_server.

Review focus

  • Placement: only atom.entrypoints.openai_server calls it. Every launch script, recipe and doc in the repo starts ATOM through that module.

Testing

The unit test pins the raise and the no-op cases. A GPU run on an MI355X node with ionic NICs reproduces the ENOMEM at that soft limit and registers after the raise.

Jasen/raise-memlock-soft-limit @ 7dd01351a: tests/test_raise_memlock_limit.py 4 passed. ruff, black clean.

Follow-ups

Dev record
  • Found: ionic's peer-memory registration first tries the host-memory ib_umem_get, which charges RLIMIT_MEMLOCK before it pins. Only -EFAULT falls through to the GPU peer path, so the limit check's ENOMEM is returned as is. peermem/peer_umem.c is identical in ionic-dkms 25.08.4.004 and 26.08.17.001.
  • Found: before 2026-11-20 the cluster's soft limit was 4,072,153,088 B. It failed only part of Mooncake's concurrent batch registration, and ATOM's sequential fallback registered the rest.
  • Decided: raise soft to hard in-process, which needs no privilege, at the entrypoint, so every RDMA path (Mooncake KV, Mooncake Store client, MoRI-IO) inherits it. The vLLM and SGLang Mooncake recipes on that cluster do the same in a setup script.
  • Surprised: with CAP_IPC_LOCK the limit is not checked, so privileged CI containers never hit this. The image's ionic verbs provider supports kernel ABI 4 only, so hosts with ABI 1 drivers need the host's provider mounted, as pd_slurm_job.sh does.
  • Left undone: the Dockerfile comment that says the provider supports ABI 1 to 4.
Evidence

MI355X node, ionic-dkms 26.03.3.001, image rocm/atom-dev:nightly_202611200431 with the host's ionic provider mounted, non-privileged container with --ulimit memlock=8388608:-1, MOONCAKE_DISABLE_HIP_DMABUF=1, a 1 GiB GPU buffer on rdma0:

CAP_IPC_LOCK=no memlock soft=8388608 hard=-1
Failed to register memory 0x7a623fe00000 length 1073741824 dmabuf_offset 0 on rdma0 MC_RDMA_DATA_DIRECT=0: Cannot allocate memory [12]
BEFORE raise: register_memory(1073741824) -> -202
atom INFO Raised RLIMIT_MEMLOCK soft limit 8388608 -> -1
AFTER raise: register_memory(1073741824) -> 0
spawned child inherits memlock soft=-1 hard=-1

With --cap-add IPC_LOCK the same registration returns 0 before the raise.

Cluster limits, read from the SGLang P/D setup script's log on the same two nodes: RLIMIT_MEMLOCK of pid N: soft 4072153088 -> -1 on 2026-11-19, soft 8388608 -> -1 on 2026-11-21. Since 2026-11-20 every ATOM P/D eval log there shows each KV chunk failing with Cannot allocate memory [12], then Mooncake register_memory failed.

🤖 Generated with Claude Code

…ver start

A GPU ibv_reg_mr is charged against RLIMIT_MEMLOCK before the RDMA driver
falls back to peer memory, so in a container without CAP_IPC_LOCK a soft
limit below one KV chunk fails every Mooncake KV registration with ENOMEM.
On the SemiAnalysis MI355X cluster Slurm sets that soft limit to 8 MiB (hard
unlimited), which failed every ATOM P/D eval there. The server now raises the
soft limit to the hard limit before it spawns the engine processes, which
inherit it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 05:01
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every eligible PR before approval:

  • ✅ Pre Checkin: Black, Ruff, catalog schema validation, non-GPU unit tests

Heavy model tests:

  • ✅ Gate checks are published on every PR so required checks do not stay missing
  • ✅ Expensive jobs run only after the PR is approved, or when a matching ci:* label is present
  • ✅ Pre Checkin must pass before approved heavy jobs continue
  • ✅ Without a matching label, expensive jobs also require a relevant path
  • ✅ A matching ci:* label is an explicit request and can open the gate even when paths would otherwise skip it

Path scope:

  • Native ATOM, vLLM, and SGLang use ignore lists: docs/markdown and unrelated plugin or Mesh paths are skipped
  • ATOMesh uses an include list: Mesh code, ATOMesh scripts/workflows/catalogs, OpenAI entrypoints, and Slurm helpers
  • Relevant path alone does not start expensive jobs; approval still opens the automatic path-scoped gate
Label Tests
ci:full Run all heavy PR model tests: native ATOM, vLLM, SGLang, and ATOMesh
ci:atom Run native ATOM model accuracy tests
ci:vllm Run ATOM vLLM OOT model accuracy tests
ci:sglang Run ATOM SGLang model accuracy tests
ci:mesh Run ATOMesh accuracy/benchmark gates for Mesh-related changes

Without a matching ci:* label, heavy jobs are skipped when the path is not relevant or the PR is not approved.
Add labels via the sidebar or gh pr edit 3725 --add-label <label>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the memlock-limit startup change.

No open issues 🎉

What changed in this PR

This PR addresses RDMA memory-registration failures in ATOM prefill/decode workers by raising the server’s RLIMIT_MEMLOCK soft limit to its hard limit before spawning engine processes.

Changes:

  • Adds a helper that raises the limit, skips changes when already equal, and warns if the raise fails.
  • Calls the helper at server startup so spawned workers inherit the limit.
  • Adds unit tests for finite and unlimited hard limits, the no-op case, and failure handling.
File Description
tests/​test_raise_memlock_limit.py Tests limit raising, no-op behavior, and warning handling.
atom/​utils/​__init__.py Adds the raise_memlock_limit utility.
atom/​entrypoints/​openai_server.py Raises the memlock limit before starting the server.

Review effort: Balanced

@valar-cop valar-cop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some changes needed..

e2e GLM-5.2 1P1D C112 eval on MI355X with the fix image?

ci green.

Comment thread atom/utils/__init__.py
if soft == hard:
return
try:
resource.setrlimit(resource.RLIMIT_MEMLOCK, (hard, hard))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this raise is process-wide, so engram mlock2 also flips from refused to granted now. intended? if so please note it in docs..

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants