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

Feat (examples): add support for Stable Diffusion XL #909

Merged
merged 1 commit into from
Apr 9, 2024

Conversation

Giuseppe5
Copy link
Collaborator

@Giuseppe5 Giuseppe5 commented Mar 16, 2024

Missing:

  • GPTQ
  • Activation equalization (layerwise if FX does not work)
  • Possibly Learned Round but it could be very slow

Torchscript export is deprecated since it is not used and difficult to make compatible with SD-XL.

More investigations are needed to fix it in case it is required.

@Giuseppe5 Giuseppe5 marked this pull request as ready for review March 16, 2024 15:15
# Workaround to expose `in_features` attribute from the Hook Wrapper
for m in pipe.unet.modules():
if isinstance(m, KwargsForwardHook) and hasattr(m.module, 'in_features'):
m.in_features = m.module.in_features
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@costigt-dev This (and similarly, line 129-131) is why I need the wrapper to expose the attributes of the wrapped module.

In this case, the wrapping is only temporary so I need to keep some sort of reference of wrapper vs wrapped

parser.add_argument(
'--weight-quant-granularity',
type=str,
default='per_group',
default='per_channel',
Copy link
Collaborator

@capnramses capnramses Mar 29, 2024

Choose a reason for hiding this comment

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

could you explain a bit of context why this changes from per group to per channel?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have more robust support for per_channel quantization, including export representation.

We can export per_group quantized network but we're still defining the best way to represent that quantization style.

if args.export_target == 'torchscript':
if args.weight_quant_granularity == 'per_group':
export_manager = BlockQuantProxyLevelManager
else:
export_manager = TorchQCDQManager
export_manager.change_weight_export(export_weight_q_node=True)
export_manager.change_weight_export(export_weight_q_node=args.export_weight_q_node)
Copy link
Collaborator

Choose a reason for hiding this comment

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

does the value from args always resolve to True/False type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does

Copy link
Collaborator

@capnramses capnramses left a comment

Choose a reason for hiding this comment

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

Because there are mostly input and argument changes in this PR my only real question would be - have you run it or tested it to double check there isn't any clash with arguments? I'd like to give it a run myself (with supervision) since it's a hot topic demo but I don't want to hold up the PR, so I'm hitting 'approve'.

Great to see some improvements to comments in tricky code and notes on PR to add context!

I asked a couple of "put me in context here" questions, but I don't see any code that looks like it could be a bug. I suggest a bit of background info in PR descriptions would be good for next PRs.

@Giuseppe5 Giuseppe5 merged commit 3014537 into Xilinx:dev Apr 9, 2024
22 checks passed
@Giuseppe5 Giuseppe5 deleted the sd_example branch April 9, 2024 11:29
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.

2 participants