Skip to content

Commit

Permalink
#5383: Rename demos/falcon7b to demos/falcon7b_common
Browse files Browse the repository at this point in the history
Signed-off-by: Salar Hosseini <[email protected]>
  • Loading branch information
skhorasganiTT committed Jul 18, 2024
1 parent 5440fc8 commit b8a7e74
Show file tree
Hide file tree
Showing 44 changed files with 77 additions and 77 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ models/demos @eyonland @arakhmati @cfjchu @xanderchin
models/demos/metal_BERT_large_11 @tt-aho @TT-BrianLiu
models/demos/wormhole @uaydonat @eyonland @AleksKnezevic @nsmithtt
models/demos/t3000 @uaydonat @AleksKnezevic @nsmithtt
models/demos/falcon7b @skhorasganiTT @djordje-tt @uaydonat @pavlejosipovic @pavlepopovic @s-jovic
models/demos/falcon7b_common @skhorasganiTT @djordje-tt @uaydonat @pavlejosipovic @pavlepopovic @s-jovic
models/demos/mamba @esmalTT @uaydonat @kpaigwar
models/demos/wormhole/falcon7b @skhorasganiTT @djordje-tt @uaydonat @pavlejosipovic @pavlepopovic @s-jovic
models/demos/wormhole/mistral7b @yieldthought @uaydonat @mtairum
Expand Down
2 changes: 1 addition & 1 deletion docs/source/ttnn/ttnn/get_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Install and build the project by following the instructions in the
^^^^^^^^^^^^^^^^^^^^^^^^^^

Get started with the Falcon 7B demo. Navigate to the `Falcon 7B demo folder
<https://github.com/tenstorrent/tt-metal/tree/main/models/demos/falcon7b>`_
<https://github.com/tenstorrent/tt-metal/tree/main/models/demos/wormhole/falcon7b>`_
for details.

You can also check our demos for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import ttnn
import tt_lib
from loguru import logger
from models.demos.falcon7b.reference.hf_modeling_falcon import FalconConfig
from models.demos.falcon7b.tt.falcon_causallm import TtFalconCausalLM
from models.demos.falcon7b.tt.model_config import get_model_config, model_config_entries
from models.demos.falcon7b.tests.test_utils import initialize_kv_cache, load_hf_model
from models.demos.falcon7b_common.reference.hf_modeling_falcon import FalconConfig
from models.demos.falcon7b_common.tt.falcon_causallm import TtFalconCausalLM
from models.demos.falcon7b_common.tt.model_config import get_model_config, model_config_entries
from models.demos.falcon7b_common.tests.test_utils import initialize_kv_cache, load_hf_model
from models.demos.utils.llm_demo_utils import create_benchmark_data, verify_perf, check_tokens_match
from models.utility_functions import (
disable_compilation_reports,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from transformers import AutoTokenizer

from models.falcon7b.reference.hf_modeling_falcon import FalconForCausalLM
from models.demos.falcon7b_common.reference.hf_modeling_falcon import FalconForCausalLM
import time

falcon1b = "tiiuae/falcon-rw-1b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import time
import numpy as np
import ttnn
from models.demos.falcon7b.tt.falcon_causallm import TtFalconCausalLM
from models.demos.falcon7b.tt.model_config import get_model_config
from models.demos.falcon7b.tests.test_utils import initialize_kv_cache, load_hf_model
from models.demos.falcon7b_common.tt.falcon_causallm import TtFalconCausalLM
from models.demos.falcon7b_common.tt.model_config import get_model_config
from models.demos.falcon7b_common.tests.test_utils import initialize_kv_cache, load_hf_model
from models.datasets.llm_dataset_utils import (
prepare_textgen_dataset,
prepare_textgen_dataloader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

import pytest
from models.demos.falcon7b.tests.perplexity.run_perplexity_falcon import run_test_perplexity
from models.demos.falcon7b_common.tests.perplexity.run_perplexity_falcon import run_test_perplexity
from models.utility_functions import is_wormhole_b0


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

import pytest
from models.demos.falcon7b.tests.perplexity.run_perplexity_falcon import run_test_perplexity
from models.demos.falcon7b_common.tests.perplexity.run_perplexity_falcon import run_test_perplexity


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from sklearn.metrics import top_k_accuracy_score

import tt_lib
from models.demos.falcon7b.tt.falcon_causallm import TtFalconCausalLM
from models.demos.falcon7b_common.tt.falcon_causallm import TtFalconCausalLM

from models.demos.falcon7b.tt.falcon_common import (
from models.demos.falcon7b_common.tt.falcon_common import (
PytorchFalconCausalLM,
)

from models.demos.falcon7b.tests.test_utils import (
from models.demos.falcon7b_common.tests.test_utils import (
get_rand_falcon_inputs,
concat_device_out_layer_present,
load_hf_model,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import pytest
from loguru import logger

from models.demos.falcon7b.tt.falcon_attention import TtFalconAttentionDecode, TtFalconAttentionPrefill
from models.demos.falcon7b.tt.model_config import get_model_config
from models.demos.falcon7b.tests.test_utils import get_rand_falcon_inputs, concat_device_outputs, load_hf_model
from models.demos.falcon7b_common.tt.falcon_attention import TtFalconAttentionDecode, TtFalconAttentionPrefill
from models.demos.falcon7b_common.tt.model_config import get_model_config
from models.demos.falcon7b_common.tests.test_utils import get_rand_falcon_inputs, concat_device_outputs, load_hf_model
from tests.tt_eager.python_api_testing.sweep_tests.comparison_funcs import (
comp_pcc,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import pytest
from loguru import logger

from models.demos.falcon7b.tt.falcon_causallm import TtFalconCausalLM
from models.demos.falcon7b_common.tt.falcon_causallm import TtFalconCausalLM

from models.demos.falcon7b.tt.model_config import (
from models.demos.falcon7b_common.tt.model_config import (
get_model_config,
)
from models.demos.falcon7b.tests.test_utils import (
from models.demos.falcon7b_common.tests.test_utils import (
get_rand_falcon_inputs,
concat_device_out_layer_present,
load_hf_model,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import pytest
from loguru import logger

from models.demos.falcon7b.tt.falcon_decoder import TtFalconDecoderLayer
from models.demos.falcon7b.tt.model_config import get_model_config
from models.demos.falcon7b.tests.test_utils import get_rand_falcon_inputs, concat_device_outputs, load_hf_model
from models.demos.falcon7b_common.tt.falcon_decoder import TtFalconDecoderLayer
from models.demos.falcon7b_common.tt.model_config import get_model_config
from models.demos.falcon7b_common.tests.test_utils import get_rand_falcon_inputs, concat_device_outputs, load_hf_model
from tests.tt_eager.python_api_testing.sweep_tests.comparison_funcs import (
comp_pcc,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import pytest

from models.demos.falcon7b.tests.run_falcon_end_to_end import (
from models.demos.falcon7b_common.tests.run_falcon_end_to_end import (
DECODE_CONFIG_TO_PCC,
PREFILL_CONFIG_TO_PCC,
DeviceSetup,
run_test_FalconCausalLM_end_to_end,
)
from models.demos.falcon7b.tt.model_config import get_model_config
from models.demos.falcon7b_common.tt.model_config import get_model_config
from models.perf.device_perf_utils import check_device_perf, prep_device_perf_report, run_device_perf
from models.utility_functions import disable_compilation_reports, disable_persistent_kernel_cache

Expand Down Expand Up @@ -85,7 +85,7 @@ def test_device_perf(seq_len, samples):
margin = 0.03
num_iterations = 1
model_config = "BFLOAT16-DRAM".lower()
command = f"pytest models/demos/falcon7b/tests/test_falcon_device_perf.py::test_device_perf_wh_bare_metal -k prefill_seq{seq_len}_{model_config}"
command = f"pytest models/demos/falcon7b_common/tests/test_falcon_device_perf.py::test_device_perf_wh_bare_metal -k prefill_seq{seq_len}_{model_config}"
cols = ["DEVICE FW", "DEVICE KERNEL", "DEVICE BRISC KERNEL"]
subdir = "falcon7b"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
import torch
import tt_lib
from loguru import logger
from models.demos.falcon7b.tests.test_utils import (
from models.demos.falcon7b_common.tests.test_utils import (
concat_device_out_layer_present,
get_rand_falcon_inputs,
load_hf_model,
)
from models.demos.falcon7b.tt.falcon_causallm import TtFalconCausalLM
from models.demos.falcon7b_common.tt.falcon_causallm import TtFalconCausalLM

# TODO: Remove this?
from models.demos.falcon7b.tt.falcon_common import PytorchFalconCausalLM
from models.demos.falcon7b.tt.model_config import get_model_config
from models.demos.falcon7b_common.tt.falcon_common import PytorchFalconCausalLM
from models.demos.falcon7b_common.tt.model_config import get_model_config
from models.utility_functions import (
disable_compilation_reports,
disable_persistent_kernel_cache,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import pytest
import torch
from loguru import logger
from models.demos.falcon7b.tt.falcon_mlp import TtFalconMLPDecode, TtFalconMLPPrefill
from models.demos.falcon7b.tt.model_config import get_model_config
from models.demos.falcon7b.tests.test_utils import load_hf_model
from models.demos.falcon7b_common.tt.falcon_mlp import TtFalconMLPDecode, TtFalconMLPPrefill
from models.demos.falcon7b_common.tt.model_config import get_model_config
from models.demos.falcon7b_common.tests.test_utils import load_hf_model
from models.utility_functions import get_devices_for_t3000, torch2tt_tensor, tt2torch_tensor
from tests.tt_eager.python_api_testing.sweep_tests.comparison_funcs import comp_allclose, comp_pcc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import torch
import pytest
from loguru import logger
from models.demos.falcon7b.tt.falcon_model import TtFalconModel
from models.demos.falcon7b.tt.model_config import (
from models.demos.falcon7b_common.tt.falcon_model import TtFalconModel
from models.demos.falcon7b_common.tt.model_config import (
get_model_config,
)
from models.demos.falcon7b.tests.test_utils import (
from models.demos.falcon7b_common.tests.test_utils import (
get_rand_falcon_inputs,
concat_device_out_layer_present,
load_hf_model,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import pytest
from loguru import logger

from models.demos.falcon7b.tt.falcon_causallm import TtFalconCausalLM
from models.demos.falcon7b_common.tt.falcon_causallm import TtFalconCausalLM

from models.demos.falcon7b.tt.model_config import (
from models.demos.falcon7b_common.tt.model_config import (
get_model_config,
)
from models.demos.falcon7b.tests.test_utils import load_hf_model
from models.demos.falcon7b_common.tests.test_utils import load_hf_model

from tests.tt_eager.python_api_testing.sweep_tests.comparison_funcs import (
comp_allclose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import pytest

from models.demos.falcon7b.tests.run_falcon_end_to_end import (
from models.demos.falcon7b_common.tests.run_falcon_end_to_end import (
DECODE_CONFIG_TO_PCC,
PREFILL_CONFIG_TO_PCC,
DeviceSetup,
run_test_FalconCausalLM_end_to_end,
)
from models.demos.falcon7b.tt.model_config import (
from models.demos.falcon7b_common.tt.model_config import (
get_model_config,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import torch
import ttnn
from models.demos.falcon7b.reference.hf_modeling_falcon import FalconForCausalLM
from models.demos.falcon7b_common.reference.hf_modeling_falcon import FalconForCausalLM
from models.utility_functions import torch2tt_tensor, tt2torch_tensor


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import ttnn

from models.demos.falcon7b.tt.falcon_lm_head import falcon_lm_head_matmul_2d
from models.demos.falcon7b_common.tt.falcon_lm_head import falcon_lm_head_matmul_2d
from models.utility_functions import comp_pcc, tt2torch_tensor, torch2tt_tensor


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from loguru import logger

import ttnn
from models.demos.falcon7b.tt.falcon_causallm import falcon_lm_head_matmul
from models.demos.falcon7b.tt.falcon_mlp import falcon_dense_4h_to_h_matmul, falcon_dense_h_to_4h_matmul
from models.demos.falcon7b.tt.model_utils import get_falcon_default_core_grid
from models.demos.falcon7b_common.tt.falcon_causallm import falcon_lm_head_matmul
from models.demos.falcon7b_common.tt.falcon_mlp import falcon_dense_4h_to_h_matmul, falcon_dense_h_to_4h_matmul
from models.demos.falcon7b_common.tt.model_utils import get_falcon_default_core_grid
from models.utility_functions import comp_pcc, tt2torch_tensor, torch2tt_tensor, skip_for_wormhole_b0
import torch
import math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from torch import nn
from typing import List, Optional, Tuple

from models.demos.falcon7b.tt.model_utils import get_falcon_default_core_grid
from models.demos.falcon7b_common.tt.model_utils import get_falcon_default_core_grid
import ttnn

from models.utility_functions import (
Expand All @@ -17,7 +17,7 @@
is_wormhole_b0,
)

from models.demos.falcon7b.tt.model_utils import get_weights_cached
from models.demos.falcon7b_common.tt.model_utils import get_weights_cached
from models.utility_functions import torch_tensors_to_tt_tensors


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import torch
import ttnn
from models.demos.falcon7b.tt.falcon_lm_head import falcon_lm_head_matmul_2d
from models.demos.falcon7b.tt.falcon_model import TtFalconModelShared
from models.demos.falcon7b.tt.model_utils import get_falcon_default_core_grid, get_weights_cached
from models.demos.falcon7b_common.tt.falcon_lm_head import falcon_lm_head_matmul_2d
from models.demos.falcon7b_common.tt.falcon_model import TtFalconModelShared
from models.demos.falcon7b_common.tt.model_utils import get_falcon_default_core_grid, get_weights_cached
from models.utility_functions import (
is_grayskull,
is_wormhole_b0,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import torch
import ttnn
from models.demos.falcon7b.tt.falcon_attention import TtFalconAttentionDecode, TtFalconAttentionPrefill
from models.demos.falcon7b.tt.falcon_mlp import TtFalconMLPDecode, TtFalconMLPPrefill
from models.demos.falcon7b.tt.model_utils import get_weights_cached, layernorm
from models.demos.falcon7b_common.tt.falcon_attention import TtFalconAttentionDecode, TtFalconAttentionPrefill
from models.demos.falcon7b_common.tt.falcon_mlp import TtFalconMLPDecode, TtFalconMLPPrefill
from models.demos.falcon7b_common.tt.model_utils import get_weights_cached, layernorm
from torch import nn


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import torch
import ttnn
from models.demos.falcon7b.tt.model_utils import get_falcon_default_core_grid, get_weights_cached
from models.demos.falcon7b_common.tt.model_utils import get_falcon_default_core_grid, get_weights_cached
from torch import nn
from models.utility_functions import (
is_grayskull,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

import tt_lib

from models.demos.falcon7b.tt.falcon_decoder import TtFalconDecoderLayer
from models.demos.falcon7b.tt.model_utils import get_weights_cached, layernorm
from models.demos.falcon7b_common.tt.falcon_decoder import TtFalconDecoderLayer
from models.demos.falcon7b_common.tt.model_utils import get_weights_cached, layernorm
from models.utility_functions import nearest_32, torch_tensors_to_tt_tensors
from models.demos.falcon7b.tests.test_utils import create_prefill_attn_mask_for_sharded_softmax
from models.demos.falcon7b_common.tests.test_utils import create_prefill_attn_mask_for_sharded_softmax
from tqdm import tqdm


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def get_model_config(model_config_str, prefill_seq_len=0, decode_batch_size=32):
"DEFAULT_DTYPE": dtype,
"DEFAULT_MEMCFG": mem_config,
"MOVE_DECODER_OUTPUT_BOOL": False,
"DEFAULT_CACHE_PATH": Path(f"models/demos/falcon7b/datasets/"),
"DEFAULT_CACHE_PATH": Path(f"models/demos/falcon7b_common/datasets/"),
} # DEFAULT_MEMCFG also used to determine banking for ttl.device.InitializeDevice
model_config.update({f"{key}_MEMCFG": mem_config for key in OP_KEYS if key not in NO_MEMCFG})
model_config.update({f"{key}_DTYPE": dtype for key in OP_KEYS if key not in NO_DTYPE})
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion models/demos/grayskull/falcon7b/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To run the model for a single user you can use the command line input:

To run the demo using prewritten prompts for a batch of 32 users run (currently only supports same token-length inputs):

`pytest --disable-warnings -q -s --input-method=json --input-path='models/demos/falcon7b/demo/input_data.json' models/demos/grayskull/falcon7b/demo_grayskull.py::test_demo[user_input0-default_mode_stochastic]`
`pytest --disable-warnings -q -s --input-method=json --input-path='models/demos/falcon7b_common/demo/input_data.json' models/demos/grayskull/falcon7b/demo_grayskull.py::test_demo[user_input0-default_mode_stochastic]`

## Inputs

Expand Down
2 changes: 1 addition & 1 deletion models/demos/grayskull/falcon7b/demo_grayskull.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

import pytest
from models.demos.falcon7b.demo.demo import run_falcon_demo_kv
from models.demos.falcon7b_common.demo.demo import run_falcon_demo_kv


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion models/demos/t3000/falcon7b/demo_t3000.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

import pytest
from models.demos.falcon7b.demo.demo import run_falcon_demo_kv
from models.demos.falcon7b_common.demo.demo import run_falcon_demo_kv
from models.utility_functions import is_wormhole_b0, get_devices_for_t3000


Expand Down
4 changes: 2 additions & 2 deletions models/demos/wormhole/falcon7b/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ To run the model for a single user you can use the command line input:

To run the demo using prewritten prompts for a batch of 32 users run (currently only supports same token-length inputs):

`pytest --disable-warnings -q -s --input-method=json --input-path='models/demos/falcon7b/demo/input_data.json' models/demos/wormhole/falcon7b/demo_wormhole.py::test_demo[user_input0-default_mode_1024_stochastic]`
`pytest --disable-warnings -q -s --input-method=json --input-path='models/demos/falcon7b_common/demo/input_data.json' models/demos/wormhole/falcon7b/demo_wormhole.py::test_demo[user_input0-default_mode_1024_stochastic]`

- **Decoding method**: The default decoding method is top-k/top-p (stochastic) sampling, however greedy decoding can also be used by replacing `stochastic` with `greedy` in the command above.

#### Performance Measurement Mode

To measure the performance of generating the `i`'th token while the KV cache is filled with `i-1` rows (where `i` is 128 in the command below):

`pytest --disable-warnings -q -s --input-method=json --input-path='models/demos/falcon7b/demo/input_data.json' models/demos/wormhole/falcon7b/demo_wormhole.py::test_demo[user_input0-perf_mode_128_stochastic]`
`pytest --disable-warnings -q -s --input-method=json --input-path='models/demos/falcon7b_common/demo/input_data.json' models/demos/wormhole/falcon7b/demo_wormhole.py::test_demo[user_input0-perf_mode_128_stochastic]`

- **Supported sequence lengths**: Currently `i` can only be set to 128, 1024, or 2048 for performance measurement mode.

Expand Down
2 changes: 1 addition & 1 deletion models/demos/wormhole/falcon7b/demo_wormhole.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

import pytest
from models.demos.falcon7b.demo.demo import run_falcon_demo_kv
from models.demos.falcon7b_common.demo.demo import run_falcon_demo_kv
from models.utility_functions import is_wormhole_b0


Expand Down
Loading

0 comments on commit b8a7e74

Please sign in to comment.