Skip to content

Fix AttributeError in onnxruntime train_unconditional (args.report_to → args.logger)#13524

Open
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix-onnxruntime-unconditional-args-report-to
Open

Fix AttributeError in onnxruntime train_unconditional (args.report_to → args.logger)#13524
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix-onnxruntime-unconditional-args-report-to

Conversation

@Ricardo-M-L
Copy link
Copy Markdown
Contributor

What does this PR do?

The ORT variant of the unconditional training script,
examples/research_projects/onnxruntime/unconditional_image_generation/train_unconditional.py,
defines the tracker flag as --logger on the parser:

parser.add_argument(
    \"--logger\",
    type=str,
    default=\"tensorboard\",
    choices=[\"tensorboard\", \"wandb\"],
    ...
)

…but main() references a non-existent args.report_to twice:

if args.report_to == \"wandb\" and args.hub_token is not None:
    raise ValueError(
        \"You cannot use both --report_to=wandb and --hub_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,
)

Because no --report_to flag is registered, the args namespace never carries that attribute, so both references raise AttributeError: 'Namespace' object has no attribute 'report_to' at the very top of main(). The script can't run end-to-end.

The sibling non-ORT script examples/unconditional_image_generation/train_unconditional.py uses args.logger throughout. This PR aligns the ORT variant with that:

  • args.report_toargs.logger at both call sites
  • --report_to=wandb--logger=wandb in the error message text

Trivial one-word fix; no behavior change beyond letting the script actually start.

Before submitting

  • This PR fixes a typo or improves the docs.
  • Did you read the contributor guideline?
  • Did you make sure to update the documentation with your changes? (N/A — error-message text only)
  • Did you write any new necessary tests? (N/A — trivially verifiable attribute name)

Who can review?

@sayakpaul @stevhliu

The ORT example `examples/research_projects/onnxruntime/unconditional_image_generation/train_unconditional.py`
defines `--logger` (argparse line 196) but references `args.report_to`
in two places:

  * Line 280: `if args.report_to == "wandb" and args.hub_token is not None:`
  * Line 294: `log_with=args.report_to,`

Since there is no `--report_to` flag on the parser, both references crash
with `AttributeError: 'Namespace' object has no attribute 'report_to'`
as soon as `main()` starts — the script cannot run at all.

The sibling non-ORT script
`examples/unconditional_image_generation/train_unconditional.py` uses
`args.logger` consistently; this PR aligns the ORT variant with that
behavior, and updates the error message to refer to `--logger=wandb`
instead of the non-existent `--report_to=wandb`.
@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