Skip to content

Conversation

plucked
Copy link

@plucked plucked commented Aug 28, 2023

This change adds the parameters used with accelerate and sends them as a payload to wandb.ai. That allows the parameters to show up in the table of runs and helps to get a better understanding of what the difference is between runs. It also uses the model's name as run name to give more context.

image

@saunderez
Copy link

You are a champion, I was looking at the wandb docs on the weekend because I wanted exactly this but got sidetracked when and never got back to it. Will pull and confirm everything works.

@rafstahelin
Copy link

Is there a way to set the Project Name in Additional Parameters of Kohya_ss rather than in train_utils?

@kohya-ss kohya-ss changed the base branch from main to dev2 September 18, 2023 12:06
@kohya-ss kohya-ss changed the base branch from dev2 to main September 18, 2023 12:18
@kohya-ss
Copy link
Owner

Thank you for this! I was checking the code before the merge and found the following code in accelerate.

https://github.com/huggingface/accelerate/blob/a87c95da9e3b416fb10a0e7dac7d397c015c3ed5/src/accelerate/accelerator.py#L2373

It is seemed to be better to use init_kwargs argument in init_trackers for logging configs to wandb.

Is it possible to rewrite this PR to use it? I think I can implement it, but unfortunately I'm not using wandb personally, I cannot test it.

@rafstahelin
Copy link

is this going to be merged?

@rockerBOO
Copy link
Contributor

Kohya is suggesting to move the config from wandb to the accelerator interface via init_kwargs/config as starting the wandb init outside the accelerator hook could cause side effects.

accelerator.init_trackers(
         project_name=args.output_name, 
         config=args
         init_kwargs={},
)

Then we could add a new argument to pass additional variables to wandb.

accelerator.init_trackers(
         project_name=args.output_name, 
         config=args,
         init_kwargs={'wandb': args.wandb_init_args},
)

Which would allow us to pass notes, tags and more described wandb.init

@rockerBOO rockerBOO mentioned this pull request Nov 5, 2023
@deepdelirious
Copy link

accelerator.init_trackers has the config argument just for this purpose. The wandb implementation calls wandb.config.update

@rockerBOO
Copy link
Contributor

I went through where we were using init_tracker already and added the args there. See #959

@kmacmcfarlane
Copy link

I also recently looked into how to do this. Great to see there's a PR already in-flight!

@FurkanGozukara
Copy link

Are you guys able to get any meaningful stats from logs for overtraining, undertraining?

@rafstahelin
Copy link

Can anyone offer me guidance?

I usually used

if args.wandb_api_key is not None: wandb.login(key=args.wandb_api_key) wandb.init(project="t1k0", name=args.output_name, config=args)
image

But now I am no longer getting the project name customised in wandb.

Has something changed in the code? Anyone?

@rafstahelin
Copy link

Kohya is suggesting to move the config from wandb to the accelerator interface via init_kwargs/config as starting the wandb init outside the accelerator hook could cause side effects.

accelerator.init_trackers(
         project_name=args.output_name, 
         config=args
         init_kwargs={},
)

Then we could add a new argument to pass additional variables to wandb.

accelerator.init_trackers(
         project_name=args.output_name, 
         config=args,
         init_kwargs={'wandb': args.wandb_init_args},
)

Which would allow us to pass notes, tags and more described wandb.init

how do i adjust the code now if there has been changes?

@rafstahelin
Copy link

Kohya is suggesting to move the config from wandb to the accelerator interface via init_kwargs/config as starting the wandb init outside the accelerator hook could cause side effects.

accelerator.init_trackers(
         project_name=args.output_name, 
         config=args
         init_kwargs={},
)

Then we could add a new argument to pass additional variables to wandb.

accelerator.init_trackers(
         project_name=args.output_name, 
         config=args,
         init_kwargs={'wandb': args.wandb_init_args},
)

Which would allow us to pass notes, tags and more described wandb.init

should this work in the additional parameters args: --log_tracker_name "finetuning" --wandb_run_name "myrun"
?

@VelocityRa
Copy link

Opened #1231 for this.

For now, @rafstahelin you can add the following above the accelerator.init_trackers call:

init_kwargs["wandb"] = {"name": args.output_name, "config": args}

@rafstahelin
Copy link

No longer necessary m. It sheen incorporated to gui a few releases back

@VelocityRa
Copy link

VelocityRa commented Apr 1, 2024

Not by default, you need to make a config for it afaict (of which I've seen no examples).

My PR makes it so if log_tracker_config isn't specified, all training options are exported out of the box.

@rafstahelin
Copy link

rafstahelin commented Apr 1, 2024 via email

@VelocityRa
Copy link

VelocityRa commented Apr 1, 2024

I'm on the latest kohya_ss version, and training parameters are not sent to wandb without my changes.
I don't care much about just the run name.

Also we are on the scripts (library) repo, not the GUI. Such change should happen here due to the way the wandb API works. Not the GUI.

@rafstahelin
Copy link

above the accelerator.init_trackers call:

you're absolutely right. Hadnt noticed the parameters were not being sent

@rafstahelin
Copy link

I'm on the latest kohya_ss version, and training parameters are not sent to wandb without my changes. I don't care much about just the run name.

Also we are on the scripts (library) repo, not the GUI. Such change should happen here due to the way the wandb API works. Not the GUI.

right on thank you

@rafstahelin
Copy link

Not by default, you need to make a config for it afaict (of which I've seen no examples).

My PR makes it so if log_tracker_config isn't specified, all training options are exported out of the box.

cool will be running with your suggestion for the time being. do you know when it will be merged?

@rafstahelin
Copy link

rafstahelin commented Apr 3, 2024 via email

@rafstahelin
Copy link

rafstahelin commented Apr 3, 2024 via email

@VelocityRa
Copy link

VelocityRa commented Apr 3, 2024

see my PR: https://github.com/kohya-ss/sd-scripts/pull/1231/files#diff-62cf7de156b588b9acd7af26941d7bb189368221946c8b5e63f69df5cda56f39R705-R707

then:
log_tracker_name -> wandb project name
wandb_run_name -> wandb run name
don't specify log_tracker_config

@rafstahelin
Copy link

see my PR: https://github.com/kohya-ss/sd-scripts/pull/1231/files#diff-62cf7de156b588b9acd7af26941d7bb189368221946c8b5e63f69df5cda56f39R705-R707

then: log_tracker_name -> wandb project name wandb_run_name -> wandb run name don't specify log_tracker_config

awesome that's working now, thanksalthough, there seems to be an issue now with samplingit doesn't work on steps, only on Sample every x epochs. 
Is this possible? 

@rafstahelin
Copy link

see my PR: https://github.com/kohya-ss/sd-scripts/pull/1231/files#diff-62cf7de156b588b9acd7af26941d7bb189368221946c8b5e63f69df5cda56f39R705-R707

then: log_tracker_name -> wandb project name wandb_run_name -> wandb run name don't specify log_tracker_config

awesome that's working now, though not all. And what's worst, I am not seeing samples being processed anymore.
sdxl_train.zip

And not only that i dont see all the parameters

I've added my sdxl_train.py Maybe i am doing something wrong in the code i added

image

So for the moment, i will stick to the limited gui ouptut to wandb, unless you could possibly point out my obvious mistake

thank you

@rafstahelin
Copy link

rafstahelin commented Apr 6, 2024 via email

@plucked plucked closed this by deleting the head repository Apr 22, 2025
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.

9 participants