Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
10 changes: 7 additions & 3 deletions megatron/post_training/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import inspect
import os

import modelopt
import modelopt.torch.quantization as mtq
import torch
from modelopt.torch.quantization.utils import is_quantized
from packaging.version import Version


Expand All @@ -32,6 +29,8 @@ def maybe_enable_modelopt(args):

def modelopt_version_higher_than(target_version: str):
"""Check if Model-Optimizer is greater than this version."""
import modelopt

info = "rank {:3}/{:3} checking if nvidia-modelopt-{} is higher than {}".format(
torch.distributed.get_rank(),
torch.distributed.get_world_size(),
Expand All @@ -43,6 +42,8 @@ def modelopt_version_higher_than(target_version: str):

def modelopt_version_at_least(target_version: str):
"""Check if Model-Optimizer is greater or equal than this version."""
import modelopt

info = "rank {:3}/{:3} checking if nvidia-modelopt-{} is at least {}".format(
torch.distributed.get_rank(),
torch.distributed.get_world_size(),
Expand Down Expand Up @@ -116,6 +117,9 @@ def _empty_like_if_meta(tensor: torch.Tensor, *, device: torch.device):


def print_distributed_quant_summary(model, msg=""):
import modelopt.torch.quantization as mtq
from modelopt.torch.quantization.utils import is_quantized

from megatron.core import parallel_state
from megatron.core.utils import unwrap_model
from megatron.training import print_rank_0
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ include = [
"megatron.core.*",
"megatron.training",
"megatron.training.*",
"megatron.post_training",
"megatron.post_training.*",
]

[tool.setuptools.dynamic]
Expand Down
Loading