Compare commits

...

1 Commits

Author SHA1 Message Date
3f50fa1903 flight_recorder: move to torch.distributed
Summary:
This moves torchfrtrace to be under `torch.distributed.flight_recorder` instead of `tools.flight_recorder` as the `tools` package is not included in the torch wheels. This makes it so you can use fr trace analyze without using it from a source checkout

allow-large-files

Test Plan:
```
buck run //caffe2/fb/flight_recorder:fr_trace
```

CI

Reviewed By: fduwjj

Differential Revision: D87022129
2025-11-13 18:18:16 -08:00
10 changed files with 22 additions and 29 deletions

View File

@ -32,7 +32,7 @@ project-excludes = [
"torch/utils/tensorboard/summary.py",
# formatting issues, will turn on after adjusting where suppressions can be
# in import statements
"tools/flight_recorder/components/types.py",
"torch/distributed/flight_recorder/components/types.py",
"torch/linalg/__init__.py",
"torch/package/importer.py",
"torch/package/_package_pickler.py",

View File

@ -1632,7 +1632,7 @@ def configure_extension_build() -> tuple[
if cmake_cache_vars["USE_DISTRIBUTED"]:
# Only enable fr_trace command if distributed is enabled
entry_points["console_scripts"].append(
"torchfrtrace = tools.flight_recorder.fr_trace:main",
"torchfrtrace = torch.distributed.flight_recorder.fr_trace:main",
)
return ext_modules, cmdclass, packages, entry_points, extra_install_requires

View File

@ -2,23 +2,16 @@
import copy
import math
import pathlib
import sys
from typing import Any
REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent.parent.parent
sys.path.insert(0, str(REPO_ROOT))
from tools.flight_recorder.components.builder import build_db
from tools.flight_recorder.components.config_manager import JobConfig
from tools.flight_recorder.components.types import COLLECTIVES, MatchInfo, MatchState
from tools.flight_recorder.components.utils import match_one_event
# Make sure to remove REPO_ROOT after import is done
sys.path.remove(str(REPO_ROOT))
from torch.distributed.flight_recorder.components.builder import build_db
from torch.distributed.flight_recorder.components.config_manager import JobConfig
from torch.distributed.flight_recorder.components.types import (
COLLECTIVES,
MatchInfo,
MatchState,
)
from torch.distributed.flight_recorder.components.utils import match_one_event
from torch.testing._internal.common_utils import run_tests, TestCase

View File

@ -11,8 +11,8 @@ import os
import sys
from typing import Any # type: ignore[attr-defined]
from tools.flight_recorder.components.fr_logger import FlightRecorderLogger
from tools.flight_recorder.components.types import (
from torch.distributed.flight_recorder.components.fr_logger import FlightRecorderLogger
from torch.distributed.flight_recorder.components.types import (
Collective,
Database,
EntryState,
@ -23,7 +23,7 @@ from tools.flight_recorder.components.types import (
Op,
Traceback,
)
from tools.flight_recorder.components.utils import (
from torch.distributed.flight_recorder.components.utils import (
add_stack_id_in_entries,
align_trace_from_beginning,
check_current_entry_match,

View File

@ -9,7 +9,7 @@ import logging
from collections.abc import Sequence
from typing import Optional
from tools.flight_recorder.components.fr_logger import FlightRecorderLogger
from torch.distributed.flight_recorder.components.fr_logger import FlightRecorderLogger
logger: FlightRecorderLogger = FlightRecorderLogger()

View File

@ -13,7 +13,7 @@ import time
from collections import defaultdict
from typing import Any, Union
from tools.flight_recorder.components.fr_logger import FlightRecorderLogger
from torch.distributed.flight_recorder.components.fr_logger import FlightRecorderLogger
logger: FlightRecorderLogger = FlightRecorderLogger()

View File

@ -16,7 +16,7 @@ from typing import ( # type: ignore[attr-defined]
TypeVar,
)
from tools.flight_recorder.components.fr_logger import FlightRecorderLogger
from torch.distributed.flight_recorder.components.fr_logger import FlightRecorderLogger
T = TypeVar("T", bound=NamedTuple)

View File

@ -8,8 +8,8 @@ import argparse
import math
from typing import Any
from tools.flight_recorder.components.fr_logger import FlightRecorderLogger
from tools.flight_recorder.components.types import (
from torch.distributed.flight_recorder.components.fr_logger import FlightRecorderLogger
from torch.distributed.flight_recorder.components.types import (
Collective,
EntryState,
Group,

View File

@ -32,10 +32,10 @@ import pickle
from collections.abc import Sequence
from typing import Optional
from tools.flight_recorder.components.builder import build_db, transform_ft
from tools.flight_recorder.components.config_manager import JobConfig
from tools.flight_recorder.components.loader import read_dir
from tools.flight_recorder.components.types import types
from torch.distributed.flight_recorder.components.builder import build_db, transform_ft
from torch.distributed.flight_recorder.components.config_manager import JobConfig
from torch.distributed.flight_recorder.components.loader import read_dir
from torch.distributed.flight_recorder.components.types import types
def main(args: Optional[Sequence[str]] = None) -> None: