Skip to content

Fix AttributeError in textual_inversion_bf16 by adding --report_to arg#13528

Open
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix-textual-inversion-bf16-missing-report-to-arg
Open

Fix AttributeError in textual_inversion_bf16 by adding --report_to arg#13528
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix-textual-inversion-bf16-missing-report-to-arg

Conversation

@Ricardo-M-L
Copy link
Copy Markdown
Contributor

What this PR does

The Intel/BF16 textual_inversion_bf16.py script reads args.report_to at the top of main():

https://github.com/huggingface/diffusers/blob/main/examples/research_projects/intel_opts/textual_inversion/textual_inversion_bf16.py#L366-L378

def main():
    args = parse_args()

    if args.report_to == "wandb" and args.hub_token is not None:
        raise ValueError(
            "You cannot use both --report_to=wandb and --hub_token due to a security risk of exposing your token."
            " Please use \`hf auth login\` to authenticate with the Hub."
        )

    ...
    accelerator = Accelerator(
        gradient_accumulation_steps=args.gradient_accumulation_steps,
        mixed_precision=args.mixed_precision,
        log_with=args.report_to,
        project_config=accelerator_project_config,
    )

But --report_to is never defined on the parser (checked via grep 'add_argument' textual_inversion_bf16.py). Any invocation of the script therefore crashes immediately with:

AttributeError: 'Namespace' object has no attribute 'report_to'

Why this is a real bug

The check fires at the start of main(), before any training setup — the script is non-runnable as shipped.

Fix

The canonical examples/textual_inversion/textual_inversion.py already defines this exact argument with default "tensorboard" and the standard help text. Mirror that definition in the bf16 variant:

parser.add_argument(
    "--report_to",
    type=str,
    default="tensorboard",
    help=(
        'The integration to report the results and logs to. Supported platforms are `"tensorboard"`'
        ' (default), `"wandb"` and `"comet_ml"`. Use `"all"` to report to all integrations.'
    ),
)

Value and default match the canonical script, keeping behavior consistent across the two scripts.

Before submitting

  • Did you read the contributor guideline?
  • Was this discussed/approved via a Github issue or the forum? N/A — the script is dead-on-arrival.
  • Did you make sure to update the documentation with your changes? N/A.
  • Did you write any new necessary tests? N/A — restores baseline runnability.

Who can review?

@sayakpaul

`examples/research_projects/intel_opts/textual_inversion/textual_inversion_bf16.py`
reads `args.report_to` twice at the start of `main()`:

    if args.report_to == "wandb" and args.hub_token is not None:
        raise ValueError(...)
    ...
    accelerator = Accelerator(..., log_with=args.report_to, ...)

but `--report_to` is never defined on the parser, so any invocation of
the script raises

    AttributeError: 'Namespace' object has no attribute 'report_to'

immediately, before any training setup. The script is non-functional
as shipped — it cannot even be run.

The canonical `examples/textual_inversion/textual_inversion.py`
defines this exact argument (default="tensorboard") with the standard
help text. Port that `add_argument` call over so the bf16 variant can
actually run. Value and default match the canonical script for parity.
@github-actions github-actions Bot added examples size/S PR with diff < 50 LOC labels Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant