Resolve host-orchestrator tensor access through a host view - #1651
Conversation
host_build_graph's orchestrator runs on the host, where `Tensor::buffer.addr` is a device address. get_tensor_data / set_tensor_data dereferenced it directly, which is only valid because a2a3 maps device buffers into the host address space and returns an identity VA. That made a platform capability an unstated precondition of the runtime: a backend without a host map — a5, or a2a3 should halHostRegister ever fail — passed the staging check (the non-identity guard accepted nullptr) and then segfaulted or silently corrupted memory inside the orchestrator. Staging now registers a host view per tensor and the orchestrator resolves addresses through it. A mapped buffer registers itself, so reads and writes land on the device bytes as before. A buffer with no mapping registers the staging copy, which holds the same bytes for the whole orchestration window, and a write is pushed back with copy_to_device so the device observes it. An address no region covers is a fatal naming the tensor kinds that have no host view (runtime-created, child memory) rather than a dereference. The read/write pair carries weak fallbacks in the runtime translation unit that dereference the address directly, so the AICPU build — which compiles this path but never runs an orchestrator — is unchanged and links without the host .cpp. A non-identity VA is now usable rather than a hard prepare failure: the orchestrator no longer assumes buffer.addr is the host address. Verified on a2a3 hardware with the host map forced off, so paged_attention's control-tensor reads and available_aicore_counts' writes both ran through the mirror path: both pass. Full a2a3 onboard sweep 51 passed, a2a3sim host_build_graph 17 passed / 4 skipped, cpput 75 passed, ut-py 1034 passed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 27 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
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. Comment |
Summary
host_build_graphruns the orchestrator on the host, whereTensor::buffer.addris a device address.get_tensor_data/set_tensor_datadereferenced it directly, which is only valid because a2a3 maps device buffers into the host address space and returns an identity VA. That made a platform capability an unstated precondition of the runtime.Staging now registers a host view per tensor and the orchestrator resolves addresses through it:
copy_to_devicepush-backnullptrfromregister_device_memory_to_hostpreviously passed the staging check, and the orchestrator then dereferenced a raw device address — a segfault or silent corruption instead of a failed prepare. An address in no registered region is now a fatal that names the tensor kinds with no host view (runtime-created, child memory).buffer.addris the host address..cpp. This is the same idiompto_orchestrator.cppalready uses for the dep_gen and scope-stats hooks. Verified byobjdump: the host.socarries the registry body, the AICPU.socarries the two-linememcpy.Registrations are valid only for the orchestration window — between staging and the first dispatched task, so a mirror cannot be stale.
host_tensor_access_resetbounds it at both ends.New files:
runtime/host_tensor_access.h,host/host_tensor_access.cpp,tests/ut/cpp/a2a3/test_hbg_tensor_access.cpp.Why
This is a prerequisite for giving a5 the host-orchestrated
host_build_graph: a5 has no host-map path, soDeviceRunnerBase::register_device_memory_to_hostreturnsnullptrthere and the current code would fault inside the orchestrator. It also closes the latent failure on a2a3 shouldhalHostRegisterever fail at runtime.Note that a per-access
rtMemcpyis deliberately not how the no-host-map case is served — that was the earlierhost_d2h_readhook, andpaged_attentionre-readsblock_tableinside itsq_loop, so its large cases issue on the order of 10^4–10^5 element reads.Testing
The mirror path has no reachable call site on a2a3, so it was exercised two ways: the new unit tests, and a temporary experiment forcing
DeviceRunner::register_device_memory_to_hostto returnnullptr, under whichpaged_attention(control-tensor reads) andavailable_aicore_counts(writes with push-back) both pass on hardware. That experiment is not part of this branch.tests/st/a2a3+examples/a2a3, both runtimes,-m "not sdma") — 51 passedhost_build_graph— 21 passed, 1 skippedhost_build_graph— 17 passed, 4 skippedtest_hbg_tensor_accesscases, the only place the mirror path runs in CI)All suites re-run after rebasing onto #1587.