Add automatic full-card PTA OOM injection (no PTA recovery) - #5
Draft
yjyang62 wants to merge 11 commits into
Draft
Add automatic full-card PTA OOM injection (no PTA recovery)#5yjyang62 wants to merge 11 commits into
yjyang62 wants to merge 11 commits into
Conversation
Provide a single top-level OutOfMemoryError injection point for workloads such as Qwen 235B that bypass C++ allocator and HCCL hooks. Controlled via NPU_INJECT_OOM_STEP and a call at the top of each inference iteration. Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
cursor
Bot
force-pushed
the
cursor/guaranteed-pta-oom-c058
branch
from
June 24, 2026 04:00
795edcf to
64b229b
Compare
Remove Python inject_oom API. Introduce maybeThrowPtaOom() controlled by PTA_OOM_TRIGGER_COUNT (default 6000), called from MakeSureQueueEmpty (async queue drain, where OOM propagates upward) and malloc() entry. Skips graph capture. Raises torch.OutOfMemoryError with PTA memory fault code. Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
On trigger, mark all allocator blocks on the device unsafe and enable unsafe-data checking before throwing OutOfMemoryError. Reset inject state on restart_device and clear unsafe check flag after recovery. Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
Drop resetPtaOomInjectState, restart_device reset call, and unsafe-flag clearing. Keep full-card OOM fault injection only; recovery is handled externally by MindIE. Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
Avoid injecting full-card OOM during model warmup; aligns with prior malloc counter tuning for large models like Qwen 235B. Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
cursor
Bot
force-pushed
the
cursor/guaranteed-pta-oom-c058
branch
from
June 24, 2026 08:52
adc18d3 to
4ab4cee
Compare
Record progress in InnerRunOpApi, ExecFunc, ExecFuncOpApi, and AclmdlRIExecuteAsync so prefill static-graph inference increments the counter. Defer throw to malloc/MakeSureQueueEmpty via pending flag. Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
TorchAir GE static graph bypasses OpCommand during prefill body; hook AclrtSynchronizeStreamWithTimeout and npuSynchronizeDevice so each prefill forward completion increments and can throw OOM on MindIE path. Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
Add PTA_OOM_INJECT=1 for immediate full-card OOM on first forward boundary (stream/device/event sync, queue drain, memcpy). Add PTA_OOM_FORWARD_SYNC_TRIGGER_COUNT (default 10) separate from the 400k op counter so Qwen GE prefill can trigger without per-op PTA paths. Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
When PTA_OOM_TRIGGER_COUNT=0 (P instance config), route malloc/queue/op hooks to the forward-boundary counter instead of no-op. Add PTA_OOM_SKIP_WARMUP_COUNT, PTA_OOM_DEBUG, route stream sync through hooked AclrtSynchronizeStreamWithTimeout, and hook D2H memcpy plus allocator event sync as additional P prefill boundaries. Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
Support PTA_OOM_TRIGGER_AFTER_SECONDS, PTA_OOM_TRIGGER_AFTER_MINUTES, and PTA_OOM_TIMER=1 (default 6 minutes). Timer starts at PTA load and throws full-card OOM on the next hook after the deadline. Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
Delete PTA_OOM_TRIGGER_COUNT, forward sync counter, warmup skip, and PTA_OOM_INJECT. All hooks now call maybeThrowPtaOom which only checks the timer (PTA_OOM_TRIGGER_AFTER_SECONDS/MINUTES or PTA_OOM_TIMER=1). Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
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.
Summary
Simplified PTA OOM injection to timer-only. All count-based logic removed.
Configuration
PTA_OOM_TRIGGER_AFTER_MINUTES=6PTA_OOM_TRIGGER_AFTER_SECONDS=360PTA_OOM_TIMER=1PTA_OOM_DEBUG=1No env set = injection disabled (no behavior change).
Behavior
.soloadsmalloc, sync, op, memcpy, etc.) throws full-cardOutOfMemoryErrorRemoved
PTA_OOM_TRIGGER_COUNTPTA_OOM_FORWARD_SYNC_TRIGGER_COUNTPTA_OOM_SKIP_WARMUP_COUNTPTA_OOM_INJECTrecordPtaOomProgress()/maybeThrowPtaOomOnForwardBoundary()APIs