Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions torchtitan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

from importlib.metadata import version

# Import to register quantization modules.
import torchtitan.components.quantization # noqa: F401

try:
__version__ = version("torchtitan")
except Exception as e:
__version__ = "0.0.0+unknown"
8 changes: 8 additions & 0 deletions torchtitan/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,14 @@ def main(trainer_class: type[Trainer]) -> None:
trainer_class: The trainer class to instantiate (e.g., Trainer, FluxTrainer, TorchCommsTrainer)
"""
init_logger()

import torchtitan

logger.info(
"TorchTitan version: %s (0.0.0 means __version__ is not defined correctly).",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would it be not defined?
can we just put Undefined instead of 0.0.0 as the version, so that we don't need to explain even when the version is normal?

Copy link
Contributor Author

@fegin fegin Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe "undefined" is going to break some package installation. We can do "0.0.0+unknown". But the explanation is better to stay there for people who don't know the version restriction well.

torchtitan.__version__,
)

config_manager = ConfigManager()
config = config_manager.parse_args()
trainer: Trainer | None = None
Expand Down
Loading