from comfy_kitchen.tensor import QuantizedTensor, TensorCoreFP8Layout, TensorCoreNVFP4Layout
# Quantize a tensor
x = torch.randn(128, 256, device="cuda", dtype=torch.bfloat16)
qt = QuantizedTensor.from_float(x, TensorCoreFP8Layout)
# Operations dispatch to optimized kernels automatically
output = torch.nn.functional.linear(qt, weight_qt)
# Dequantize back to float
dq = qt.dequantize()
How is weight_qt computed in this case?
Also, is it recommended to quantize the input (which seems to be qt in this case) instead of the weights?
How is
weight_qtcomputed in this case?Also, is it recommended to quantize the input (which seems to be
qtin this case) instead of the weights?