Skip to content

Conversation

SunMarc
Copy link
Member

@SunMarc SunMarc commented Sep 25, 2025

What does this PR do?

This PR removes deprecates code related to model_parallel feature in the modeling as well as in Trainer. This was a feature that was added only for a few models like t5 and gpt2 but eventually we switched to using device_map and tp now.
For the models, we removes is_parallelizable and model_parallel attributes and some deprecated methods.
For Trainer, we remove a small section related to model_parallel.

@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.

Comment on lines -500 to -519
if getattr(model, "is_parallelizable", False) and getattr(model, "model_parallel", False):
self.is_model_parallel = True
else:
self.is_model_parallel = False

self.is_model_parallel = False
if getattr(model, "hf_device_map", None) is not None:
devices = [device for device in set(model.hf_device_map.values()) if device not in ["cpu", "disk"]]
if len(devices) > 1:
self.is_model_parallel = True
elif len(devices) == 1:
self.is_model_parallel = self.args.device != torch.device(devices[0])
else:
self.is_model_parallel = False

# warn users
if self.is_model_parallel:
logger.info(
"You have loaded a model on multiple GPUs. `is_model_parallel` attribute will be force-set"
" to `True` to avoid any unexpected behavior such as device placement mismatching."
)
Copy link
Member Author

Choose a reason for hiding this comment

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

this is what changed in trainer cc @qgallouedec

@SunMarc SunMarc changed the title [v5] Remove bits related to model_parallel [v5] Remove model_parallel deprecated feature Sep 25, 2025
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: bloom, camembert, codegen, decision_transformer, falcon_mamba, gpt2, gpt_neo, gpt_neox_japanese, gptj, imagegpt, kosmos2_5, lilt, luke, mamba, modernbert_decoder, moshi

Copy link
Member

@Cyrilvallez Cyrilvallez left a comment

Choose a reason for hiding this comment

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

Nice cleanup, thanks a lot! 🤗 Happy to see it disappear!

@SunMarc SunMarc merged commit ad74fba into main Sep 29, 2025
26 checks passed
@SunMarc SunMarc deleted the fix-parallel branch September 29, 2025 14:14
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