Repository navigation
feat(a5): route DFX collectors through MemoryAllocator so committed_device_memory counts them - #1602
Conversation
…evice_memory counts them The a5 profiling collectors (l2_swimlane, args_dump, pmu, scope_stats, dep_gen) allocated their device buffers via raw rtMalloc (prof_alloc_cb / prof_free_cb), bypassing the per-runner MemoryAllocator. As a result their HBM was invisible to committed_device_memory() (added in hw-native-sys#1592), while a2a3 already routes DFX through mem_alloc_ and counts it — a platform-inconsistent gap the hw-native-sys#1592 docstring ("excludes HCCL/VMM comm windows", implying profiling buffers ARE counted) now describes correctly for both platforms. Replace the raw-rtMalloc callbacks with capturing `alloc_cb` / `free_cb` lambdas that call mem_alloc_.alloc / mem_alloc_.free, matching a2a3's init_pmu / init_dep_gen / init_scope_stats. Both allocators use the same rtMalloc(RT_MEMORY_HBM) underneath, so the device-buffer properties are unchanged; the only effect is that DFX buffers are now tracked and counted. Completes the a5 coverage deferred from hw-native-sys#1592 to keep that PR single-purpose. Onboard a5 DFX scene tests (test_pmu / test_dep_gen / test_scope_stats / test_args_dump) exercise the new alloc path.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughProfiling collector initialization and finalization now use per-run allocation callbacks backed by ChangesProfiling allocator ownership
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
What
Route the a5 onboard DFX collectors (
l2_swimlane,args_dump,pmu,scope_stats,dep_gen) through the per-runnerMemoryAllocatorinstead ofraw
rtMalloc/rtFree.Why
committed_device_memory()(added in #1592) reports the device HBM tracked byMemoryAllocator. On a2a3, the DFX collectors already allocate their devicebuffers through
mem_alloc_(init_pmu/init_dep_gen/init_scope_stats),so their HBM is counted. On a5 they used
prof_alloc_cb/prof_free_cb—raw
rtMalloc(RT_MEMORY_HBM)— bypassingmem_alloc_, so a5 profiling bufferswere invisible to
committed_device_memory().That made the #1592 docstring ("excludes HCCL/VMM comm windows", which implies
profiling buffers are counted) correct on a2a3 but wrong on a5. This PR
closes that platform gap.
How
Replace the two file-static callbacks with capturing
alloc_cb/free_cblambdas (
mem_alloc_.alloc/mem_alloc_.free) at each collector init and infinalize_collectors, matching a2a3's style. Both paths call the samertMalloc(RT_MEMORY_HBM)/rtFreeunderneath, so device-buffer properties areunchanged — the only effect is that a5 DFX buffers are now tracked and counted,
including the runtime watermark replenishment.
Scope / testing
Not part of [Code Health] Reconcile a2a3 vs a5 tensormap_and_ringbuffer runtime implementation divergence #1582 (that issue tracks
tensormap_and_ringbufferruntime-treedivergence and treats profiling instrumentation as already aligned); this is a
platform-host-tree consistency fix stemming from feat: add committed_device_memory() API (L1 byte counter + L2/L3 query) #1592.
test_pmu/test_dep_gen/test_scope_stats/test_args_dump) exercise the new alloc path.host_runtime.socompiles against this change.