Skip to content

Update check_modular_conversion #37456

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

qubvel
Copy link
Member

@qubvel qubvel commented Apr 11, 2025

What does this PR do?

  • Adds multiprocessing for processing modular files (with and without fix_and_overwrite flag)
  • While checking, we always should overwrite files to be sure we did not miss any conversion

cc @ydshieh

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@qubvel qubvel requested a review from ydshieh April 14, 2025 09:54
@qubvel qubvel marked this pull request as ready for review April 14, 2025 09:54
@@ -23,7 +23,7 @@
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, "qwen3", "modular_qwen3_moe.py"),
os.path.join(MODEL_ROOT, "qwen3_moe", "modular_qwen3_moe.py"),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this test is not running on CI or failed.

@ydshieh
Copy link
Collaborator

ydshieh commented Apr 15, 2025

@qubvel Thank you for working on this.

I have admitted that I have to check the sort and dependency stuff here to get better understanding before I can judge correctly.

However I have a question: since we are running with multiple processes and each would modify some modeling files (i.e. generate them from modular files), it's not very clear to me that we are free of the race condition.

Maybe this won't happen from the way we (and you) handle the dependency and the control flow, but I find it's kind difficult to see the logic clearly.

I will leave some comments and questions in the PR changes so we can discuss in more specific positions.

# Remove the leafs from the graph (and from the deps of other nodes)
graph = {node: deps - leaf_nodes for node, deps in graph.items() if node not in leaf_nodes}

return [name_mapping[x] for x in sorting_list]
return sorting_list
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to me that the return type is changed from a list of string (of modular file paths) to list[list[str]].
Would be nice to explain this (i.e. the algorithm), and having a docstring about it (which is also missing on main).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caller (find_priority_list) to topological_sort still have ordered_files as variable, and its docstring is still A tuple with the ordered files (list). If I don't make mistake, this is no longer the case. So should update there too?

console.print(f"[bold yellow]Files per level: {tuple([len(x) for x in ordered_files])}[/bold yellow]")

try:
for dependency_level_files in ordered_files:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this moment, it's not easy to understand dependency_level_files and the what ordered_files is

if not args.check_all and guaranteed_no_diff(file_path, dependencies, models_in_diff):
skipped_models.add(file_path.split("/")[-2]) # save model folder name
else:
files_to_check.append(file_path)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so files_to_check a list of of modular file paths and there won't be any duplicated elements?

@qubvel
Copy link
Member Author

qubvel commented Apr 15, 2025

Thanks for the review, @ydshieh. That's definitely a fair point. I will add more comments to clarify the algorithm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants