Skip to content

Commit

Permalink
fix pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
zigzagcai committed Aug 21, 2024
1 parent 1c81359 commit 5f254db
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion internlm/core/parallel/shard.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from internlm.core.context import global_context as gpc
from internlm.core.parallel.comm.utils import _split
from internlm.utils.logger import get_logger
from internlm.utils.utils import ModelType, TensorParallelMode
from internlm.utils.utils import TensorParallelMode

logger = get_logger(__file__)

Expand Down
6 changes: 3 additions & 3 deletions internlm/core/trainer_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from internlm.model.losses.ce_loss import FlashGPTLMLoss
from internlm.model.metrics import AccPerplex
from internlm.monitor.monitor import send_alert_message
from internlm.train import initialize_model
from internlm.train.pipeline import (
get_scheduler_hooks,
initialize_llm_profile,
Expand All @@ -41,7 +42,6 @@
from internlm.utils.parallel import get_parallel_log_file_name, is_using_isp
from internlm.utils.simple_memory_profiler import SimpleMemoryProfiler
from internlm.utils.writer import Writer
from internlm.train import initialize_model

# global llm logger
logger = logging.getLogger(__file__)
Expand Down Expand Up @@ -95,7 +95,7 @@ def __init__(
self.current_time = self._setup_time_and_logging()
# load config_lines
config_lines = self._read_config(kwargs["config"])

# set amp and parallel attribute for model
model = initialize_model(model)

Expand Down Expand Up @@ -371,4 +371,4 @@ def _update_profilers(self, batch_count: int, prof):
if self.memory_profiler is not None:
self.memory_profiler.step()
if batch_count % 2 == 0:
prof.step()
prof.step()
5 changes: 2 additions & 3 deletions internlm/data/build_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
PackedDatasetWithPadForMultimodal,
get_packed_dataset_without_short_length,
)
from internlm.data.utils import get_dataset_type_ids_map
from internlm.utils.logger import get_logger
from internlm.utils.utils import DataType

Expand Down Expand Up @@ -149,14 +148,14 @@ def build_train_loader_with_data_type():
Returns: train_dl
"""
data_cfg = gpc.config.data

if data_cfg.type == DataType.tokenized.name:
train_ds, train_sampler, train_collate_fn = get_tokenized_train_loader_items(data_cfg)
elif data_cfg.type == DataType.streaming.name:
train_ds, train_sampler, train_collate_fn = get_hf_train_loader_items(data_cfg)
else:
raise ValueError(f"dataset type {data_cfg.type} is not supported")

# Create the training data loader
train_dl = DataLoader(
dataset=train_ds,
Expand Down
4 changes: 1 addition & 3 deletions internlm/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import torch

from internlm.core.context import global_context as gpc
from internlm.core.context.process_group_initializer import ParallelMode
from internlm.utils.utils import ModelType


def get_dataset_type_ids_map(path):
Expand Down Expand Up @@ -69,5 +67,5 @@ def packed_data_normalizer(data, label):
data["indexes"] = data["indexes"][0]
data["cu_seqlens"] = data["cu_seqlens"][0].squeeze(0)
data["max_seqlen"] = (data["cu_seqlens"][1:] - data["cu_seqlens"][:-1]).max().item()

return data, label
1 change: 1 addition & 0 deletions internlm/model/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def has(self, module_name: str):

model_initializer = Registry("model_initializer")


def register_model_initializer() -> None:
model_initializer.register_module(ModelType.INTERNLM.name, InternLM1)
model_initializer.register_module(ModelType.INTERNLM2_PUBLIC.name, InternLM2)
Expand Down
1 change: 0 additions & 1 deletion internlm/model/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any, Dict, List

from internlm.core.context import global_context as gpc
from internlm.model.modules.mha import MHA


Expand Down
4 changes: 1 addition & 3 deletions internlm/train/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import math
import time
from typing import Callable, Iterable, List, Optional, Tuple, TypeVar, Union
from typing import Iterable, List, Tuple, TypeVar, Union

import torch
from torch import nn
Expand Down Expand Up @@ -44,7 +44,6 @@
from internlm.core.parallel.comm.zero import ParamAsyncBcastHandler
from internlm.core.trainer import TrainState
from internlm.data.utils import unpack_type_ids
from internlm.model.builder import create_model
from internlm.model.metrics import SchedulerMetricHook
from internlm.model.modules.embedding import Embedding1D
from internlm.model.modules.linear import (
Expand All @@ -61,7 +60,6 @@
)
from internlm.model.moe.moe import MoE
from internlm.model.ops.norm import RMSNorm
from internlm.model.registry import register_model_initializer
from internlm.monitor import set_env_var
from internlm.monitor.monitor import monitor_manager as mm
from internlm.solver.optimizer import (
Expand Down

0 comments on commit 5f254db

Please sign in to comment.