Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit 83090cd

Browse files
committed
Just Try Catch
1 parent 37a8141 commit 83090cd

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

install/install_requirements.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ PYTORCH_NIGHTLY_VERSION=dev20240901
5252
# Nightly version for torchvision
5353
VISION_NIGHTLY_VERSION=dev20240901
5454

55-
# Nightly version for torchtune
56-
TUNE_NIGHTLY_VERSION=dev20240928
57-
5855
# Uninstall triton, as nightly will depend on pytorch-triton, which is one and the same
5956
(
6057
set -x
@@ -75,7 +72,6 @@ fi
7572
REQUIREMENTS_TO_INSTALL=(
7673
torch=="2.5.0.${PYTORCH_NIGHTLY_VERSION}"
7774
torchvision=="0.20.0.${VISION_NIGHTLY_VERSION}"
78-
torchtune=="0.3.0.${TUNE_NIGHTLY_VERSION}"
7975
)
8076

8177
# Install the requirements. --extra-index-url tells pip to look for package
@@ -91,6 +87,12 @@ REQUIREMENTS_TO_INSTALL=(
9187
$PIP_EXECUTABLE install torchao=="0.5.0"
9288
)
9389

90+
# Rely on the latest tochtune for flamingo support
91+
(
92+
set -x
93+
$PIP_EXECUTABLE install -I git+https://github.com/pytorch/torchtune.git@d002d45e3ec700fa770d9dcc61b02c59e2507bf6
94+
)
95+
9496
if [[ -x "$(command -v nvidia-smi)" ]]; then
9597
(
9698
set -x

torchchat/model.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@
3030
SequenceParallel,
3131
)
3232
from torch.nn import functional as F
33+
34+
try:
35+
# TODO: remove this after we figure out where in torchtune an `evaluate` module
36+
# is being imported, which is being confused with huggingface's `evaluate``.
37+
import lm_eval # noqa
38+
except Exception:
39+
pass
40+
41+
from torchtune.models.clip import clip_vision_encoder
3342
from torchtune.models.llama3_1._component_builders import llama3_1 as llama3_1_builder
3443
from torchtune.models.llama3_2_vision._component_builders import (
3544
llama3_2_vision_decoder,
@@ -223,9 +232,6 @@ def _flamingo(cls):
223232

224233
@classmethod
225234
def _llava(cls):
226-
# TODO: Import locally until we find where in torchtune an `evaluate` module
227-
# is being imported, which is being confused with huggingface's `evaluate``.
228-
from torchtune.models.clip import clip_vision_encoder
229235
return cls(
230236
model_type=ModelType.Llava,
231237
modules={

torchchat/usages/eval.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33

44
# This source code is licensed under the license found in the
55
# LICENSE file in the root directory of this source tree.
6+
import argparse
67
from typing import Callable, Optional
78

8-
import lm_eval
9-
109
import torch
1110
import torch._dynamo.config
1211
import torch._inductor.config
@@ -17,6 +16,7 @@
1716
BuilderArgs,
1817
TokenizerArgs,
1918
)
19+
from torchchat.cli.cli import add_arguments_for_verb, arg_init
2020

2121
from torchchat.model import Model
2222
from torchchat.utils.build_utils import set_precision
@@ -28,6 +28,8 @@
2828
torch._inductor.config.triton.cudagraphs = True
2929
torch._dynamo.config.cache_size_limit = 100000
3030

31+
import lm_eval
32+
3133
from lm_eval.evaluator import evaluate
3234
from lm_eval.models.huggingface import HFLM as eval_wrapper
3335
from lm_eval.tasks import get_task_dict

torchchat/utils/scripts/install_utils.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ install_executorch_python_libs() {
9494
bash ./install_requirements.sh --pybind xnnpack
9595
fi
9696

97+
# TODO: figure out the root cause of 'AttributeError: module 'evaluate'
98+
# has no attribute 'utils'' error from evaluate CI jobs and remove
99+
# `import lm_eval` from torchchat.py since it requires a specific version
100+
# of numpy.
101+
pip install numpy=='1.26.4'
102+
97103
pip3 list
98104
popd
99105
}

0 commit comments

Comments
 (0)