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

cond and uncond quantization issue #4

Open
Andy0422 opened this issue Jul 23, 2024 · 1 comment
Open

cond and uncond quantization issue #4

Andy0422 opened this issue Jul 23, 2024 · 1 comment

Comments

@Andy0422
Copy link

I just confused that i cannot get the clue about the cond and uncond quantization part you claim in your paper in the code, could you give me a hand?

@A-suozhang
Copy link
Member

The classifier-free guidance process consists of two network inference, once with the control signal, and once without, the results are then weighted sum together. These two inference have activation variations, and thus should use different quantization parameters.

Normally, the two inference is conducted in parallel in the batch dimension, and the quantizer automatically calculated the activation scaling factor for each token (of all batches). To calculate the quantization parameter respectively for cond and uncond, we need to conduct two separate inference.

The CFG split code is presented here (apology for it's hidden inside the scheduler), by turning the CFG_SPLIT=True, you could conduct 2 separate inference, and save the quantization parameters for the cond and uncond inference respectively.

https://github.com/A-suozhang/ViDiT-Q/blob/fb2c8486a63aee5071a80d7382802ace0b08aeb7/t2v/opensora/schedulers/iddpm/__init__.py#L140

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

No branches or pull requests

2 participants