Skip to content

Keep explicit model parallel on one multi-GPU machine - #1439

Open
chetana1410 wants to merge 1 commit into
huggingface:mainfrom
chetana1410:fix-single-node-model-parallel
Open

chetana1410 wants to merge 1 commit into
huggingface:mainfrom
chetana1410:fix-single-node-model-parallel

Conversation

@chetana1410

Copy link
Copy Markdown

init_model_parallel treated torch.cuda.device_count() // LOCAL_WORLD_SIZE == 1 as "not a distributed setting" and forced model_parallel=False. That ratio is how many GPUs each process can see. accelerate launch --num_processes=2 on a 2-GPU machine hits it, so an explicit model_parallel=True never reached device_map="auto".

The override now runs only when model parallel was not requested. model_parallel=True still builds the per-process GPU map. Leaving the flag unset, with one GPU per process, still keeps model parallel off. One process that can see several GPUs still turns it on. The same check in the VLM model is updated with it.

Fixes #895

Tests

pytest tests/unit/models/test_transformers_model.py::TestInitModelParallel

2 passed. The cases cover an explicit True on 2 processes and 2 GPUs, an unset flag in that same launch, and one process that can see both GPUs.

device_count // LOCAL_WORLD_SIZE is the number of GPUs each process can see. Treating 1 as "not distributed" forced model_parallel off for a normal single-node launch, including when it was set to True.

Fixes huggingface#895

Signed-off-by: Chetana Tanmayee Tadikamalla <chetana.tadikamalla@meltwater.com>
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.

[BUG] Model Parallelism is incorrectly disabled on single multi-GPU machines

1 participant