Skip to content

Commit 38644dd

Browse files
committed
Refactor everything outside of core to be out of the main megatron. namespace.
1 parent dc7fa88 commit 38644dd

File tree

159 files changed

+478
-605
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+478
-605
lines changed

README.md

Lines changed: 6 additions & 6 deletions

examples/detxoify_lm/finetune_gpt.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
import sys
1111
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
1212
os.path.pardir, os.path.pardir)))
13-
from megatron import get_args
14-
from megatron import get_timers
15-
from megatron import get_tokenizer
16-
from megatron import print_rank_0
13+
from megatron.training import get_args
14+
from megatron.training import get_timers
15+
from megatron.training import get_tokenizer
16+
from megatron.training import print_rank_0
1717
from megatron.core import mpu
1818
from megatron.core.datasets.blended_megatron_dataset_builder import BlendedMegatronDatasetBuilder
1919
from megatron.core.datasets.blended_megatron_dataset_config import GPTDatasetConfig
2020
from megatron.core.datasets.gpt_dataset import GPTDataset
21-
from megatron.model import GPTModel
21+
from megatron.legacy.model import GPTModel
2222
from megatron.core.enums import ModelType
2323
from megatron.training import pretrain
24-
from megatron.utils import get_ltor_masks_and_position_ids
25-
from megatron.utils import average_losses_across_data_parallel_group
24+
from megatron.training.utils import get_ltor_masks_and_position_ids
25+
from megatron.training.utils import average_losses_across_data_parallel_group
2626

2727
def model_provider(pre_process=True, post_process=True):
2828
"""Build the model."""

examples/detxoify_lm/generate_samples_gpt.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
1010
os.path.pardir, os.path.pardir)))
1111
import torch
12-
from megatron import get_args
13-
from megatron import get_tokenizer
14-
from megatron import print_rank_0
15-
from megatron.checkpointing import load_checkpoint
12+
from megatron.training import get_args
13+
from megatron.training import get_tokenizer
14+
from megatron.training import print_rank_0
15+
from megatron.training.checkpointing import load_checkpoint
1616
from megatron.core import mpu
17-
from megatron.initialize import initialize_megatron
18-
from megatron.model import GPTModel
17+
from megatron.training.initialize import initialize_megatron
18+
from megatron.legacy.model import GPTModel
1919
from megatron.training import get_model
20-
from megatron.text_generation import generate_and_post_process
21-
from megatron.arguments import core_transformer_config_from_args
20+
from megatron.inference.text_generation import generate_and_post_process
21+
from megatron.training.arguments import core_transformer_config_from_args
2222
from megatron.core.models.gpt import GPTModel
2323
from typing import Union
24-
import megatron.model
24+
import megatron.legacy.model
2525
from megatron.core.transformer.spec_utils import import_module
26-
from megatron.arguments import core_transformer_config_from_args
26+
from megatron.training.arguments import core_transformer_config_from_args
2727
from megatron.core.models.gpt.gpt_layer_specs import get_gpt_layer_with_transformer_engine_spec, get_gpt_layer_local_spec
2828

29-
def model_provider(pre_process=True, post_process=True) -> Union[GPTModel, megatron.model.GPTModel]:
29+
def model_provider(pre_process=True, post_process=True) -> Union[GPTModel, megatron.legacy.model.GPTModel]:
3030
"""Builds the model.
3131
3232
If you set the use_mcore_models to True, it will return the mcore GPT model and if not the legacy GPT model.
@@ -37,7 +37,7 @@ def model_provider(pre_process=True, post_process=True) -> Union[GPTModel, megat
3737
3838
3939
Returns:
40-
Union[GPTModel, megatron.model.GPTModel]: The returned model
40+
Union[GPTModel, megatron.legacy.model.GPTModel]: The returned model
4141
"""
4242
args = get_args()
4343

@@ -83,7 +83,7 @@ def model_provider(pre_process=True, post_process=True) -> Union[GPTModel, megat
8383
else:
8484
assert(args.context_parallel_size == 1), "Context parallelism is only supported with Megatron Core!"
8585

86-
model = megatron.model.GPTModel(
86+
model = megatron.legacy.model.GPTModel(
8787
config,
8888
num_tokentypes=0,
8989
parallel_output=True,

examples/deploy/README.md renamed to examples/inference/README.md

Lines changed: 3 additions & 3 deletions

examples/deploy/ptq_trtllm_llama_7b.sh renamed to examples/inference/ptq_trtllm_llama_7b.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ python -c "import ammo.torch.quantization.extensions as ext; print(ext.cuda_ext)
7373
launch_config="--nproc_per_node=${TP}"
7474

7575
# Launch multi-process with torchrun
76-
torchrun ${launch_config} examples/deploy/text_generation_ptq.py ${options} ${additional_options} --load ${CHECKPOINT_LOAD_DIR}
76+
torchrun ${launch_config} examples/inference/text_generation_ptq.py ${options} ${additional_options} --load ${CHECKPOINT_LOAD_DIR}
7777

7878
# This script is using mpi4py which will fork multiple processes.
79-
python examples/deploy/trtllm_text_generation.py ${trtllm_options}
79+
python examples/inference/trtllm_text_generation.py ${trtllm_options}

examples/deploy/ptq_trtllm_nemotron3_8b.sh renamed to examples/inference/ptq_trtllm_nemotron3_8b.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ python -c "import ammo.torch.quantization.extensions as ext; print(ext.cuda_ext)
6868
launch_config="--nproc_per_node=${TP}"
6969

7070
# Launch multi-process with torchrun
71-
torchrun ${launch_config} examples/deploy/text_generation_ptq.py ${options} ${additional_options} --load ${CHECKPOINT_LOAD_DIR}
71+
torchrun ${launch_config} examples/inference/text_generation_ptq.py ${options} ${additional_options} --load ${CHECKPOINT_LOAD_DIR}
7272

7373
# This script is using mpi4py which will fork multiple processes.
74-
python examples/deploy/trtllm_text_generation.py ${trtllm_options}
74+
python examples/inference/trtllm_text_generation.py ${trtllm_options}
7575

examples/deploy/text_generation_ptq.py renamed to examples/inference/text_generation_ptq.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
from datasets import load_dataset
1414

1515
# [ModelOpt]: changing the default model provider to the AMMO version
16-
from megatron import get_args, print_rank_0
17-
from megatron.checkpointing import load_checkpoint, save_checkpoint
16+
from megatron.training import get_args, print_rank_0
17+
from megatron.training.checkpointing import load_checkpoint, save_checkpoint
1818
from megatron.core import mpu
1919
from megatron.core.dist_checkpointing import load
20-
from megatron.deploy.arguments import add_ammo_args
21-
from megatron.deploy.gpt.model_provider import model_provider
22-
from megatron.initialize import initialize_megatron
23-
from megatron.text_generation import generate_and_post_process
20+
from megatron.inference.arguments import add_ammo_args
21+
from megatron.inference.gpt.model_provider import model_provider
22+
from megatron.training.initialize import initialize_megatron
23+
from megatron.inference.text_generation import generate_and_post_process
2424
from megatron.training import get_model
25-
from megatron.utils import unwrap_model
25+
from megatron.training.utils import unwrap_model
2626

2727
QUANT_CFG_CHOICES = {
2828
"int8": atq.INT8_DEFAULT_CFG,

0 commit comments

Comments
 (0)