-
Notifications
You must be signed in to change notification settings - Fork 7
SD-XL update #260
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
Merged
Merged
SD-XL update #260
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6c8038f
first commit
MarcelWilnicki 37e5ce5
wip
MarcelWilnicki f272fe5
wip
MarcelWilnicki b68f74e
wip
MarcelWilnicki 2ae4215
wip
MarcelWilnicki e82a99f
update requirements
MarcelWilnicki ec01d47
wip
MarcelWilnicki 615fab1
wip
MarcelWilnicki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,5 @@ invisible-watermark | |
torchmetrics<1.0.0 | ||
kornia | ||
open-clip-torch<2.26.1 | ||
diffusers | ||
accelerate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,13 +44,48 @@ def single_pass_pytorch(_runner, _stablediffusion): | |
return run_model(single_pass_pytorch, runner, stablediffusion, batch_size, num_runs, timeout) | ||
|
||
|
||
def run_pytorch_fp32(model_name, steps, batch_size, num_runs, timeout, **kwargs): | ||
import torch._dynamo | ||
from diffusers import DiffusionPipeline | ||
torch._dynamo.config.suppress_errors = True | ||
|
||
from utils.benchmark import run_model | ||
from utils.pytorch import apply_compile | ||
from utils.pytorch import PyTorchRunnerV2 | ||
from utils.text_to_image.stable_diffusion import StableDiffusion | ||
|
||
model = DiffusionPipeline.from_pretrained(model_name, | ||
use_safetensors=True).to("cpu") | ||
|
||
model.unet = apply_compile(model.unet) | ||
|
||
def single_pass_pytorch(_runner, _stablediffusion): | ||
prompts = [_stablediffusion.get_input() for _ in range(batch_size)] | ||
x_samples = _runner.run(batch_size * steps, prompt=prompts, num_inference_steps=steps) | ||
_stablediffusion.submit_count(batch_size, x_samples) | ||
|
||
runner = PyTorchRunnerV2(model) | ||
stablediffusion = StableDiffusion() | ||
return run_model(single_pass_pytorch, runner, stablediffusion, batch_size, num_runs, timeout) | ||
|
||
|
||
if __name__ == "__main__": | ||
from utils.helpers import DefaultArgParser | ||
from utils.misc import print_goodbye_message_and_die | ||
|
||
stablediffusion_variants = ["stabilityai/stable-diffusion-xl-base-1.0"] | ||
parser = DefaultArgParser(["pytorch"]) | ||
parser.require_model_name(stablediffusion_variants) | ||
parser.ask_for_batch_size() | ||
parser.add_argument("--steps", type=int, default=25, help="steps through which the model processes the input") | ||
parser.add_argument("-p", "--precision", type=str, choices=["fp32", "bf16"], required=True, | ||
help="precision in which to run the model") | ||
|
||
run_pytorch_bf16(**vars(parser.parse())) | ||
args = parser.parse() | ||
if args.precision == "fp32": | ||
run_pytorch_fp32(**vars(parser.parse())) | ||
elif args.precision == "bf16": | ||
run_pytorch_bf16(**vars(parser.parse())) | ||
else: | ||
print_goodbye_message_and_die( | ||
"this model seems to be unsupported in a specified framework: " + args.framework) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the dataset, right? Naming could be clearer