Repository navigation
[MiniMax-M3.1] Step watchdog and GPU guard for Mono decode stalls - #3724
Draft
ganyi1996ppo wants to merge 1 commit into
Draft
ganyi1996ppo wants to merge 1 commit into
ganyi1996ppo wants to merge 1 commit into
Conversation
A Mono decode kernel holds every CU of its GPU and its CTAs spin on the TP peers, so any other kernel that needs a CU on one TP GPU can stall the whole step until the GPU's queues are remapped. - atom/utils/gpu_guard.py: poll KFD sysfs for processes on the server's GPUs that were not there at start; while one is present (and for a short hold-off after it leaves) the engine keeps decode off Mono, and runs a step eagerly when a Mono-captured graph could replay it. - EngineCore: every model forward goes through _timed_forward, which hands the guard's verdict to the batch and lets a step watchdog report a forward running past 5 s with its kind (prefill / mixed / decode), the processes on the GPUs that are not the server's own, and a count of long forwards. - MonoDecode: set_blocked() and the set of token counts captured with Mono. Liveness only; numerics unchanged.
Contributor
🏷️ CI GuideRuns automatically on every eligible PR before approval:
Heavy model tests:
Path scope:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Mono decode kernels are persistent: one CTA per CU, each holding the CU's whole LDS, spinning on each other and on the TP peers' mailbox pushes. Any other kernel that needs LDS on one CU of one TP GPU can keep a Mono CTA from launching, and then every rank spins until that kernel leaves. See #3369 (mailbox polling stalls next to concurrent copy kernels; the backoff in #3350 is a mitigation, the root cause is open).
One source of such kernels is another process on the same TP GPUs (e.g. a second server on double-leased GPUs). In a c8 benchmark run the engine thread sat blocked in one forward for ~212 s with no log line. This PR is a robustness and diagnostics change, not a speedup.
Change
atom/utils/gpu_guard.py(new):GpuGuardpolls/sys/class/kfd/kfd/proc/*/vram_<gpu_id>(readable inside a container) for processes on the server's GPUs that were not there at engine start. While one is present, and for 5 s after the last one leaves (so a periodic neighbour does not flip steps between Mono and eager),EngineCoremarks the batchmono_blocked(decided once on the engine, so all TP ranks agree) and decode stays off Mono; the runner runs such a step eagerly when a Mono-captured graph could replay it. The watched GPUs followROCR_VISIBLE_DEVICES/HIP_VISIBLE_DEVICES(elseCUDA_VISIBLE_DEVICES); entries that are not indices, an empty list, or an unset variable (every GPU of the host is watched) are logged. On a host without KFD sysfs the guard sees nothing and says so.EngineCore._timed_forward: every model forward (main loop, PP stages, decode-side engine) goes through it. It setsmono_blockedand publishes the step to a watchdog thread. A forward running past 5 s is logged with its kind (prefill / mixed / decode, "Mono off" when the guard blocked it) and the processes on the GPUs that are not the server's own; when it ends, the log reports how long it ran and counts long forwards per kind. Mono kernels only run in decode-only steps, so a long prefill or mixed forward is not read as a Mono stall.MonoDecode:set_blocked()and the set of token counts captured with Mono, which the runner uses to decide when a blocked step must run eagerly.No new environment variables. The thresholds (5 s watchdog, 5 s hold-off, 0.2 s guard poll) are constants in
gpu_guard.py.Evidence
EngineCore/PPEngineCoreProc/MonoDecodestand-in (59 files) give the same results asmain. Tests:tests/test_gpu_guard.py(fake KFD tree: GPU mapping, ROCR/UUID handling, newcomer reported then cleared, hold-off, other servers' GPUs not watched) andtests/test_step_watchdog_kind.py(step naming,_mono_blocked_step; skipped without torch).Reproduce:
python -m pytest tests/test_gpu_guard.py tests/test_step_watchdog_kind.py.Numerics
Bit-identical when no foreign process is present: no kernel or tensor-value code is touched. While the guard blocks Mono, a step runs the model's existing non-Mono path, which is not bit-identical to the Mono kernels (fp32-order class, not verified on GPU); which steps those are depends on foreign-process timing. No GSM8K gate is claimed.
Notes for review
With none of
ROCR_/HIP_/CUDA_VISIBLE_DEVICESset the guard watches every GPU of the host and says so; a sibling engine process that opens a GPU after this one started counts as foreign and keeps Mono off. Set the variable (as the launchers do) for a multi-server host.The guard thread and the watchdog start in every
EngineCore(all models); the guard only changes routing for a model with Mono hooks. A guard poll that raises is logged and retried.The watchdog logs at ERROR for any forward over 5 s, including long prefills.
Applies to every model: the guard and watchdog live in
EngineCore. For a model without Mono the guard has no effect on routing (the runner only acts on a model exposing the Mono hooks); the watchdog only logs.Own processes are those on the GPUs when the engine finished starting; a process of this server that opens a watched GPU later (e.g. a profiler) counts as foreign. Host PIDs from KFD cannot be matched to the container's process tree, so descendants are not tracked.
Out of scope: a decision made mid-forward (a process arriving during a step affects the next step), and DP idle-rank dummy forwards that bypass
_timed_forward.🤖 Generated with Claude Code