[modular] speedup check_modular_conversion with multiprocessing (#37456)
* Change topological sort to return level-based output (lists of lists) * Update main for modular converter * Update test * update check_modular_conversion * Update gitignore * Fix missing conversion for glm4 * Update * Fix error msg * Fixup * fix docstring * update docs * Add comment * delete qwen3_moe
This commit is contained in:
committed by
GitHub
parent
571a8c2131
commit
fe1a5b73e6
@@ -38,20 +38,29 @@ FILES_TO_PARSE = [
|
||||
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"),
|
||||
]
|
||||
|
||||
|
||||
def appear_after(model1: str, model2: str, priority_list: list[str]) -> bool:
|
||||
def appear_after(model1: str, model2: str, priority_list: list[list[str]]) -> bool:
|
||||
"""Return True if `model1` appear after `model2` in `priority_list`."""
|
||||
return priority_list.index(model1) > priority_list.index(model2)
|
||||
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
|
||||
model_priority_list = [file.rsplit("modular_")[-1].replace(".py", "") for file in priority_list]
|
||||
# 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))
|
||||
@@ -62,3 +71,4 @@ class ConversionOrderTest(unittest.TestCase):
|
||||
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