Skip to content

Commit

Permalink
Merge branch 'mosaicml:main' into add-memory-snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
cli99 authored Feb 1, 2024
2 parents f9c2a8e + 4b82876 commit 7c57eba
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,6 @@ jobs:
cache-from: type=registry,ref=${{ env.IMAGE_CACHE }}
cache-to: type=registry,ref=${{ env.IMAGE_CACHE }},mode=max
build-args: |
BRANCH_NAME=${{ github.head_ref || github.ref_name }}
BASE_IMAGE=${{ matrix.base_image }}
DEP_GROUPS=${{ matrix.dep_groups }}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ repos:
- id: insert-license
args:
- --license-filepath
- .ci/FILE_HEADER
- .pre-commit/FILE_HEADER
- --comment-style
- "#"
- --allow-past-years
Expand Down
File renamed without changes.
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
ARG BASE_IMAGE
FROM $BASE_IMAGE

ARG BRANCH_NAME
ARG DEP_GROUPS

# Check for changes in setup.py.
# If there are changes, the docker cache is invalidated and a fresh pip installation is triggered.
ADD https://raw.githubusercontent.com/mosaicml/llm-foundry/$BRANCH_NAME/setup.py setup.py
RUN rm setup.py

# Install and uninstall foundry to cache foundry requirements
RUN git clone -b main https://github.com/mosaicml/llm-foundry.git
RUN git clone -b $BRANCH_NAME https://github.com/mosaicml/llm-foundry.git
RUN pip install --no-cache-dir "./llm-foundry${DEP_GROUPS}"
RUN pip uninstall -y llm-foundry
RUN rm -rf llm-foundry
4 changes: 4 additions & 0 deletions llmfoundry/utils/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ def build_tokenizer(
int(1e30),
)

if not hasattr(tokenizer, 'eos_token') or tokenizer.eos_token is None:
raise ValueError(
f'The tokenizer {tokenizer_name} must have an eos_token.')

if dist.is_available() and dist.is_initialized(
) and dist.get_world_size() > 1:
if dist.get_local_rank() == 0:
Expand Down
2 changes: 2 additions & 0 deletions scripts/eval/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
from composer.utils import dist, get_device, reproducibility
from omegaconf import DictConfig, ListConfig
from omegaconf import OmegaConf as om
from rich.traceback import install
from transformers import (AutoModelForCausalLM, PreTrainedTokenizerBase,
T5ForConditionalGeneration)

install()
from llmfoundry.models import MPTForCausalLM
from llmfoundry.models.model_registry import COMPOSER_MODEL_REGISTRY
from llmfoundry.utils.builders import (add_metrics_to_eval_loaders,
Expand Down
2 changes: 2 additions & 0 deletions scripts/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
from composer.utils import dist, get_device, reproducibility
from omegaconf import DictConfig, ListConfig
from omegaconf import OmegaConf as om
from rich.traceback import install
from transformers import PreTrainedTokenizerBase

install()
from llmfoundry import (COMPOSER_MODEL_REGISTRY, ComposerHFCausalLM,
MPTForCausalLM)
from llmfoundry.callbacks import AsyncEval
Expand Down
7 changes: 7 additions & 0 deletions tests/utils/test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ def test_tokenizer_builder(tokenizer_name: str, tokenizer_kwargs: dict):
assert isinstance(tokenizer, PreTrainedTokenizerBase)


def test_tokenizer_no_EOS():
with pytest.raises(
ValueError,
match='The tokenizer bert-base-uncased must have an eos_token.'):
build_tokenizer('bert-base-uncased', {})


def test_build_callback_fails():
with pytest.raises(ValueError):
build_callback('nonexistent_callback', {}, {})
Expand Down

0 comments on commit 7c57eba

Please sign in to comment.