[CompressedTensors] FP4 Qutlass Integration - #43229
Conversation
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request implements the process_weights_after_loading and apply methods for the QutlassNvFP4LinearMethod class, facilitating quantized matrix multiplication with CUTLASS and Hadamard matrix normalization. The feedback identifies a potential AttributeError in the weight processing logic, suggesting that self.input_transform.weight should be indexed before accessing its partitions.
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
|
I added a smoke test for NVFP4
Had16+NVFP4 (hadacore achieves 11.3593 PPL)
Had128+NVFP4 (hadacore achieves 11.3938 PPL)
|
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
1e2cd7c to
9d211c7
Compare
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
|
On this branch, after the changes to always use the fused Nv pathway for fused layers (like qkv and gate_up), I am getting the following results. Unsafe means the old custom op (which will error in torch 2.12+), just to confirm operating in-place and returning modified tensors doesn't affect throughput. Throughput overhead is about 5% for Had16 and 5.6% for Had128. The default hadacore pathway is typically 3-4% overhead:
|
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
| @@ -111,26 +110,19 @@ def forward(self, value: Tensor, part_id: int = 0) -> Tensor: | |||
| weight = ( | |||
| weight if self.transforms[part_id].args.inverse else weight.T | |||
There was a problem hiding this comment.
I have one question left: in our case, the way our transforms are defined, no transposition takes place at runtime, correct? @brian-dellabetta
There was a problem hiding this comment.
Yeah this only happens for non-hadamard transforms. What we've added on this PR doesn't go through HadamardTransforms's forward method, and if it does it goes through the hadacore transform. this path with the transpose only occurs if dense
| ) | ||
| value = dispatch_unquantized_gemm()( | ||
| self, value.to(weight.dtype), weight, None | ||
| ).to(value.dtype) |
There was a problem hiding this comment.
Similar with this type casts. Is this here for safety, or is it actually casting data at runtime?
There was a problem hiding this comment.
yeah likely just safety. this precedes my PR, we are just removing the scale factor here, absorbing it into the transform weight matrix earlier on
|
Added smoke model test runs successfully locally: but model is failing to initialize in buildkite here UPDATE: this is because i am testing on a b200 but the buildkite test runs on a device with incorrect compute capability. we want both paths to work. i have updated the method selector to only choose QutlassNvFP4LinearMethod if |
|
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Brian Dellabetta <brian-dellabetta@users.noreply.github.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
| if is_qutlass_fp4_scheme(quant_scheme, input_tfms): | ||
| if is_qutlass_fp4_scheme( | ||
| quant_scheme, input_tfms | ||
| ) and current_platform.has_device_capability(100): |
There was a problem hiding this comment.
This should probably be is_device_capability_family(100) if this only works on Blackwell? has is >=
Summary
This PR integrates the NVFP4 Qutlass kernel for compressed-tensors models with NVFP4 weights and online transforms. It supports any block-diagonal transform, and is not limited to deterministic hadamard transforms like hadacore. It is selected as the default, over hadacore, for any applicable configuration. To reduce memory usage, online-transform weights are shared where applicable.
MXFP4 Qutlass integration will be added in follow-up:
Test Plan:
Suggested Reviewers