quanto icon indicating copy to clipboard operation
quanto copied to clipboard

issues with non-contiguous Tensor

Open bghira opened this issue 4 months ago • 1 comments

hello @dacorvo thanks for all the prompt feedback so far.

I might be doing something suboptimally or just incorrectly, but we're running into this a lot where .view() is being used on non-contiguous tensors. this happens with SDXL and Flux training, whether or not we are using LyCORIS, PEFT, or just directly tuning a quantised model.

this sort of workaround is applied:

if input.is_contiguous():
    reshaped_input = input.view(-1, in_features)
else:
    reshaped_input = input.reshape(-1, in_features)
output = torch._weight_int4pack_mm(
    reshaped_input.to(dtype=other.dtype),
    other._data._data,
    other._group_size,
    other._scale_shift,
)

which avoids unnecessary copy overhead.

However, my list of workarounds is growing forever-larger.

Is this something that can be addressed on my side, or is it something that is missing in Quanto itself?

bghira avatar Oct 02 '24 17:10 bghira