first commit
Some checks failed
Self-hosted runner (nightly-past-ci-caller) / Get number (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.11 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.10 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.9 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.8 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.7 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.6 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.5 (push) Has been cancelled
Self-hosted runner (benchmark) / Benchmark (aws-g5-4xlarge-cache) (push) Has been cancelled
Build documentation / build (push) Has been cancelled
Build documentation / build_other_lang (push) Has been cancelled
CodeQL Security Analysis / CodeQL Analysis (push) Has been cancelled
New model PR merged notification / Notify new model (push) Has been cancelled
PR CI / pr-ci (push) Has been cancelled
Slow tests on important models (on Push - A10) / Get all modified files (push) Has been cancelled
Secret Leaks / trufflehog (push) Has been cancelled
Update Transformers metadata / build_and_package (push) Has been cancelled
Slow tests on important models (on Push - A10) / Model CI (push) Has been cancelled
Check Tiny Models / Check tiny models (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Model CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Pipeline CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Example CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / DeepSpeed CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Trainer/FSDP CI (push) Has been cancelled
Nvidia CI - Flash Attn / Setup (push) Has been cancelled
Nvidia CI - Flash Attn / Model CI (push) Has been cancelled
Nvidia CI / Setup (push) Has been cancelled
Nvidia CI / Model CI (push) Has been cancelled
Nvidia CI / Torch pipeline CI (push) Has been cancelled
Nvidia CI / Example CI (push) Has been cancelled
Nvidia CI / Trainer/FSDP CI (push) Has been cancelled
Nvidia CI / DeepSpeed CI (push) Has been cancelled
Nvidia CI / Quantization CI (push) Has been cancelled
Nvidia CI / Kernels CI (push) Has been cancelled
Doctests / Setup (push) Has been cancelled
Doctests / Call doctest jobs (push) Has been cancelled
Doctests / Send results to webhook (push) Has been cancelled
Extras Smoke Test / Get supported Python versions (push) Has been cancelled
Extras Smoke Test / Test extras on Python ${{ matrix.python-version }} (push) Has been cancelled
Extras Smoke Test / Check Slack token availability (push) Has been cancelled
Extras Smoke Test / Notify failures to Slack (push) Has been cancelled
Self-hosted runner (AMD scheduled CI caller) / Trigger Scheduled AMD CI (push) Has been cancelled
Stale Bot / Close Stale Issues (push) Has been cancelled
Some checks failed
Self-hosted runner (nightly-past-ci-caller) / Get number (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.11 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.10 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.9 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.8 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.7 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.6 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.5 (push) Has been cancelled
Self-hosted runner (benchmark) / Benchmark (aws-g5-4xlarge-cache) (push) Has been cancelled
Build documentation / build (push) Has been cancelled
Build documentation / build_other_lang (push) Has been cancelled
CodeQL Security Analysis / CodeQL Analysis (push) Has been cancelled
New model PR merged notification / Notify new model (push) Has been cancelled
PR CI / pr-ci (push) Has been cancelled
Slow tests on important models (on Push - A10) / Get all modified files (push) Has been cancelled
Secret Leaks / trufflehog (push) Has been cancelled
Update Transformers metadata / build_and_package (push) Has been cancelled
Slow tests on important models (on Push - A10) / Model CI (push) Has been cancelled
Check Tiny Models / Check tiny models (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Model CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Pipeline CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Example CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / DeepSpeed CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Trainer/FSDP CI (push) Has been cancelled
Nvidia CI - Flash Attn / Setup (push) Has been cancelled
Nvidia CI - Flash Attn / Model CI (push) Has been cancelled
Nvidia CI / Setup (push) Has been cancelled
Nvidia CI / Model CI (push) Has been cancelled
Nvidia CI / Torch pipeline CI (push) Has been cancelled
Nvidia CI / Example CI (push) Has been cancelled
Nvidia CI / Trainer/FSDP CI (push) Has been cancelled
Nvidia CI / DeepSpeed CI (push) Has been cancelled
Nvidia CI / Quantization CI (push) Has been cancelled
Nvidia CI / Kernels CI (push) Has been cancelled
Doctests / Setup (push) Has been cancelled
Doctests / Call doctest jobs (push) Has been cancelled
Doctests / Send results to webhook (push) Has been cancelled
Extras Smoke Test / Get supported Python versions (push) Has been cancelled
Extras Smoke Test / Test extras on Python ${{ matrix.python-version }} (push) Has been cancelled
Extras Smoke Test / Check Slack token availability (push) Has been cancelled
Extras Smoke Test / Notify failures to Slack (push) Has been cancelled
Self-hosted runner (AMD scheduled CI caller) / Trigger Scheduled AMD CI (push) Has been cancelled
Stale Bot / Close Stale Issues (push) Has been cancelled
This commit is contained in:
75
tests/repo_utils/modular/test_conversion_order.py
Normal file
75
tests/repo_utils/modular/test_conversion_order.py
Normal file
@@ -0,0 +1,75 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||
sys.path.append(os.path.join(ROOT_DIR, "utils"))
|
||||
|
||||
import create_dependency_mapping # noqa: E402
|
||||
|
||||
|
||||
# This is equivalent to `all` in the current library state (as of 09/01/2025)
|
||||
MODEL_ROOT = os.path.join("src", "transformers", "models")
|
||||
FILES_TO_PARSE = [
|
||||
os.path.join(MODEL_ROOT, "starcoder2", "modular_starcoder2.py"),
|
||||
os.path.join(MODEL_ROOT, "gemma", "modular_gemma.py"),
|
||||
os.path.join(MODEL_ROOT, "olmo2", "modular_olmo2.py"),
|
||||
os.path.join(MODEL_ROOT, "diffllama", "modular_diffllama.py"),
|
||||
os.path.join(MODEL_ROOT, "granite", "modular_granite.py"),
|
||||
os.path.join(MODEL_ROOT, "gemma2", "modular_gemma2.py"),
|
||||
os.path.join(MODEL_ROOT, "mixtral", "modular_mixtral.py"),
|
||||
os.path.join(MODEL_ROOT, "olmo", "modular_olmo.py"),
|
||||
os.path.join(MODEL_ROOT, "rt_detr", "modular_rt_detr.py"),
|
||||
os.path.join(MODEL_ROOT, "qwen2", "modular_qwen2.py"),
|
||||
os.path.join(MODEL_ROOT, "qwen3", "modular_qwen3.py"),
|
||||
os.path.join(MODEL_ROOT, "llava_next_video", "modular_llava_next_video.py"),
|
||||
os.path.join(MODEL_ROOT, "cohere2", "modular_cohere2.py"),
|
||||
os.path.join(MODEL_ROOT, "modernbert", "modular_modernbert.py"),
|
||||
os.path.join(MODEL_ROOT, "colpali", "modular_colpali.py"),
|
||||
os.path.join(MODEL_ROOT, "deformable_detr", "modular_deformable_detr.py"),
|
||||
os.path.join(MODEL_ROOT, "aria", "modular_aria.py"),
|
||||
os.path.join(MODEL_ROOT, "ijepa", "modular_ijepa.py"),
|
||||
os.path.join(MODEL_ROOT, "bamba", "modular_bamba.py"),
|
||||
os.path.join(MODEL_ROOT, "dinov2_with_registers", "modular_dinov2_with_registers.py"),
|
||||
os.path.join(MODEL_ROOT, "instructblipvideo", "modular_instructblipvideo.py"),
|
||||
os.path.join(MODEL_ROOT, "glm", "modular_glm.py"),
|
||||
os.path.join(MODEL_ROOT, "phi", "modular_phi.py"),
|
||||
os.path.join(MODEL_ROOT, "mistral", "modular_mistral.py"),
|
||||
os.path.join(MODEL_ROOT, "phi3", "modular_phi3.py"),
|
||||
os.path.join(MODEL_ROOT, "cohere", "modular_cohere.py"),
|
||||
os.path.join(MODEL_ROOT, "glm4", "modular_glm4.py"),
|
||||
os.path.join(MODEL_ROOT, "seed_oss", "modular_seed_oss.py"),
|
||||
]
|
||||
|
||||
|
||||
def appear_after(model1: str, model2: str, priority_list: list[list[str]]) -> bool:
|
||||
"""Return True if `model1` appear after `model2` in `priority_list`."""
|
||||
model1_index, model2_index = None, None
|
||||
for i, level in enumerate(priority_list):
|
||||
if model1 in level:
|
||||
model1_index = i
|
||||
if model2 in level:
|
||||
model2_index = i
|
||||
if model1_index is None or model2_index is None:
|
||||
raise ValueError(f"Model {model1} or {model2} not found in {priority_list}")
|
||||
return model1_index > model2_index
|
||||
|
||||
|
||||
class ConversionOrderTest(unittest.TestCase):
|
||||
def test_conversion_order(self):
|
||||
# Find the order
|
||||
priority_list, _ = create_dependency_mapping.find_priority_list(FILES_TO_PARSE)
|
||||
# Extract just the model names (list of lists)
|
||||
model_priority_list = [[file.split("/")[-2] for file in level] for level in priority_list]
|
||||
|
||||
# These are based on what the current library order should be (as of 09/01/2025)
|
||||
self.assertTrue(appear_after("mixtral", "mistral", model_priority_list))
|
||||
self.assertTrue(appear_after("gemma2", "gemma", model_priority_list))
|
||||
self.assertTrue(appear_after("starcoder2", "mistral", model_priority_list))
|
||||
self.assertTrue(appear_after("olmo2", "olmo", model_priority_list))
|
||||
self.assertTrue(appear_after("diffllama", "mistral", model_priority_list))
|
||||
self.assertTrue(appear_after("cohere2", "gemma2", model_priority_list))
|
||||
self.assertTrue(appear_after("cohere2", "cohere", model_priority_list))
|
||||
self.assertTrue(appear_after("phi3", "mistral", model_priority_list))
|
||||
self.assertTrue(appear_after("glm4", "glm", model_priority_list))
|
||||
Reference in New Issue
Block a user