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

Updated _encode_prompt_with_clip and encode_prompt in train_dreamboth_sd3 #9800

Merged
merged 11 commits into from
Nov 6, 2024

Conversation

SahilCarterr
Copy link
Contributor

What does this PR do?

Fixes #9773
Updated _encode_prompt_with_clip and encode_prompt in train_dreamboth_sd3 according to train_dreamboth_lora_sd3 for consistency

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed.
@sayakpaul @a-r-r-o-w

Copy link
Member

@a-r-r-o-w a-r-r-o-w left a comment

Choose a reason for hiding this comment

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

LGTM

@a-r-r-o-w a-r-r-o-w requested a review from sayakpaul October 30, 2024 05:24
Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Thanks!

@SahilCarterr
Copy link
Contributor Author

i don't see any errors in failing checks. @sayakpaul

@sayakpaul
Copy link
Member

Could you push an empty commit?

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@SahilCarterr
Copy link
Contributor Author

Pytorch Example CPU test is failing any suggestion how to fix this? @a-r-r-o-w

@a-r-r-o-w
Copy link
Member

The LoRA tests are failing. Here's the stacktrace:

stacktrace
_________________ DreamBoothSD3.test_dreambooth_checkpointing __________________
command = ['accelerate', 'launch', '--config_file', '/tmp/tmpnw4j3n3a/default_config.yml', 'examples/dreambooth/train_dreambooth_sd3.py', '--pretrained_model_name_or_path', ...]
return_stdout = False
    def run_command(command: List[str], return_stdout=False):
        """
        Runs `command` with `subprocess.check_output` and will potentially return the `stdout`. Will also properly capture
        if an error occurred while running `command`
        """
        try:
            output = subprocess.check_output(command, stderr=subprocess.STDOUT)
            if return_stdout:
                if hasattr(output, "decode"):
                    output = output.decode("utf-8")
                return output
        except subprocess.CalledProcessError as e:
>           raise SubprocessCallException(
                f"Command `{' '.join(command)}` failed with the following error:\n\n{e.output.decode()}"
            ) from e
E           test_examples_utils.SubprocessCallException: Command `accelerate launch --config_file /tmp/tmpnw4j3n3a/default_config.yml examples/dreambooth/train_dreambooth_sd3.py --pretrained_model_name_or_path hf-internal-testing/tiny-sd3-pipe --instance_data_dir docs/source/en/imgs --instance_prompt photo --resolution 64 --train_batch_size 1 --gradient_accumulation_steps 1 --max_train_steps 4 --learning_rate 5.0e-04 --scale_lr --lr_scheduler constant --lr_warmup_steps 0 --output_dir /tmp/tmpotpr0ant --checkpointing_steps=2 --seed=0` failed with the following error:
E           
E           10/30/2024 11:21:33 - INFO - __main__ - Distributed environment: NO
E           Num processes: 1
E           Process index: 0
E           Local process index: 0
E           Device: cpu
E           
E           Mixed precision type: no
E           
E           You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
E           You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
E           You are using a model of type t5 to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
E           {'base_image_seq_len', 'use_dynamic_shifting', 'base_shift', 'max_shift', 'max_image_seq_len'} was not found in config. Values will be initialized to default values.
E           {'mid_block_add_attention'} was not found in config. Values will be initialized to default values.
E           {'qk_norm', 'dual_attention_layers'} was not found in config. Values will be initialized to default values.
E           Traceback (most recent call last):
E             File "/__w/diffusers/diffusers/examples/dreambooth/train_dreambooth_sd3.py", line 1819, in <module>
E               main(args)
E             File "/__w/diffusers/diffusers/examples/dreambooth/train_dreambooth_sd3.py", line 1387, in main
E               instance_prompt_hidden_states, instance_pooled_prompt_embeds = compute_text_embeddings(
E             File "/__w/diffusers/diffusers/examples/dreambooth/train_dreambooth_sd3.py", line 1376, in compute_text_embeddings
E               prompt_embeds, pooled_prompt_embeds = encode_prompt(
E             File "/__w/diffusers/diffusers/examples/dreambooth/train_dreambooth_sd3.py", line 970, in encode_prompt
E               t5_prompt_embed = _encode_prompt_with_t5(
E           TypeError: _encode_prompt_with_t5() got an unexpected keyword argument 'text_input_ids'
E           Traceback (most recent call last):
E             File "/opt/venv/bin/accelerate", line 8, in <module>
E               sys.exit(main())
E             File "/opt/venv/lib/python3.10/site-packages/accelerate/commands/accelerate_cli.py", line 48, in main
E               args.func(args)
E             File "/opt/venv/lib/python3.10/site-packages/accelerate/commands/launch.py", line 11[68](https://github.com/huggingface/diffusers/actions/runs/11588531231/job/32273204638?pr=9800#step:10:69), in launch_command
E               simple_launcher(args)
E             File "/opt/venv/lib/python3.10/site-packages/accelerate/commands/launch.py", line 763, in simple_launcher
E               raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
E           subprocess.CalledProcessError: Command '['/opt/venv/bin/python', 'examples/dreambooth/train_dreambooth_sd3.py', '--pretrained_model_name_or_path', 'hf-internal-testing/tiny-sd3-pipe', '--instance_data_dir', 'docs/source/en/imgs', '--instance_prompt', 'photo', '--resolution', '64', '--train_batch_size', '1', '--gradient_accumulation_steps', '1', '--max_train_steps', '4', '--learning_rate', '5.0e-04', '--scale_lr', '--lr_scheduler', 'constant', '--lr_warmup_steps', '0', '--output_dir', '/tmp/tmpotpr0ant', '--checkpointing_steps=2', '--seed=0']' returned non-zero exit status 1.
examples/test_examples_utils.py:43: SubprocessCallException
_____ DreamBoothSD3.test_dreambooth_checkpointing_checkpoints_total_limit ______
command = ['accelerate', 'launch', '--config_file', '/tmp/tmpnw4j3n3a/default_config.yml', 'examples/dreambooth/train_dreambooth_sd3.py', '--pretrained_model_name_or_path=hf-internal-testing/tiny-sd3-pipe', ...]
return_stdout = False
    def run_command(command: List[str], return_stdout=False):
        """
        Runs `command` with `subprocess.check_output` and will potentially return the `stdout`. Will also properly capture
        if an error occurred while running `command`
        """
        try:
            output = subprocess.check_output(command, stderr=subprocess.STDOUT)
            if return_stdout:
                if hasattr(output, "decode"):
                    output = output.decode("utf-8")
                return output
        except subprocess.CalledProcessError as e:
>           raise SubprocessCallException(
                f"Command `{' '.join(command)}` failed with the following error:\n\n{e.output.decode()}"
            ) from e
E           test_examples_utils.SubprocessCallException: Command `accelerate launch --config_file /tmp/tmpnw4j3n3a/default_config.yml examples/dreambooth/train_dreambooth_sd3.py --pretrained_model_name_or_path=hf-internal-testing/tiny-sd3-pipe --instance_data_dir=docs/source/en/imgs --output_dir=/tmp/tmpo2cbphhs --instance_prompt=photo --resolution=64 --train_batch_size=1 --gradient_accumulation_steps=1 --max_train_steps=6 --checkpoints_total_limit=2 --checkpointing_steps=2` failed with the following error:
E           
E           10/30/2024 11:21:41 - INFO - __main__ - Distributed environment: NO
E           Num processes: 1
E           Process index: 0
E           Local process index: 0
E           Device: cpu
E           
E           Mixed precision type: no
E           
E           You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
E           You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
E           You are using a model of type t5 to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
E           {'base_shift', 'base_image_seq_len', 'max_image_seq_len', 'max_shift', 'use_dynamic_shifting'} was not found in config. Values will be initialized to default values.
E           {'mid_block_add_attention'} was not found in config. Values will be initialized to default values.
E           {'qk_norm', 'dual_attention_layers'} was not found in config. Values will be initialized to default values.
E           Traceback (most recent call last):
E             File "/__w/diffusers/diffusers/examples/dreambooth/train_dreambooth_sd3.py", line 1819, in <module>
E               main(args)
E             File "/__w/diffusers/diffusers/examples/dreambooth/train_dreambooth_sd3.py", line 1387, in main
E               instance_prompt_hidden_states, instance_pooled_prompt_embeds = compute_text_embeddings(
E             File "/__w/diffusers/diffusers/examples/dreambooth/train_dreambooth_sd3.py", line 1376, in compute_text_embeddings
E               prompt_embeds, pooled_prompt_embeds = encode_prompt(
E             File "/__w/diffusers/diffusers/examples/dreambooth/train_dreambooth_sd3.py", line 9[70](https://github.com/huggingface/diffusers/actions/runs/11588531231/job/32273204638?pr=9800#step:10:71), in encode_prompt
E               t5_prompt_embed = _encode_prompt_with_t5(
E           TypeError: _encode_prompt_with_t5() got an unexpected keyword argument 'text_input_ids'
E           Traceback (most recent call last):
E             File "/opt/venv/bin/accelerate", line 8, in <module>
E               sys.exit(main())
E             File "/opt/venv/lib/python3.10/site-packages/accelerate/commands/accelerate_cli.py", line 48, in main
E               args.func(args)
E             File "/opt/venv/lib/python3.10/site-packages/accelerate/commands/launch.py", line 1168, in launch_command
E               simple_launcher(args)
E             File "/opt/venv/lib/python3.10/site-packages/accelerate/commands/launch.py", line [76](https://github.com/huggingface/diffusers/actions/runs/11588531231/job/32273204638?pr=9800#step:10:77)3, in simple_launcher
E               raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
E           subprocess.CalledProcessError: Command '['/opt/venv/bin/python', 'examples/dreambooth/train_dreambooth_sd3.py', '--pretrained_model_name_or_path=hf-internal-testing/tiny-sd3-pipe', '--instance_data_dir=docs/source/en/imgs', '--output_dir=/tmp/tmpo2cbphhs', '--instance_prompt=photo', '--resolution=64', '--train_batch_size=1', '--gradient_accumulation_steps=1', '--max_train_steps=6', '--checkpoints_total_limit=2', '--checkpointing_steps=2']' returned non-zero exit status 1.
examples/test_examples_utils.py:43: SubprocessCallException
_ DreamBoothSD3.test_dreambooth_checkpointing_checkpoints_total_limit_removes_multiple_checkpoints _
command = ['accelerate', 'launch', '--config_file', '/tmp/tmpnw4j3n3a/default_config.yml', 'examples/dreambooth/train_dreambooth_sd3.py', '--pretrained_model_name_or_path=hf-internal-testing/tiny-sd3-pipe', ...]
return_stdout = False
    def run_command(command: List[str], return_stdout=False):
        """
        Runs `command` with `subprocess.check_output` and will potentially return the `stdout`. Will also properly capture
        if an error occurred while running `command`
        """
        try:
            output = subprocess.check_output(command, stderr=subprocess.STDOUT)
            if return_stdout:
                if hasattr(output, "decode"):
                    output = output.decode("utf-8")
                return output
        except subprocess.CalledProcessError as e:
>           raise SubprocessCallException(
                f"Command `{' '.join(command)}` failed with the following error:\n\n{e.output.decode()}"
            ) from e
E           test_examples_utils.SubprocessCallException: Command `accelerate launch --config_file /tmp/tmpnw4j3n3a/default_config.yml examples/dreambooth/train_dreambooth_sd3.py --pretrained_model_name_or_path=hf-internal-testing/tiny-sd3-pipe --instance_data_dir=docs/source/en/imgs --output_dir=/tmp/tmp8vofedjj --instance_prompt=photo --resolution=64 --train_batch_size=1 --gradient_accumulation_steps=1 --max_train_steps=4 --checkpointing_steps=2` failed with the following error:
E           
E           10/30/2024 11:21:48 - INFO - __main__ - Distributed environment: NO
E           Num processes: 1
E           Process index: 0
E           Local process index: 0
E           Device: cpu
E           
E           Mixed precision type: no
E           
E           You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
E           You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
E           You are using a model of type t5 to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
E           {'max_image_seq_len', 'max_shift', 'base_image_seq_len', 'use_dynamic_shifting', 'base_shift'} was not found in config. Values will be initialized to default values.
E           {'mid_block_add_attention'} was not found in config. Values will be initialized to default values.
E           {'dual_attention_layers', 'qk_norm'} was not found in config. Values will be initialized to default values.
E           Traceback (most recent call last):
E             File "/__w/diffusers/diffusers/examples/dreambooth/train_dreambooth_sd3.py", line 1[81](https://github.com/huggingface/diffusers/actions/runs/11588531231/job/32273204638?pr=9800#step:10:82)9, in <module>
E               main(args)
E             File "/__w/diffusers/diffusers/examples/dreambooth/train_dreambooth_sd3.py", line 1387, in main
E               instance_prompt_hidden_states, instance_pooled_prompt_embeds = compute_text_embeddings(
E             File "/__w/diffusers/diffusers/examples/dreambooth/train_dreambooth_sd3.py", line 1376, in compute_text_embeddings
E               prompt_embeds, pooled_prompt_embeds = encode_prompt(
E             File "/__w/diffusers/diffusers/examples/dreambooth/train_dreambooth_sd3.py", line 970, in encode_prompt
E               t5_prompt_embed = _encode_prompt_with_t5(
E           TypeError: _encode_prompt_with_t5() got an unexpected keyword argument 'text_input_ids'
E           Traceback (most recent call last):
E             File "/opt/venv/bin/accelerate", line 8, in <module>
E               sys.exit(main())
E             File "/opt/venv/lib/python3.10/site-packages/accelerate/commands/accelerate_cli.py", line 48, in main
E               args.func(args)
E             File "/opt/venv/lib/python3.10/site-packages/accelerate/commands/launch.py", line 1168, in launch_command
E               simple_launcher(args)
E             File "/opt/venv/lib/python3.10/site-packages/accelerate/commands/launch.py", line 763, in simple_launcher
E               raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
E           subprocess.CalledProcessError: Command '['/opt/venv/bin/python', 'examples/dreambooth/train_dreambooth_sd3.py', '--pretrained_model_name_or_path=hf-internal-testing/tiny-sd3-pipe', '--instance_data_dir=docs/source/en/imgs', '--output_dir=/tmp/tmp8vofedjj', '--instance_prompt=photo', '--resolution=64', '--train_batch_size=1', '--gradient_accumulation_steps=1', '--max_train_steps=4', '--checkpointing_steps=2']' returned non-zero exit status 1.
examples/test_examples_utils.py:43: SubprocessCallException

Might possibly have something to do with line 976 - I see that _encode_prompt_with_clip supports the text_input_ids, and it is passed correctly. But _encode_prompt_with_t5 does not seem to support it, yet the ids are passed.

@SahilCarterr
Copy link
Contributor Author

FIxed @a-r-r-o-w

Might possibly have something to do with line 976 - I see that _encode_prompt_with_clip supports the text_input_ids, and it is passed correctly. But _encode_prompt_with_t5 does not seem to support it, yet the ids are passed.

@SahilCarterr
Copy link
Contributor Author

@sayakpaul, the PR has passed all tests and is ready for your review. Could we proceed with merging when you have a moment? Thank you!

@yiyixuxu yiyixuxu merged commit 76b7d86 into huggingface:main Nov 6, 2024
8 checks passed
@yiyixuxu
Copy link
Collaborator

yiyixuxu commented Nov 6, 2024

@SahilCarterr thanks for your contribution!

@SahilCarterr SahilCarterr deleted the train_sd3 branch November 6, 2024 04:08
sayakpaul added a commit that referenced this pull request Dec 23, 2024
…_sd3 (#9800)

* updated encode prompt and clip encod prompt


---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
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.

text_input_ids_list not part of encode_prompt definition
5 participants