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

Add CPU test for ModernBert Model #1130

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ jobs:
apt install -y libgl1 libglx-mesa0
set -o pipefail # Ensures that the exit code reflects the first command that fails
pip install pytest-split
pip show transformers
pytest -m push --splits ${{ inputs.test_group_cnt }} \
--group ${{ matrix.test_group_id }} \
--splitting-algorithm least_duration \
Expand Down
2 changes: 1 addition & 1 deletion env/core_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ scipy>=1.8.0
tensorflow==2.13
tensorboard==2.13
tf2onnx==1.15.1
transformers==4.47.0
transformers==4.48.1
# To avoid warning during the import
requests==2.28.2
urllib3==1.26.14
Expand Down
28 changes: 28 additions & 0 deletions forge/test/models/pytorch/text/modernbert/test_modernbert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC
#
# SPDX-License-Identifier: Apache-2.0
import pytest
from transformers import AutoTokenizer, ModernBertModel

variants = [
"answerdotai/ModernBERT-base",
]


@pytest.mark.nightly
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_modernbert_test_generation(variant):
tokenizer = AutoTokenizer.from_pretrained(variant)
framework_model = ModernBertModel.from_pretrained(variant) # , return_dict=False)
# model = AutoModelForMaskedLM.from_pretrained("answerdotai/ModernBERT-base")

inputs = tokenizer(
"Hello, my dog is cute",
return_tensors="pt",
max_length=150,
pad_to_max_length=True,
truncation=True,
)
outputs = framework_model(**inputs)

print("outputs:", outputs)
Loading