Skip to content

fix(qwen): default PTO2_RING_HEAP to 512MB so a plain Qwen3-14B launch doesn't deadlock - #106

Open
lterrac wants to merge 1 commit into
hw-native-sys:mainfrom
lterrac:fix/qwen-ring-heap-default
Open

fix(qwen): default PTO2_RING_HEAP to 512MB so a plain Qwen3-14B launch doesn't deadlock#106
lterrac wants to merge 1 commit into
hw-native-sys:mainfrom
lterrac:fix/qwen-ring-heap-default

Conversation

@lterrac

@lterrac lterrac commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

A plain pypto-serving ... --model Qwen3-14B (the exact command in the README)
fails to start: the warmup prefill at the default --max-num-batched-tokens 4096 overflows the PTO2 ring-task heap, which defaults to 256MB in the runtime,
and startup aborts with HEAP_RING_DEADLOCK (surfaced as
ACL_ERROR_RT_AICPU_EXCEPTION / code 507018).

This sets a working default so Qwen3-14B launches out of the box, and documents
the knob.

Change

  • Qwen314BPyptoExecutor.__init__ does os.environ.setdefault("PTO2_RING_HEAP", 512MB) before any worker is created. It's a setdefault, so an explicit
    PTO2_RING_HEAP from the caller still wins; it's in the executor, so both the
    serving and offline (npu_generate.py) paths get it.
  • README: note that Qwen3-14B raises the ring heap to 512MB automatically and
    how to override it.

512MB is the smallest size that clears the warmup on a 14B (256MB deadlocks).

Verified

Launched Qwen3-14B without any PTO2_RING_HEAP in the environment:

  • startup reaches Application startup complete, no HEAP_RING_DEADLOCK
  • memory breakdown shows the arena at 2.28 GB (512MB x 4 + overhead), confirming
    the 512MB default took effect (256MB would be ~1.1 GB)
  • "Once upon a time"", there was a young girl named Lily"

Notes

  • Qwen3-14B only (the executor is model-specific); DeepSeek path untouched.
  • Independent of the staging / kernel-cache PRs.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 83a3f140-04ec-4702-b88f-1dad9e963a64

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Qwen3-14B now defaults PTO2_RING_HEAP to 512MB before worker creation, preserves existing environment overrides, and documents the runtime behavior and manual override option.

Changes

Qwen3-14B runtime heap

Layer / File(s) Summary
Configure and document the Qwen3-14B heap default
pypto_serving/model/qwen/npu_executor.py, README.md
Defines a 512MB heap default, applies it without overriding an existing environment value, and documents the warmup behavior and PTO2_RING_HEAP override.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit saw the heap grow wide,
Five hundred twelve megabytes beside.
Warmup hops without a fright,
Deadlocks vanish out of sight.
Set your own size if you decide!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the Qwen3-14B heap default change and the deadlock fix.
Description check ✅ Passed The description accurately describes the heap default, override behavior, and README update.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request automatically configures the PTO2_RING_HEAP environment variable to 512MB for Qwen3-14B to prevent HEAP_RING_DEADLOCK during warmup, and documents this behavior in the README. The feedback suggests setting this environment variable before calling super().__init__ in the constructor to ensure that any initialization logic in the base class correctly inherits the setting.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pypto_serving/model/qwen/npu_executor.py Outdated
@lterrac
lterrac force-pushed the fix/qwen-ring-heap-default branch from 78a4b1d to 35366d2 Compare July 21, 2026 10:33
…deadlock

The Qwen3-14B warmup (default --max-num-batched-tokens 4096) overflows the PTO2
ring-task heap at its 256MB runtime default and aborts startup with
HEAP_RING_DEADLOCK (surfaced as ACL_ERROR_RT_AICPU_EXCEPTION / code 507018).

Set a 512MB default in the Qwen3-14B executor before any worker is created (the
PTO2_RING_HEAP env var still overrides), and document it in the README, so
serving and offline launches work without the caller knowing this knob.
@lterrac
lterrac force-pushed the fix/qwen-ring-heap-default branch from 35366d2 to a5b19df Compare July 21, 2026 12:33
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.

1 participant