Skip to content

Auto-log parallelism info to wandb.config using HF Accelerate#40055

Open
WoosungMyung wants to merge 1 commit intohuggingface:mainfrom
WoosungMyung:feat/wandb-parallelism-config
Open

Auto-log parallelism info to wandb.config using HF Accelerate#40055
WoosungMyung wants to merge 1 commit intohuggingface:mainfrom
WoosungMyung:feat/wandb-parallelism-config

Conversation

@WoosungMyung
Copy link
Copy Markdown

What

This PR adds parallelism info non intrusively to WandbCallback so that, when Hugging Face Accelerate is in use, the callback automatically logs the parallelism sizes to wandb.config at train start.

Why

Users frequently want their distributed setup (e.g., tp_size, dp_replicate_size) with Weights & Biases for reproducibility and experiment analysis. Today, this is typically done manually on the user side. This change standardizes and automates that step.

This PR is from Issue #39882
@Rocketknight1 @MekkCyber

Thanks for you precious time for reviewing this PR.

Signed-off-by: WoosungMyung <dntjd517@naver.com>
@Rocketknight1
Copy link
Copy Markdown
Member

cc @SunMarc

Copy link
Copy Markdown
Contributor

@MekkCyber MekkCyber left a comment

Choose a reason for hiding this comment

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

Thanks a lot 🤗 Sounds good ! left some nits

# Auto log Accelerate parallelism info to wandb.config
if self._initialized and state.is_world_process_zero and getattr(self._wandb, "run", None) is not None:
acc = getattr(model, "accelerator", None)
pc = getattr(acc, "parallelism_config", None) if acc is not None else None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think the if check is necessary since we can use getattr with NoneType as well in python

Suggested change
pc = getattr(acc, "parallelism_config", None) if acc is not None else None
pc = getattr(acc, "parallelism_config", None)

if self._initialized and state.is_world_process_zero and getattr(self._wandb, "run", None) is not None:
acc = getattr(model, "accelerator", None)
pc = getattr(acc, "parallelism_config", None) if acc is not None else None
sizes = getattr(pc, "_sizes", None) if pc is not None else None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
sizes = getattr(pc, "_sizes", None) if pc is not None else None
sizes = getattr(pc, "_sizes", None)

@MekkCyber MekkCyber requested a review from SunMarc August 26, 2025 12:05
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