mirror of
https://github.com/pytorch/pytorch.git
synced 2026-10-28 18:56:51 +08:00
Summary:
Fine-grained activity filters were bypassed by the MTIA custom-config path, and `COLLECTIVE_COMM` was injected separately from MTIA selection. This prevented Python callers from expressing an exact MTIA activity selection. Make `COLLECTIVE_COMM` a selectable/default MTIA activity, remove it from MTIA requests when no collective profiler is available, and preserve the historical global collective behavior for profiles that do not request MTIA.
Reject combining a non-empty `custom_profiler_config` with an explicit MTIA `activity_filter`, since they are competing mechanisms for selecting MTIA activities.
Test Plan:
# Before
With collective profiling available, the regression test failed because `COLLECTIVE_COMM` was still present for a mixed CPU plus `{ProfilerActivity.MTIA: ["MTIA_INSIGHT"]}` request.
Supplying both a non-empty `custom_profiler_config` and an explicit MTIA `activity_filter` was also ambiguous: the filter selected the activity set while the raw custom config was still forwarded to Kineto.
After adding the test to the OSS CMake suite, GitHub builds also failed to link `test_mtia_activity_filter` because `prepareTrace` was not exported from `libtorch`.
# After
The focused test covers exact MTIA collective inclusion and exclusion in one test process, the legacy MTIA custom-config path, rejection of conflicting custom-config and activity-filter inputs, and preserved CPU-only behavior.
```bash
buck test fbcode//caffe2/test/cpp/profiler:test_mtia_activity_filter
```
https://www.internalfb.com/intern/testinfra/testrun/28710447655788492
The full stack integration coverage exercises the Python vLLM and `mtia-launch` plumbing.
```bash
buck test fbcode//caffe2/test/cpp/profiler:test_mtia_activity_filter fbcode//vllm/fb/mtia/tests/unit:test_profiler_activity_filter fbcode//vllm/fb/mtia/tests/unit:test_mtia_worker fbcode//mtia/genai/inference/launch/test:test_profiler
```
https://www.internalfb.com/intern/testinfra/testrun/5629499923215536
Reviewed By: ryanzhang22, mzzchy
Differential Revision: D117536902
Pull Request resolved: https://github.com/pytorch/pytorch/pull/194920
Approved by: https://github.com/ryanzhang22