Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate ICL classes to foundry #936

Merged
merged 100 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
cd18e74
start
bmosaicml Jan 23, 2024
1fffbad
still need to migrate fixtures
bmosaicml Feb 2, 2024
5a6e81c
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Feb 2, 2024
4aac81e
wip onboarding tests
bmosaicml Feb 2, 2024
946a4af
still workin'
bmosaicml Feb 2, 2024
289ca55
still wip
bmosaicml Feb 2, 2024
3696f8d
maybe done; test out on mcli now
bmosaicml Feb 2, 2024
a20877d
mcli
bmosaicml Feb 2, 2024
53da3ea
remove calibration error
bmosaicml Feb 2, 2024
16b8e32
merge
bmosaicml Feb 7, 2024
a90766e
migration
bmosaicml Feb 7, 2024
72ce793
migration
bmosaicml Feb 7, 2024
667bdec
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
bmosaicml Feb 9, 2024
ceff0c4
full migration
bmosaicml Feb 9, 2024
5bb06cc
precommit
bmosaicml Feb 12, 2024
fe83828
fix
bmosaicml Feb 12, 2024
b54a12b
fix pytests
bmosaicml Feb 12, 2024
71e8391
refactor QA
bmosaicml Feb 16, 2024
414153e
update
bmosaicml Feb 22, 2024
a3f5a31
restore
bmosaicml Feb 23, 2024
820069a
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Feb 23, 2024
4a1cd79
add
bmosaicml Feb 23, 2024
d265979
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
bmosaicml Feb 23, 2024
ddfd7b5
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Feb 26, 2024
71f77e3
fix
bmosaicml Feb 26, 2024
cb3725b
wip
bmosaicml Feb 27, 2024
5135152
update readme
bmosaicml Feb 27, 2024
18bae17
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Feb 27, 2024
c6162dd
final pyright
bmosaicml Feb 27, 2024
25d431e
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
bmosaicml Feb 27, 2024
f1b334d
done
bmosaicml Feb 27, 2024
c4ed644
pass prelimiter into ALL the ICL task datasets
eitanturok Feb 27, 2024
2516c24
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Mar 4, 2024
f213a40
allow QA task name stil lfor backward compatibility
bmosaicml Mar 4, 2024
35fd2f1
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
bmosaicml Mar 4, 2024
d570e5d
fix
bmosaicml Mar 5, 2024
a5cd308
fix test
bmosaicml Mar 5, 2024
0fb37cd
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Mar 5, 2024
901fc69
add generation length
bmosaicml Mar 5, 2024
a313499
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
bmosaicml Mar 5, 2024
df19c0d
remove max_new_tokens
bmosaicml Mar 5, 2024
54bb4c7
fix cpu trsts
bmosaicml Mar 6, 2024
9ebeaa0
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Mar 6, 2024
ca9816c
Merge branch 'main' into migrate_subclasses_to_foundry
maxisawesome Mar 6, 2024
b9d6cd1
try and fix lm eval test
bmosaicml Mar 7, 2024
691ab20
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
bmosaicml Mar 7, 2024
c207cd9
temp disable lm task eval test
bmosaicml Mar 7, 2024
c85813b
fix test?
bmosaicml Mar 8, 2024
08ef908
fix tet
bmosaicml Mar 11, 2024
aca0e63
finish
bmosaicml Mar 11, 2024
30fcedd
fix
bmosaicml Mar 12, 2024
59daa26
Merge branch 'main' into migrate_subclasses_to_foundry
maxisawesome Mar 13, 2024
4217a78
Update scripts/eval/README.md
bmosaicml Mar 13, 2024
6f597a9
fix comments
bmosaicml Mar 13, 2024
8c6e622
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
bmosaicml Mar 13, 2024
f387a73
fix bug with seq len
bmosaicml Mar 14, 2024
cbfa3da
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Mar 14, 2024
2f405d9
restore mcli
bmosaicml Mar 14, 2024
76e600a
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
bmosaicml Mar 14, 2024
898928e
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Mar 15, 2024
07fb59e
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Mar 18, 2024
587971f
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Mar 18, 2024
18efa86
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Mar 29, 2024
7faeb78
merge
bmosaicml Apr 1, 2024
343e115
fix builder
bmosaicml Apr 1, 2024
bf6231e
add deprecation warning
bmosaicml Apr 1, 2024
58859a3
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Apr 1, 2024
501d4cc
add deprecation warning
bmosaicml Apr 1, 2024
22f6759
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
bmosaicml Apr 1, 2024
414467a
merge
bmosaicml Apr 1, 2024
65fbbed
merge
bmosaicml Apr 1, 2024
5696f09
add logging necessities to nlp.py
maxisawesome Apr 1, 2024
91a2b18
add attention_mask test update
maxisawesome Apr 1, 2024
79877ee
fix generation_length in tests
maxisawesome Apr 1, 2024
9c50795
Merge branch 'main' into migrate_subclasses_to_foundry
maxisawesome Apr 1, 2024
eac919a
fix bug
maxisawesome Apr 1, 2024
965c20c
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
maxisawesome Apr 1, 2024
57e902a
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Apr 2, 2024
7c0996f
Merge branch 'main' into migrate_subclasses_to_foundry
maxisawesome Apr 2, 2024
599695c
Merge branch 'main' into migrate_subclasses_to_foundry
maxisawesome Apr 2, 2024
e10086f
restore yamls
bmosaicml Apr 3, 2024
a60ef1d
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Apr 4, 2024
d78d783
Merge branch 'main' into migrate_subclasses_to_foundry
maxisawesome Apr 4, 2024
1ddf194
Merge branch 'main' into migrate_subclasses_to_foundry
maxisawesome Apr 9, 2024
d5aebc8
fix typos
bmosaicml Apr 10, 2024
d7272b1
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
bmosaicml Apr 10, 2024
a5082b0
add deprecation warning for code
maxisawesome Apr 10, 2024
3c8ac56
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
maxisawesome Apr 10, 2024
642ad40
pyright wip
maxisawesome Apr 10, 2024
f30db14
Merge branch 'main' into migrate_subclasses_to_foundry
maxisawesome Apr 11, 2024
de321b2
fix pyright
bmosaicml Apr 11, 2024
019c58a
fix pyright error again
bmosaicml Apr 11, 2024
779f490
fix pyright
bmosaicml Apr 11, 2024
03f7e91
fix pyright
bmosaicml Apr 11, 2024
e81823d
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Apr 12, 2024
709fc80
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Apr 12, 2024
eb494d8
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Apr 12, 2024
3cd226d
Merge branch 'main' into migrate_subclasses_to_foundry
bmosaicml Apr 12, 2024
02308df
update version
maxisawesome Apr 12, 2024
1a36d3f
Merge branch 'migrate_subclasses_to_foundry' of github.com:mosaicml/l…
maxisawesome Apr 12, 2024
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
1,939 changes: 1,939 additions & 0 deletions llmfoundry/eval/datasets/in_context_learning_evaluation.py

Large diffs are not rendered by default.

599 changes: 599 additions & 0 deletions llmfoundry/eval/metrics/nlp.py

Large diffs are not rendered by default.

15 changes: 5 additions & 10 deletions llmfoundry/models/hf/hf_causal_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@
from typing import TYPE_CHECKING, Any, Dict, Mapping

# required for loading a python model into composer
from composer.metrics.nlp import (InContextLearningCodeEvalAccuracy,
InContextLearningLMAccuracy,
InContextLearningLMExpectedCalibrationError,
InContextLearningMCExpectedCalibrationError,
InContextLearningMultipleChoiceAccuracy,
InContextLearningQAAccuracy,
LanguageCrossEntropy, LanguagePerplexity)
from composer.metrics.nlp import LanguageCrossEntropy, LanguagePerplexity
from composer.models.huggingface import peft_installed
from composer.utils import dist
from omegaconf import DictConfig
from transformers import (AutoConfig, AutoModelForCausalLM, PreTrainedModel,
PreTrainedTokenizerBase)

from llmfoundry.eval.metrics.nlp import (
InContextLearningCodeEvalAccuracy, InContextLearningLMAccuracy,
InContextLearningMultipleChoiceAccuracy, InContextLearningQAAccuracy)
from llmfoundry.models.hf.hf_fsdp import hf_get_init_device
from llmfoundry.models.hf.model_wrapper import HuggingFaceModelWithZLoss
from llmfoundry.models.layers.attention import is_flash_v2_installed
Expand Down Expand Up @@ -115,9 +112,7 @@ def __init__(self, om_model_config: DictConfig,
InContextLearningLMAccuracy(),
InContextLearningMultipleChoiceAccuracy(),
InContextLearningQAAccuracy(),
InContextLearningCodeEvalAccuracy(),
InContextLearningLMExpectedCalibrationError(),
InContextLearningMCExpectedCalibrationError()
InContextLearningCodeEvalAccuracy()
]
if not om_model_config.get('use_train_metrics', True):
train_metrics = []
Expand Down
16 changes: 6 additions & 10 deletions llmfoundry/models/inference_api_wrapper/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@

import torch
from composer.core.types import Batch
from composer.metrics import InContextLearningMetric
from composer.metrics.nlp import (InContextLearningLMAccuracy,
InContextLearningLMExpectedCalibrationError,
InContextLearningMCExpectedCalibrationError,
InContextLearningMultipleChoiceAccuracy,
InContextLearningQAAccuracy,
LanguageCrossEntropy, LanguagePerplexity)
from composer.metrics.nlp import LanguageCrossEntropy, LanguagePerplexity
from composer.models import ComposerModel
from torchmetrics import Metric
from transformers import AutoTokenizer

from llmfoundry.eval.metrics.nlp import (
InContextLearningLMAccuracy, InContextLearningMetric,
InContextLearningMultipleChoiceAccuracy, InContextLearningQAAccuracy)


class InferenceAPIEvalWrapper(ComposerModel):

Expand All @@ -28,9 +26,7 @@ def __init__(self, model_cfg: Dict, tokenizer: AutoTokenizer):
LanguagePerplexity(),
InContextLearningLMAccuracy(),
InContextLearningMultipleChoiceAccuracy(),
InContextLearningQAAccuracy(),
InContextLearningLMExpectedCalibrationError(),
InContextLearningMCExpectedCalibrationError()
InContextLearningQAAccuracy()
]
self.eval_metrics = {
metric.__class__.__name__: metric for metric in eval_metrics
Expand Down
11 changes: 3 additions & 8 deletions llmfoundry/models/mpt/modeling_mpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@
import torch
import torch.nn as nn
import torch.nn.functional as F
from composer.metrics import (InContextLearningCodeEvalAccuracy,
InContextLearningLMAccuracy,
InContextLearningLMExpectedCalibrationError,
InContextLearningMCExpectedCalibrationError,
InContextLearningMultipleChoiceAccuracy,
InContextLearningQAAccuracy)
from composer.metrics.nlp import LanguageCrossEntropy, LanguagePerplexity
from composer.models import HuggingFaceModel
from composer.utils import dist

from llmfoundry.eval.metrics.nlp import (
InContextLearningCodeEvalAccuracy, InContextLearningLMAccuracy,
InContextLearningMultipleChoiceAccuracy, InContextLearningQAAccuracy)
from llmfoundry.models.layers.attention import (is_flash_v1_installed,
is_flash_v2_installed)

Expand Down Expand Up @@ -1032,8 +1029,6 @@ def __init__(
InContextLearningMultipleChoiceAccuracy(),
InContextLearningQAAccuracy(),
InContextLearningCodeEvalAccuracy(),
InContextLearningLMExpectedCalibrationError(),
InContextLearningMCExpectedCalibrationError(),
]

super().__init__(
Expand Down
4 changes: 2 additions & 2 deletions llmfoundry/utils/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
MemoryMonitor, OptimizerMonitor,
RuntimeEstimator, SpeedMonitor)
from composer.core import Algorithm, Callback, Evaluator
from composer.datasets.in_context_learning_evaluation import \
get_icl_task_dataloader
from composer.loggers import (InMemoryLogger, LoggerDestination, MLFlowLogger,
TensorboardLogger, WandBLogger)
from composer.optim import DecoupledAdamW
Expand All @@ -35,6 +33,8 @@
LayerFreezing, MonolithicCheckpointSaver,
ScheduledGarbageCollector)
from llmfoundry.data.dataloader import build_dataloader
from llmfoundry.eval.datasets.in_context_learning_evaluation import \
get_icl_task_dataloader
from llmfoundry.optim import (DecoupledAdaLRLion, DecoupledClipLion,
DecoupledLionW, DecoupledLionW_8bit)
from llmfoundry.optim.scheduler import InverseSquareRootWithWarmupScheduler
Expand Down
16 changes: 9 additions & 7 deletions mcli/mcli-hf-eval.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
integrations:
- integration_type: git_repo
git_repo: mosaicml/llm-foundry
git_branch: v0.4.0
git_branch: migrate_subclasses_to_foundry # v0.4.0
bmosaicml marked this conversation as resolved.
Show resolved Hide resolved
# git_commit: # OR use your commit hash
pip_install: -e ".[gpu]"
ssh_clone: false # Should be true if using a private repo

command: |
cd llm-foundry/scripts
pip uninstall mosaicml -y
pip install git+https://github.com/mosaicml/composer.git@refactor_update_metric
composer eval/eval.py /mnt/config/parameters.yaml

# Mosaic Cloud will use run_name (with a unique suffix) to populate the env var $RUN_NAME
run_name: mpt-eval
name: mpt-eval
gpu_num: 8
# gpu_type:
# cluster: # replace with your cluster here!
gpu_type: a100_80gb
cluster: r1z1 # replace with your cluster here!

image: mosaicml/llm-foundry:2.1.0_cu121_flash2-latest

Expand All @@ -28,16 +30,16 @@ parameters:

models:
-
model_name: mosaicml/mpt-7b-instruct
model_name: mosaicml/mpt-7b
# Tokenizer
tokenizer:
name: EleutherAI/gpt-neox-20b
name: mosaicml/mpt-7b
kwargs:
model_max_length: ${max_seq_len}

model:
name: hf_causal_lm
pretrained_model_name_or_path: mosaicml/mpt-7b-instruct
pretrained_model_name_or_path: mosaicml/mpt-7b
init_device: mixed
pretrained: true
use_auth_token: false
Expand Down
2 changes: 1 addition & 1 deletion tests/callbacks/test_eval_gauntlet_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import torch
from composer.core import State
from composer.loggers import InMemoryLogger, Logger
from composer.metrics import InContextLearningLMAccuracy
from transformers import AutoTokenizer

from llmfoundry.eval.metrics.nlp import InContextLearningLMAccuracy
from llmfoundry.utils.builders import build_icl_data_and_gauntlet


Expand Down
Loading
Loading