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

#0: Update copyright year to 2024 #15655

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ To set up pre-commit on your local machine, follow these steps:
scripts. For Python files, we are to use this convention:

```
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0
```
Expand All @@ -485,7 +485,7 @@ To set up pre-commit on your local machine, follow these steps:
convention:

```
// SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
// SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.
//
// SPDX-License-Identifier: Apache-2.0
```
Expand Down
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion docs/source/tt-metalium/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion docs/source/tt-metalium/tools/device_program_profiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The kernel code for full buffer is in ``{$TT_METAL_HOME}/tt_metal/programming_ex
.. code-block:: c++
:linenos:

// SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
// SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.
//
// SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion docs/source/ttnn/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion infra/data_collection/cicd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion infra/data_collection/github/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion infra/data_collection/github/workflows.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion infra/data_collection/junit_xml_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion infra/machine_setup/scripts/setup_hugepages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/common/lightweightmodule.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/common/rmsnorm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0
import ttnn
Expand Down
2 changes: 1 addition & 1 deletion models/common/tests/test_rmsnorm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0
import os
Expand Down
2 changes: 1 addition & 1 deletion models/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
94 changes: 58 additions & 36 deletions models/datasets/dataset_squadv2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand All @@ -8,10 +8,20 @@
from datasets import load_dataset
from loguru import logger


class SQUADV2Dataset(Dataset):
"""Configurable SQuad-V2 Dataset."""

def __init__(self, dataset_question: Any , dataset_context: Any, dataset_reference: Any, tokenizer: Any, seq_len: int, attention_mask: bool, token_type_ids: bool):
def __init__(
self,
dataset_question: Any,
dataset_context: Any,
dataset_reference: Any,
tokenizer: Any,
seq_len: int,
attention_mask: bool,
token_type_ids: bool,
):
"""Init and preprocess SST-2 dataset.

Parameters
Expand All @@ -30,7 +40,8 @@ def __init__(self, dataset_question: Any , dataset_context: Any, dataset_referen

self.data = []
for i in range(len(dataset_question)):
self.data.append((
self.data.append(
(
tokenizer.batch_encode_plus(
zip(dataset_question[i], dataset_context[i]),
max_length=seq_len,
Expand All @@ -39,13 +50,12 @@ def __init__(self, dataset_question: Any , dataset_context: Any, dataset_referen
return_attention_mask=attention_mask,
return_token_type_ids=token_type_ids,
return_tensors="pt",
)
, dataset_reference[i]
, dataset_question[i]
, dataset_context[i])
),
dataset_reference[i],
dataset_question[i],
dataset_context[i],
)


)

def __len__(self):
"""Return length of dataset.
Expand Down Expand Up @@ -74,19 +84,18 @@ def __getitem__(self, index: int):
return X



def squad_divide_chunks(dataset_question, dataset_context, dataset_reference, batch):
dataset_question_b = []
dataset_context_b = []
dataset_reference_b = []
for i in range(0, len(dataset_question), batch):
dataset_question_b.append(dataset_question[i:i + batch])
dataset_context_b.append(dataset_context[i:i + batch])
dataset_reference_b.append(dataset_reference[i:i + batch])
dataset_question_b.append(dataset_question[i : i + batch])
dataset_context_b.append(dataset_context[i : i + batch])
dataset_reference_b.append(dataset_reference[i : i + batch])
return dataset_question_b, dataset_context_b, dataset_reference_b


def squadv2_1K_samples_input(tokenizer, seq_len, attention_mask, token_type_ids, microbatch=8):
def squadv2_1K_samples_input(tokenizer, seq_len, attention_mask, token_type_ids, microbatch=8):
squadv2_dataset = load_dataset("squad_v2", use_auth_token=False, streaming=True)["validation"]
# squadv2_dataset = load_dataset("squad_v2", use_auth_token=True, streaming=True)["validation"]

Expand All @@ -97,23 +106,33 @@ def squadv2_1K_samples_input(tokenizer, seq_len, attention_mask, token_type_ids,

for _ in range(2048):
dataset_sgl = next(dataset_iter)
if len(dataset_sgl['answers']['text']) > 0:
dataset_question.append(dataset_sgl['question'])
dataset_context.append(dataset_sgl['context'])
dataset_reference.append({'answers': dataset_sgl['answers'], 'id': dataset_sgl['id']})
if len(dataset_sgl["answers"]["text"]) > 0:
dataset_question.append(dataset_sgl["question"])
dataset_context.append(dataset_sgl["context"])
dataset_reference.append({"answers": dataset_sgl["answers"], "id": dataset_sgl["id"]})
if len(dataset_question) == 1024:
logger.info("SQuADv2 1024 samples load ..done")
break

dataset_question, dataset_context, dataset_reference = squad_divide_chunks(dataset_question, dataset_context, dataset_reference, microbatch)
dataset_processed = SQUADV2Dataset(dataset_question, dataset_context, dataset_reference, tokenizer=tokenizer, seq_len=seq_len, attention_mask=attention_mask, token_type_ids=token_type_ids)
dataset_question, dataset_context, dataset_reference = squad_divide_chunks(
dataset_question, dataset_context, dataset_reference, microbatch
)
dataset_processed = SQUADV2Dataset(
dataset_question,
dataset_context,
dataset_reference,
tokenizer=tokenizer,
seq_len=seq_len,
attention_mask=attention_mask,
token_type_ids=token_type_ids,
)

return dataset_processed



def squadv2_answer_decode_batch(HF_model, tokenizer, nlp, references, cpu_out, tt_untilized_output, BATCH_SIZE, question, context):

def squadv2_answer_decode_batch(
HF_model, tokenizer, nlp, references, cpu_out, tt_untilized_output, BATCH_SIZE, question, context
):
tt_predictions = []
cpu_predictions = []

Expand All @@ -123,7 +142,6 @@ def squadv2_answer_decode_batch(HF_model, tokenizer, nlp, references, cpu_out, t
examples = nlp._args_parser(input_q)

for i in range(BATCH_SIZE):

logger.info(f"--REF-- {references[i]['answers']['text']}")

answer_start_scores = cpu_out["start_logits"][i]
Expand All @@ -144,25 +162,29 @@ def squadv2_answer_decode_batch(HF_model, tokenizer, nlp, references, cpu_out, t
}

pt_res = {
"start": answer_start_scores,
"end": answer_end_scores,
"example": single_input["example"],
**single_input["inputs"],
}
"start": answer_start_scores,
"end": answer_end_scores,
"example": single_input["example"],
**single_input["inputs"],
}
cpu_answer_nlp = nlp.postprocess([pt_res], **postprocess_params)["answer"]

tt_res = {
"start": tt_start_logits,
"end": tt_end_logits,
"example": single_input["example"],
**single_input["inputs"],
}
"start": tt_start_logits,
"end": tt_end_logits,
"example": single_input["example"],
**single_input["inputs"],
}
tt_answer_nlp = nlp.postprocess([tt_res], **postprocess_params)["answer"]

logger.info(f"--CPU-- {cpu_answer_nlp}")
logger.info(f"--TT--- {tt_answer_nlp}")
logger.info(f"=======")
cpu_predictions.append({'prediction_text': cpu_answer_nlp, 'id': references[i]['id'], 'no_answer_probability': 0.})
tt_predictions.append({'prediction_text': tt_answer_nlp, 'id': references[i]['id'], 'no_answer_probability': 0.})
cpu_predictions.append(
{"prediction_text": cpu_answer_nlp, "id": references[i]["id"], "no_answer_probability": 0.0}
)
tt_predictions.append(
{"prediction_text": tt_answer_nlp, "id": references[i]["id"], "no_answer_probability": 0.0}
)

return cpu_predictions, tt_predictions
2 changes: 1 addition & 1 deletion models/datasets/llm_dataset_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/bert/demo/demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/bert/reference/torch_bert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/bert/tests/test_perf_device_bert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/bert/tests/test_ttnn_optimized_bert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/bert/tt/ttnn_bert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/bert/tt/ttnn_optimized_bert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/bert/tt/ttnn_optimized_sharded_bert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/bert_tiny/demo/demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/bert_tiny/tests/test_performance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/bert_tiny/tt/bert_tiny.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/convnet_mnist/convnet_mnist_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/convnet_mnist/demo/demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/convnet_mnist/tests/test_performance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/convnet_mnist/tt/convnet_mnist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/distilbert/demo/demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/distilbert/distilbert_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/distilbert/tests/test_perf_distilbert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion models/demos/distilbert/tt/ttnn_optimized_distilbert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

Expand Down
Loading
Loading