-
Notifications
You must be signed in to change notification settings - Fork 19
[Quantization][Decompression] Fix QDQ for dynamic quant; Update NVFP4 Compression Params #407
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
Conversation
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.
If this doesn't support 4d activations, you should add asserts making sure that the ndims matches expectations
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.
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.
LGTM!
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.
I need to understand this first, sorry
In the future it might be nice to take a step back and make a decision about when tensors need to be reshaped during the qdq process. Maybe rather than reshaping all of in The implementation below is what it might look like for both activations and weights. Some of this is wrong (it's late for me) but this function ensures the last dim is the granularity you want to quantize by. def reshape_for_groups(func):
def wrapper(x, args, ...):
assert x.ndim >= 2
if args.strategy == "token":
pass
if args.strategy == "channel":
x = x.unsqueeze(-1)
if args.strategy in ("group", "tensor_group"):
num_groups = x.size(-1) // args.group_size
x = x.unflatten(-1, (num_groups, args.group_size))
if args.strategy == "block":
block_height, block1_width = args.block_structure
x = x.unfold(-2, block_height, block_height) # [num_horiz, x.dim[-1], block_height]
x = x.unfold(-2, block1_width, block1_width) # [num_horiz, num_vert, block_height, block_width]
x = flatten(-4, -3) # [num_blocks, block_height x block_width]
x = func(x, args, ...)
if args.strategy == "token":
pass
if args.strategy == "channel":
x = x.squeeze(-1)
if args.strategy in ("group", "tensor_group"):
return x.flatten(-2, -1)
if args.strategy == "block":
x = torch.cat(x, dim=-2)
x = torch.cat(x, dim=-2)
return wrapper
@reshape_for_groups
def _process_quantization(x, args, ...):
if do_quantize:
...
if do_dequantize:
... |
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.
Thank you!
… Compression Params (#407) * add compression param; update qdq for batch greater than 1 * make generic * fix tests * remove incorrect line change; make generic * update
Uh oh!
There was an error while loading. Please reload this page.