Repository navigation
[Bugfix][TE] Register direct ACL VMM fabric memory as device - #4286
Merged
ascend-direct-dev merged 1 commit intoSep 23, 2026
Merged
ascend-direct-dev merged 1 commit into
ascend-direct-dev merged 1 commit into
Conversation
csxxs
requested review from
XucSh,
YiXR,
alogfans,
ascend-direct-dev,
chestnut-Q,
doujiang24,
staryxchen,
stmatengss and
ykwd
as code owners
September 23, 2026 01:33
ascend-direct-dev
marked this pull request as draft
September 23, 2026 01:37
Fabric memory mode must not register every fabric buffer as device memory. Only the allocations that bypass adxl::MallocMem - the direct ACL VMM allocations made by ascend_allocator - need MEM_DEVICE registration, because ADXL does not know about them and reads their VA back as HOST. Allocations made through adxl::MallocMem stay MEM_HOST and keep using ADXL's own host-memory export path. Changes: - Record the allocation size in the VMM allocation table and look an address back up in it: ascend_is_direct_vmm_memory() only matches records flagged as direct allocations, so adxl::MallocMem records never match. It matches on the start address only, because a caller may register a longer range than was allocated and requiring full containment would silently keep that buffer as MEM_HOST. - AscendDirectTransport::registerLocalMemory() overrides mem_type to MEM_DEVICE when this TE is fabric enabled and the buffer is a direct VMM allocation. - Grant the current device read/write access after aclrtMapMem in the direct VMM path, and roll back unmap/release/free if the grant fails. Host pages are only bound to the host by aclrtMapMem, so the NPU needs this explicit grant before SDMA can reach them; adxl::MallocMem does the same for its own allocations. Co-authored-by: Cursor <[email protected]>
csxxs
force-pushed
the
fix/ascend-direct-vmm-register-device
branch
from
September 23, 2026 01:40
9041064 to
2e21aa5
Compare
ascend-direct-dev
marked this pull request as ready for review
September 23, 2026 03:49
ascend-direct-dev
enabled auto-merge (squash)
September 23, 2026 03:50
ascend-direct-dev
disabled auto-merge
September 23, 2026 03:50
ascend-direct-dev
enabled auto-merge (squash)
September 23, 2026 03:50
alogfans
approved these changes
Sep 23, 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.
Description
Fixes the memory type used when registering fabric memory, so that fabric memory mode no longer registers every fabric buffer as device memory. Only the buffers that bypass
adxl::MallocMem- the direct ACL VMM allocations made byascend_allocator- are looked back up at registration time and registered asMemType::Device; allocations made throughadxl::MallocMemkeep usingMemType::Host.Background: the VA of a direct ACL VMM allocation is reported by
aclrtPointerGetAttributes()as HOST / HOST_NUMA, so it was classified asMEM_HOST. With the buffer pool enabled,registerMemskipsMEM_HOSTbuffers entirely, and the fabric transfer path does not fall back to a local copy, so D2H/H2D transfers fail. An earlier revision registered everything asMEM_DEVICEwheneveruse_fabric_mem_was set, which also changed allocations that ADXL owns and exports through its own host-memory path. This PR instead distinguishes allocations by their origin.Changes:
ascend_allocator: the allocation table (AllocRecord) now records the allocation size, and a newascend_is_direct_vmm_memory()looks an address back up in it. The lookup only matches records flagged as direct allocations, so buffers returned byadxl::MallocMem(recorded withis_direct_alloc == false) can never match. Both insertion points ofAllocRecordrecord the length.AscendDirectTransport::registerLocalMemory(): when this TE is a fabric TE and the buffer is a direct VMM allocation,mem_typeis overridden toadxl::MEM_DEVICE. The override is one-way (Host -> Device), so explicitly device memory such aslocation="npu"is unaffected. The gate isuse_fabric_mem_(this TE's own fabric flag) rather than the process-wide config, so a co-located non-fabric TE is not affected.ascend_allocator: the direct VMM path now callsaclrtMemSetAccessafteraclrtMapMem, granting the current device read/write access, and rolls back withUnmap + ReleaseMemAddress + FreePhysicalif the grant fails.aclrtMapMemonly binds the pages to the host, so the NPU needs this explicit grant;adxl::MallocMemdoes the same for its own allocations.Per request, this PR contains no unit test changes.
Module
mooncake-transfer-engine)mooncake-store)mooncake-conductor)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
Built and ran the Ascend transport unit tests on an aarch64 Linux VM with
-DUSE_ASCEND_DIRECT=ON.Test commands:
cmake -DUSE_ASCEND_DIRECT=ON .. make mooncake_store transfer_engine ascend_transport make ascend_direct_transport_test && ./ascend_direct_transport_test ./scripts/code_format.shTest results:
ascend_direct_transport_test: 79 tests passed)There is no NPU on this host, so verification covers compilation, the unit test suite, and
code_formatonly. End-to-end fabric D2H/H2D transfers on real hardware, plus theRegisterMemreturn value, still need a run on an A3 machine.Checklist
./scripts/code_format.shNotes for reviewers
align_down_1gor a percentile step down) can return less. Requiring full containment would silently keep that buffer asMEM_HOST, which is exactly the bug this PR fixes, so the lookup would not take effect on the store segment path.split_limitset,real_client.cppmountssegment_sizeeven whenmapped_sizeis smaller, so the capacity reported to the master can exceed the memory that was actually mapped (mapped_size < segment_size). Worth a separate look; it is not touched here.location.idforaclrtMemSetAccessmust be a driver logical id whileaclrtGetDevicereturns a user id. The conversion follows the existing code inshared_segment/ascend_shared_segment.cpp. Deployments that expose only a subset throughASCEND_RT_VISIBLE_DEVICESare worth a confirmation on real hardware.ascend_direct_transport_test.cppimplements its own set of ACL stubs, and the two calls added here (aclrtGetLogicDevIdByUserDevId,aclrtMemSetAccess) are not stubbed. Per request this PR does not touch test files; if needed later, the stubs areaclrtGetLogicDevIdByUserDevIdwriting back its argument andaclrtMemSetAccessreturningACL_ERROR_NONE.aclrtReserveMemAddressstub returns amalloc(64)pointer rather than a real ACL VMM address. On a machine without an NPU these two real library calls "succeed" spuriously (measured:aclrtGetLogicDevIdByUserDevId(0) == 0andaclrtMemSetAccess(malloc_ptr) == 0), which is why all 79 tests pass here. On an A3 machine with an NPU,aclrtMemSetAccesswill likely reject that non-ACL address, the grant returns -1, allocation returns nullptr, andAgentModeAllocTest.DirectVmmDoesNotRotateSequencerplusFabricMemBestEffortAllocTest.*would fail.BUILD_UNIT_TESTS=OFF, so CI will not surface this.AI Assistance Disclosure
The changes were written with AI assistance and reviewed; the submitter is responsible for the content.