Switch to Triton FP8 Quantization in EMU1.6 #2688
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
For some reason, the cuda
quantize_fp8_per_row
kernel is very slow in EMU. Switching it to the functionally equivalent triton kernel yields excellent speedups from FP8. For eager mode, I'm seeing a 20% e2e speedup and still getting proper outputs.Eager:
BF16: 19702.10ms
FP8 Triton Quant: 16466.97ms
Compiled:
FP8 Native Quant: 14605.18ms
FP8 Triton Quant: 16043.92ms
BF16: 18030.98ms
We see that quantizing in native pytorch helps quite a bit when torch.compile is used. I added the option to choose which quantization function is used and default to triton when torch.compile is off and native torch when torch.compile is on. This gives us the best performance in either case.
Reviewed By: jiawenliu64
Differential Revision: D58167756