Skip to content

script: accelerate.py function: clip_grad_norm_ if parameters == [p for p in model.parameters()]: RuntimeError: Boolean value of Tensor with more than one value is ambiguous #3789

@Xingyuxingyu

Description

@Xingyuxingyu

System Info

accelerate 1.10.1
os: Linux #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
python: 3.10
numpy: 1.26.0
torch version: 2.5.1+cu118

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • One of the scripts in the examples/ folder of Accelerate or an officially supported no_trainer script in the examples folder of the transformers repo (such as run_no_trainer_glue.py)
  • My own task or dataset (give details below)

Reproduction

accelerate fsdp model
if accelerator.sync_gradients and train_config.max_grad_norm > 0:
all_norm = accelerator.clip_grad_norm_(model.parameters(), train_config.max_grad_norm)

Expected behavior

No RuntimeError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions