From df3e545e3777427c9ce53d500ac8b1dcd9daecf9 Mon Sep 17 00:00:00 2001 From: Colman Glagovich Date: Tue, 29 Oct 2024 06:02:08 -0700 Subject: [PATCH] #13368: Remove llama_models as submodule. Move its install to llama3 requirements.txt. --- .gitmodules | 3 --- models/demos/llama3/demo/multimodal_demo_chat.py | 4 ++-- models/demos/llama3/demo/multimodal_demo_text.py | 4 ++-- models/demos/llama3/reference/llama_models | 1 - models/demos/llama3/requirements.txt | 1 + .../demos/llama3/tests/multimodal/test_llama_conv2d_patch.py | 2 +- .../llama3/tests/multimodal/test_llama_cross_attention.py | 2 +- .../multimodal/test_llama_cross_attention_transformer_text.py | 2 +- .../test_llama_cross_attention_transformer_vision.py | 2 +- .../demos/llama3/tests/multimodal/test_llama_cross_block.py | 2 +- .../llama3/tests/multimodal/test_llama_image_attention.py | 4 ++-- .../demos/llama3/tests/multimodal/test_llama_image_block.py | 4 ++-- models/demos/llama3/tests/multimodal/test_llama_image_mlp.py | 2 +- .../llama3/tests/multimodal/test_llama_image_transformer.py | 4 ++-- models/demos/llama3/tests/multimodal/test_llama_layernorm.py | 2 +- .../tests/multimodal/test_llama_tile_position_embedding.py | 2 +- .../llama3/tests/multimodal/test_llama_vision_encoder.py | 2 +- .../demos/llama3/tests/multimodal/test_llama_vision_model.py | 4 ++-- models/demos/llama3/tt/multimodal/llama_vision_encoder.py | 2 +- models/demos/llama3/tt/multimodal/llama_vision_model.py | 4 ++-- tests/scripts/t3000/run_t3000_demo_tests.sh | 2 +- tests/scripts/t3000/run_t3000_frequent_tests.sh | 4 ++-- tests/scripts/t3000/run_t3000_unit_tests.sh | 4 ++-- 23 files changed, 30 insertions(+), 33 deletions(-) delete mode 160000 models/demos/llama3/reference/llama_models create mode 100644 models/demos/llama3/requirements.txt diff --git a/.gitmodules b/.gitmodules index 1c29f48e987..ab121e423f3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,6 +28,3 @@ [submodule "tt_metal/third_party/tt_llk_blackhole"] path = tt_metal/third_party/tt_llk_blackhole url = https://github.com/tenstorrent/tt-llk-bh.git -[submodule "models/demos/llama3/reference/llama_models"] - path = models/demos/llama3/reference/llama_models - url = https://github.com/tenstorrent/llama-models.git diff --git a/models/demos/llama3/demo/multimodal_demo_chat.py b/models/demos/llama3/demo/multimodal_demo_chat.py index 05ee6c4159d..a7d8c3ffe4b 100644 --- a/models/demos/llama3/demo/multimodal_demo_chat.py +++ b/models/demos/llama3/demo/multimodal_demo_chat.py @@ -9,9 +9,9 @@ from termcolor import cprint from models.demos.llama3.demo.multimodal_demo_text import create_multimodal_model -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.generation as llama_reference_generation +import llama_models.llama3.reference_impl.generation as llama_reference_generation -from models.demos.llama3.reference.llama_models.models.llama3.api.datatypes import ImageMedia, UserMessage +from llama_models.llama3.api.datatypes import ImageMedia, UserMessage THIS_DIR = Path(__file__).parent.parent.resolve() / "reference/llama_models/models/scripts/" diff --git a/models/demos/llama3/demo/multimodal_demo_text.py b/models/demos/llama3/demo/multimodal_demo_text.py index f2eada1966c..4d3dad9f7f2 100644 --- a/models/demos/llama3/demo/multimodal_demo_text.py +++ b/models/demos/llama3/demo/multimodal_demo_text.py @@ -8,9 +8,9 @@ from PIL import Image as PIL_Image from termcolor import cprint -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.generation as llama_reference_generation +import llama_models.llama3.reference_impl.generation as llama_reference_generation -from models.demos.llama3.reference.llama_models.models.llama3.api.datatypes import ImageMedia +from llama_models.llama3.api.datatypes import ImageMedia THIS_DIR = Path(__file__).parent.parent.resolve() / "reference/llama_models/models/scripts/" diff --git a/models/demos/llama3/reference/llama_models b/models/demos/llama3/reference/llama_models deleted file mode 160000 index c217d3eb10f..00000000000 --- a/models/demos/llama3/reference/llama_models +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c217d3eb10f6c01bbaa1aa7c714bb7c5ccf3b14f diff --git a/models/demos/llama3/requirements.txt b/models/demos/llama3/requirements.txt new file mode 100644 index 00000000000..e830cffd233 --- /dev/null +++ b/models/demos/llama3/requirements.txt @@ -0,0 +1 @@ +git+https://github.com/tenstorrent/llama-models.git@tt_metal_tag diff --git a/models/demos/llama3/tests/multimodal/test_llama_conv2d_patch.py b/models/demos/llama3/tests/multimodal/test_llama_conv2d_patch.py index d98d1c8613e..c38dd5ccb26 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_conv2d_patch.py +++ b/models/demos/llama3/tests/multimodal/test_llama_conv2d_patch.py @@ -25,7 +25,7 @@ ) from models.demos.llama3.tt.model_config import TtModelArgs -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_mod +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_mod @skip_for_grayskull("Requires wormhole_b0 to run") diff --git a/models/demos/llama3/tests/multimodal/test_llama_cross_attention.py b/models/demos/llama3/tests/multimodal/test_llama_cross_attention.py index ba0e269480f..14c7db894eb 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_cross_attention.py +++ b/models/demos/llama3/tests/multimodal/test_llama_cross_attention.py @@ -7,7 +7,7 @@ import os import ttnn -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_mod +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_mod from models.demos.llama3.tt.multimodal.llama_cross_attention import TtLlamaCrossAttention from models.demos.llama3.tt.model_config import TtModelArgs from models.demos.llama3.tt.llama_common import ( diff --git a/models/demos/llama3/tests/multimodal/test_llama_cross_attention_transformer_text.py b/models/demos/llama3/tests/multimodal/test_llama_cross_attention_transformer_text.py index f11165862b6..286e7bac509 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_cross_attention_transformer_text.py +++ b/models/demos/llama3/tests/multimodal/test_llama_cross_attention_transformer_text.py @@ -7,7 +7,7 @@ import os import ttnn -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_mod +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_mod from models.demos.llama3.tt.multimodal.llama_cross_attention_transformer_text import ( TtLlamaCrossAttentionTransformerText, ) diff --git a/models/demos/llama3/tests/multimodal/test_llama_cross_attention_transformer_vision.py b/models/demos/llama3/tests/multimodal/test_llama_cross_attention_transformer_vision.py index abcc1bd8156..a3f360bfa23 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_cross_attention_transformer_vision.py +++ b/models/demos/llama3/tests/multimodal/test_llama_cross_attention_transformer_vision.py @@ -7,7 +7,7 @@ import os import ttnn -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_mod +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_mod from models.demos.llama3.tt.multimodal.llama_cross_attention_transformer_vision import ( TtLlamaCrossAttentionTransformerVision, ) diff --git a/models/demos/llama3/tests/multimodal/test_llama_cross_block.py b/models/demos/llama3/tests/multimodal/test_llama_cross_block.py index f45f0eaa432..f64f9c98f7f 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_cross_block.py +++ b/models/demos/llama3/tests/multimodal/test_llama_cross_block.py @@ -7,7 +7,7 @@ import os import ttnn -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_mod +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_mod from models.demos.llama3.tt.multimodal.llama_cross_block import TtLlamaCrossAttentionTransformerBlock from models.demos.llama3.tt.model_config import TtModelArgs from models.demos.llama3.tt.llama_common import ( diff --git a/models/demos/llama3/tests/multimodal/test_llama_image_attention.py b/models/demos/llama3/tests/multimodal/test_llama_image_attention.py index 357f02a5b10..49f4ee58d2f 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_image_attention.py +++ b/models/demos/llama3/tests/multimodal/test_llama_image_attention.py @@ -7,8 +7,8 @@ import os import ttnn -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_mod -from models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal import encoder_utils +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_mod +from llama_models.llama3.reference_impl.multimodal import encoder_utils from models.demos.llama3.tt.multimodal.llama_image_attention import TtLlamaImageAttention from models.demos.llama3.tt.multimodal.llama_vision_encoder import pad_seq_one_tile, mask_tile_padding from models.demos.llama3.tt.model_config import TtModelArgs diff --git a/models/demos/llama3/tests/multimodal/test_llama_image_block.py b/models/demos/llama3/tests/multimodal/test_llama_image_block.py index bea85a0a16f..8eecfe156d6 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_image_block.py +++ b/models/demos/llama3/tests/multimodal/test_llama_image_block.py @@ -7,8 +7,8 @@ import os import ttnn -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_mod -from models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal import encoder_utils +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_mod +from llama_models.llama3.reference_impl.multimodal import encoder_utils from models.demos.llama3.tt.multimodal.llama_image_block import TtLlamaImageTransformerBlock from models.demos.llama3.tt.multimodal.llama_vision_encoder import pad_seq_one_tile, mask_tile_padding from models.demos.llama3.tt.model_config import TtModelArgs diff --git a/models/demos/llama3/tests/multimodal/test_llama_image_mlp.py b/models/demos/llama3/tests/multimodal/test_llama_image_mlp.py index 4181f9dfd0c..c6b65ef7f9d 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_image_mlp.py +++ b/models/demos/llama3/tests/multimodal/test_llama_image_mlp.py @@ -8,7 +8,7 @@ import os import ttnn -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_mod +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_mod from models.demos.llama3.tt.multimodal.llama_image_mlp import TtLlamaImageFeedForward from models.demos.llama3.tt.model_config import TtModelArgs from models.utility_functions import ( diff --git a/models/demos/llama3/tests/multimodal/test_llama_image_transformer.py b/models/demos/llama3/tests/multimodal/test_llama_image_transformer.py index d042eb1e683..b92d74290d6 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_image_transformer.py +++ b/models/demos/llama3/tests/multimodal/test_llama_image_transformer.py @@ -7,8 +7,8 @@ import os import ttnn -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_mod -from models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal import encoder_utils +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_mod +from llama_models.llama3.reference_impl.multimodal import encoder_utils from models.demos.llama3.tt.multimodal.llama_image_transformer import TtLlamaImageTransformer from models.demos.llama3.tt.model_config import TtModelArgs from models.demos.llama3.tt.multimodal.llama_vision_encoder import pad_seq_one_tile, mask_tile_padding diff --git a/models/demos/llama3/tests/multimodal/test_llama_layernorm.py b/models/demos/llama3/tests/multimodal/test_llama_layernorm.py index 23294782651..d52d9f415f3 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_layernorm.py +++ b/models/demos/llama3/tests/multimodal/test_llama_layernorm.py @@ -8,7 +8,7 @@ import os import ttnn -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_mod +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_mod from models.demos.llama3.tt.multimodal.llama_layernorm import TtLayerNorm # Updated import for LayerNorm from models.demos.llama3.tt.model_config import TtModelArgs from models.utility_functions import ( diff --git a/models/demos/llama3/tests/multimodal/test_llama_tile_position_embedding.py b/models/demos/llama3/tests/multimodal/test_llama_tile_position_embedding.py index 2249b684cbd..4ba64dd76ff 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_tile_position_embedding.py +++ b/models/demos/llama3/tests/multimodal/test_llama_tile_position_embedding.py @@ -31,7 +31,7 @@ ) from models.demos.llama3.tt.model_config import TtModelArgs -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_mod +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_mod @skip_for_grayskull("Requires wormhole_b0 to run") diff --git a/models/demos/llama3/tests/multimodal/test_llama_vision_encoder.py b/models/demos/llama3/tests/multimodal/test_llama_vision_encoder.py index 61824eb484e..b3790d498e5 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_vision_encoder.py +++ b/models/demos/llama3/tests/multimodal/test_llama_vision_encoder.py @@ -7,7 +7,7 @@ import os import ttnn -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_mod +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_mod from models.demos.llama3.tt.multimodal.llama_vision_encoder import TtLlamaVisionEncoder from models.demos.llama3.tt.model_config import TtModelArgs from models.demos.llama3.tt.llama_common import ( diff --git a/models/demos/llama3/tests/multimodal/test_llama_vision_model.py b/models/demos/llama3/tests/multimodal/test_llama_vision_model.py index e39555d4be1..f55a47891ac 100644 --- a/models/demos/llama3/tests/multimodal/test_llama_vision_model.py +++ b/models/demos/llama3/tests/multimodal/test_llama_vision_model.py @@ -8,9 +8,9 @@ from PIL import Image as PIL_Image from termcolor import cprint -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.generation as llama_reference_generation +import llama_models.llama3.reference_impl.generation as llama_reference_generation -from models.demos.llama3.reference.llama_models.models.llama3.api.datatypes import ImageMedia +from llama_models.llama3.api.datatypes import ImageMedia from models.utility_functions import ( comp_pcc, diff --git a/models/demos/llama3/tt/multimodal/llama_vision_encoder.py b/models/demos/llama3/tt/multimodal/llama_vision_encoder.py index 8ab71f831c3..ff8a71c7de5 100644 --- a/models/demos/llama3/tt/multimodal/llama_vision_encoder.py +++ b/models/demos/llama3/tt/multimodal/llama_vision_encoder.py @@ -24,7 +24,7 @@ synchronize_devices, ) -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.encoder_utils as encoder_utils +import llama_models.llama3.reference_impl.multimodal.encoder_utils as encoder_utils def to_2tuple(x): diff --git a/models/demos/llama3/tt/multimodal/llama_vision_model.py b/models/demos/llama3/tt/multimodal/llama_vision_model.py index 5a64637aad8..f96aba089c4 100644 --- a/models/demos/llama3/tt/multimodal/llama_vision_model.py +++ b/models/demos/llama3/tt/multimodal/llama_vision_model.py @@ -15,8 +15,8 @@ from torch import nn, Tensor -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.model as llama_reference_model -import models.demos.llama3.reference.llama_models.models.llama3.reference_impl.multimodal.image_transform as llama_reference_image_transforms +import llama_models.llama3.reference_impl.multimodal.model as llama_reference_model +import llama_models.llama3.reference_impl.multimodal.image_transform as llama_reference_image_transforms import ttnn from models.demos.llama3.tt.multimodal.llama_cross_attention_transformer_vision import ( diff --git a/tests/scripts/t3000/run_t3000_demo_tests.sh b/tests/scripts/t3000/run_t3000_demo_tests.sh index ad329ca2319..1ced36a3955 100755 --- a/tests/scripts/t3000/run_t3000_demo_tests.sh +++ b/tests/scripts/t3000/run_t3000_demo_tests.sh @@ -89,7 +89,7 @@ run_t3000_llama3_vision_tests() { t3k=T3K # Install Vision-specific packages - pip install -r models/demos/llama3/reference/llama_models/requirements.txt + pip install -r models/demos/llama3/requirements.txt for fake_device in "$n300" "$t3k"; do FAKE_DEVICE=$fake_device LLAMA_DIR=$llama11b WH_ARCH_YAML=$wh_arch_yaml pytest -n auto models/demos/llama3/demo/multimodal_demo_chat.py -k "tt and 1" --timeout 600; fail+=$? diff --git a/tests/scripts/t3000/run_t3000_frequent_tests.sh b/tests/scripts/t3000/run_t3000_frequent_tests.sh index 7b95c2570d9..b5fb7360c89 100755 --- a/tests/scripts/t3000/run_t3000_frequent_tests.sh +++ b/tests/scripts/t3000/run_t3000_frequent_tests.sh @@ -87,7 +87,7 @@ run_t3000_llama3.2-11b-vision_freq_tests() { llama11b=/mnt/MLPerf/tt_dnn-models/llama/Llama3.2-11B-Vision-Instruct/ # Install Vision-specific packages - pip install -r models/demos/llama3/reference/llama_models/requirements.txt + pip install -r models/demos/llama3/requirements.txt LLAMA_DIR=$llama11b WH_ARCH_YAML=$wh_arch_yaml pytest -n auto models/demos/llama3/tests/multimodal/test_llama_image_transformer.py ; fail+=$? LLAMA_DIR=$llama11b WH_ARCH_YAML=$wh_arch_yaml pytest -n auto models/demos/llama3/tests/multimodal/test_llama_vision_encoder.py ; fail+=$? @@ -117,7 +117,7 @@ run_t3000_spoof_n300_llama3.2-11b-vision_freq_tests() { fake_device=N300 # Install Vision-specific packages - pip install -r models/demos/llama3/reference/llama_models/requirements.txt + pip install -r models/demos/llama3/requirements.txt FAKE_DEVICE=$fake_device LLAMA_DIR=$llama11b WH_ARCH_YAML=$wh_arch_yaml pytest -n auto models/demos/llama3/tests/multimodal/test_llama_image_transformer.py ; fail+=$? FAKE_DEVICE=$fake_device LLAMA_DIR=$llama11b WH_ARCH_YAML=$wh_arch_yaml pytest -n auto models/demos/llama3/tests/multimodal/test_llama_vision_encoder.py ; fail+=$? diff --git a/tests/scripts/t3000/run_t3000_unit_tests.sh b/tests/scripts/t3000/run_t3000_unit_tests.sh index e15ebbb00df..e47a6b7a93c 100755 --- a/tests/scripts/t3000/run_t3000_unit_tests.sh +++ b/tests/scripts/t3000/run_t3000_unit_tests.sh @@ -164,7 +164,7 @@ run_t3000_llama3.2-11b-vision_unit_tests() { llama11b=/mnt/MLPerf/tt_dnn-models/llama/Llama3.2-11B-Vision-Instruct/ # Install Vision-specific packages - pip install -r models/demos/llama3/reference/llama_models/requirements.txt + pip install -r models/demos/llama3/requirements.txt LLAMA_DIR=$llama11b WH_ARCH_YAML=$wh_arch_yaml pytest -n auto models/demos/llama3/tests/multimodal/test_llama_image_mlp.py ; fail+=$? LLAMA_DIR=$llama11b WH_ARCH_YAML=$wh_arch_yaml pytest -n auto models/demos/llama3/tests/multimodal/test_llama_image_attention.py ; fail+=$? @@ -199,7 +199,7 @@ run_t3000_spoof_n300_llama3.2-11b-vision_unit_tests() { fake_device=N300 # Install Vision-specific packages - pip install -r models/demos/llama3/reference/llama_models/requirements.txt + pip install -r models/demos/llama3/requirements.txt FAKE_DEVICE=$fake_device LLAMA_DIR=$llama11b WH_ARCH_YAML=$wh_arch_yaml pytest -n auto models/demos/llama3/tests/multimodal/test_llama_image_mlp.py ; fail+=$? FAKE_DEVICE=$fake_device LLAMA_DIR=$llama11b WH_ARCH_YAML=$wh_arch_yaml pytest -n auto models/demos/llama3/tests/multimodal/test_llama_image_attention.py ; fail+=$?