Skip to content

Commit

Permalink
make tp dir
Browse files Browse the repository at this point in the history
  • Loading branch information
eitanturok committed Sep 26, 2024
1 parent c9e64df commit df169e8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions llmfoundry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
models,
optim,
tokenizers,
tp,
utils,
)
from llmfoundry._version import __version__
Expand Down Expand Up @@ -87,5 +88,6 @@
'models',
'optim',
'tokenizers',
'tp',
'utils',
]
5 changes: 1 addition & 4 deletions llmfoundry/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
MPTModel,
MPTPreTrainedModel,
)
from llmfoundry.models.utils.tp_strategies import ffn_tp_strategies
from llmfoundry.registry import models, tp_strategies
from llmfoundry.registry import models

models.register('mpt_causal_lm', func=ComposerMPTCausalLM)
models.register('hf_causal_lm', func=ComposerHFCausalLM)
Expand All @@ -25,7 +24,6 @@
models.register('fmapi_causal_lm', func=FMAPICasualLMEvalWrapper)
models.register('openai_chat', func=OpenAIChatAPIEvalWrapper)
models.register('fmapi_chat', func=FMAPIChatAPIEvalWrapper)
tp_strategies.register('ffn', func=ffn_tp_strategies)

__all__ = [
'ComposerHFCausalLM',
Expand All @@ -39,5 +37,4 @@
'FMAPICasualLMEvalWrapper',
'OpenAIChatAPIEvalWrapper',
'FMAPIChatAPIEvalWrapper',
'ffn_tp_strategies',
]
11 changes: 11 additions & 0 deletions llmfoundry/tp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2024 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0

from llmfoundry.registry import tp_strategies
from llmfoundry.tp.tp_strategies import ffn_tp_strategies

tp_strategies.register('ffn', func=ffn_tp_strategies)

__all__ = [
'ffn_tp_strategies',
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


def ffn_tp_strategies(model: ComposerModel) -> dict[str, ParallelStyle]:
TP_LAYERS = {'up_proj', 'down_proj'}
TP_LAYERS = {'ffn', 'ffn.up_proj', 'ffn.down_proj'}

# Validate that all TP_LAYERS are in model
tp_layers_in_model = {
Expand Down
2 changes: 1 addition & 1 deletion tests/models/utils/test_tp_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
'ignore:tp_strategies is experimental and may change with future versions.',
)
def test_ffn_tp_strategies_layer_plan():
# Actual layer plan from tp_strategies=fnn
# Create layer plan from fnn tp_strategy
tp_config = {
'strategy': 'ffn',
}
Expand Down

0 comments on commit df169e8

Please sign in to comment.