feat: add complete MetaX profiler tracing - #134
Open
lvyufeng wants to merge 1 commit into
Open
Conversation
Support CUPTI-compatible MCPTI activity collection for MetaX, including runtime names, kernel metadata, memcpy and memset records, correlation flows, device-time attribution, and capture-window filtering. Add vendor-specific tracer selection with an unavailable fallback, update profiler validation tests, and document measured MetaX parity coverage. Tested: MetaX profiler parity 7 passed Tested: profiler unit tests 4 passed, 1 skipped Tested: ruff check . Tested: ruff format --check . Tested: MetaX boxing torch_fl build Tested: unavailable tracer standalone compilation Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
lvyufeng
force-pushed
the
feat/flagos-profiler-full
branch
from
August 19, 2026 05:52
b349929 to
f815435
Compare
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.
AI Agent Information
flagos/mainbefore submission.Summary
This change adds complete profiler activity collection for MetaX through the CUDA-compatible MCPTI API. It emits kernel, memcpy, memset, and runtime events with correct callback names, correlation flows, device-time attribution, kernel metadata, and capture-window filtering. It also adds per-accelerator tracer selection with an explicit unavailable fallback and documents the measured MetaX support and remaining validation limits.
Change Type
Platforms Affected
Problem Analysis
What was broken/missing?
MetaX profiling did not provide a complete device timeline through the existing CUPTI-compatible tracer. Runtime callback IDs were interpreted with the NVIDIA namespace, device-side activity records could be lost or discarded, occupancy metadata was unavailable, and unsupported platforms had no explicit device-tracer factory fallback.
Why did it happen?
MetaX MCPTI uses a different callback-ID namespace and vendor record layouts from NVIDIA CUPTI. MCPTI 3.8.0 can also return a stale iterator pointer after external-correlation records. Its compatibility runtime exposes
wcudaDeviceGetAttributerather than the NVIDIA symbol used by the occupancy calculator. Finally, the source tree uses recursive globbing, so every build must exclude all tracer implementations except exactly one factory.Investigation process:
wcudaDeviceGetAttributeentry point.Solution Design
Implementation approach:
mcptiActivityGetApiNameresolution.wcudaDeviceGetAttributewhile retaining the existing CUDA path for NVIDIA and PPU-compatible builds.Key design decisions:
DeviceTracerinterface.Code changes by file:
csrc/CMakeLists.txt: select exactly one profiler tracer per accelerator, enable MetaX MCPTI definitions, and search the MetaX occupancy compatibility include path.csrc/profiler/cupti_shim.h: add MetaX callback ABI declarations, MCPTI library loading, callback-ID mapping, and deferred resolver support.csrc/profiler/cupti_device_tracer.cc: parse MCPTI records, recover malformed iterator sequences, skip missing timestamps, resolve occupancy metadata, and preserve correlation/name semantics.csrc/profiler/unavailable_device_tracer.cc: provide the no-device-activity fallback factory.tests/unit/test_profiler_privateuse1.py: make profiler library checks MetaX-aware, include MetaX in CUPTI-compatible build gating, and translate modified comments to English.docs/architecture/profiler.md: document tracer selection, MetaX MCPTI behavior, measured parity, and known scanner limits.docs/reference/compatibility.md: record MetaX profiler support as experimental based on local C550 measurement rather than CI validation.Changes by commit:
b349929-feat: add complete MetaX profiler tracing: adds the MetaX MCPTI implementation, fallback tracer, tests, and documentation.Verification
Pre-submission Checklist
Linting Results
Test Results
Manual Verification
The original MetaX parity workload initially produced no usable device events because MCPTI records were misnamed, malformed iterator advancement abandoned valid records, and zero/zero timestamps were converted into an unrelated clock range. After the implementation, the same workload emitted kernel=17, memcpy=1, memset=1, and runtime=187 events; all seven parity assertions passed.
Code Quality Verification
Style Consistency
DeviceTracerabstractionsEdge Cases Considered
start == end == 0means timing was unavailable, not a valid event at clock origin.Potential Risks
Rollback Plan
Revert commit
b349929. This removes the MetaX MCPTI parser changes, fallback tracer, source-selection changes, tests, and documentation updates without changing generated operator code.Related Work
Explicitly Not Included
Human Review Notes
Areas needing special attention:
mcptiActivityGetApiNameresolution and callback ABI typedefs for SDK compatibility.Questions for reviewer:
Additional Context
flagos/mainbefore submission.flagos-ai/Torch-FL.🤖 Generated with Claude Code