Skip to content

Align _choose_scale_float8's use of block_size with other code #3324

@jerryzh168

Description

@jerryzh168

Recently I found that for _choose_scale_float8:

len(block_size) == 0 for per tensor:

if len(block_size) == 0:

keepdim=True for others:

max_abs = tensor_reshaped.abs().amax(dim=reduction_dims, keepdim=True)

While for _choose_qparams_affine (for int):

we use keepdim=False:

min_val = torch.amin(input, dim=reduction_dims, keepdim=False)
max_val = torch.amax(input, dim=reduction_dims, keepdim=False)
that will make per tensor quantization to have a scalar scale automatically.

I think we should fix this discrepancy to reduce confusion, by aligning _choose_scale_float8 with the int one, i.e. change keepdim=True to keepdim=False and make sure the tests work.

we can also add some docs afterwards to both ops to clarify.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions