Skip to content
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

Replace FSDP args #1517

Merged
merged 11 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions llmfoundry/command_utils/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def evaluate_model(
device_eval_batch_size: Union[int, float],
eval_gauntlet_config: Optional[Union[str, dict[str, Any]]],
eval_loader_config: Optional[Union[dict[str, Any], list[dict[str, Any]]]],
fsdp_config: Optional[dict[str, Any]],
parallelism_config: Optional[dict[str, Any]],
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should be deprecating and not hard deleting...

Copy link
Collaborator

Choose a reason for hiding this comment

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

CC: @dakinggg as well for input

loggers: list[LoggerDestination],
python_log_level: Optional[str],
precision: str,
Expand Down Expand Up @@ -99,6 +99,10 @@ def evaluate_model(
mosaicml_logger.log_metrics(metadata)
mosaicml_logger._flush_metadata(force_flush=True)

fsdp_config = parallelism_config.get(
'fsdp_config',
None,
) if parallelism_config else None
if fsdp_config and model.get('load_in_8bit', False):
raise ValueError(
'The FSDP config block is not supported when loading ' +
Expand Down Expand Up @@ -316,7 +320,7 @@ def evaluate(cfg: DictConfig) -> tuple[list[Trainer], pd.DataFrame]:
device_eval_batch_size=eval_config.device_eval_batch_size,
eval_gauntlet_config=eval_gauntlet_config,
eval_loader_config=eval_loader_config,
fsdp_config=fsdp_config,
parallelism_config={'fsdp': fsdp_config},
loggers=loggers,
python_log_level=eval_config.python_log_level,
precision=eval_config.precision,
Expand Down
5 changes: 3 additions & 2 deletions tests/a_scripts/inference/test_convert_composer_to_hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,8 @@ def test_huggingface_conversion_callback(
model=original_model,
device='gpu',
precision=trainer_precision,
fsdp_config=fsdp_config if fsdp_state_dict_type is not None else None,
parallelism_config={'fsdp': fsdp_config}
if fsdp_state_dict_type is not None else None,
train_dataloader=train_dataloader,
save_folder=os.path.join(tmp_path, 'checkpoints'),
save_interval=save_interval,
Expand Down Expand Up @@ -1469,7 +1470,7 @@ def test_mptmoe_huggingface_conversion_callback(
trainer = Trainer(
model=original_model,
device='gpu',
fsdp_config=fsdp_config,
parallelism_config={'fsdp': fsdp_config},
train_dataloader=train_dataloader,
save_folder=os.path.join(tmp_path, 'checkpoints'),
save_interval=save_interval,
Expand Down
2 changes: 1 addition & 1 deletion tests/models/hf/test_fsdp_weight_tying.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_fsdp_weight_tying(
trainer = Trainer(
model=original_model,
device='gpu',
fsdp_config=fsdp_config,
parallelism_config={'fsdp': fsdp_config},
train_dataloader=[],
device_train_microbatch_size=1,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/models/hf/test_hf_peft_wrapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_lora_mixed_init(
trainer = Trainer(
model=original_model,
device='gpu',
fsdp_config=fsdp_config,
parallelism_config={'fsdp': fsdp_config},
train_dataloader=[],
device_train_microbatch_size=1,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_fsdp_act_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_fsdp_act_checkpoint(
trainer = Trainer(
model=model,
device='gpu',
fsdp_config=fsdp_config,
parallelism_config={'fsdp': fsdp_config},
)

assert trainer.state.fsdp_enabled
Expand Down
Loading