Repository navigation
fix(npu): disable XRT's residency controller so NPU buffers stay resi… - #1221
Merged
Merged
Conversation
…dent On aie2p Windows (driver ...4480), qwen3.6-moe's weights show up as system memory while the model loads and only become NPU memory at the first request. The MCDM XRT shim (XRT-MCDM src/umd/shim) makes every BO resident when it is allocated (alloc_bo_type -> D3DKMTMakeResident, CantTrimFurther). Its residency controller, on by default since XRT-MCDM 7710e2a9 (2025-12), registers for Windows trim notifications. On a trim it evicts the BOs of every command not run since the last trim, including BOs created resident whose command never ran, and makes them resident again at the next submit. qwen3.6-moe builds its layer runs before its weights load, so a trim during the long load pushes the weight BOs back to system memory until the first request. flm now sets Runtime.disable_residency_controller=true in open_npu_device(), before the shared NPU device opens and before any BO is allocated, in every Windows XRT build, with or without corelib. BOs then keep the residency they get at allocation. ryzenai-corelib sets the same value. If XRT has already read the key, flm warns. Trade-off: XRT no longer releases idle NPU buffers under system memory pressure; a loaded model's weights stay resident for the model's life. Co-Authored-By: Claude <noreply@anthropic.com>
Security scan found no critical or high findings on lines changed by this pull requestView the security scan run for complete reports. “New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta. |
tawei-amd
self-requested a review
December 2, 2026 16:59
Collaborator
|
@alfxu-amd tested on a lab machine. worked and safe to merge |
zaneni6
approved these changes
Dec 3, 2026
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.
On any internal machines, the XRT driver has enabled residency controller, which means under memory pressure, it will release the bo buffer (make it system memory) and only make it a bo buffer again once a command is using it. That slows down the flm and may also crash the npu runlist.
This PR fix it by manually set the disable_residency_controller as true.
For platforms that are not able to run new build, before run flm, do:
Then run flm, and the problem can be solved.