-
Notifications
You must be signed in to change notification settings - Fork 800
NVRTC NVFP4 quantization kernels #3301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f6f2c54
e4eeeb9
124d874
deb6591
04df751
b080615
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| #ifndef TRANSFORMER_ENGINE_CORE_NVFP4_CUH_ | ||
| #define TRANSFORMER_ENGINE_CORE_NVFP4_CUH_ | ||
|
|
||
| #if !defined(__CUDACC_RTC__) | ||
| #include <cuda.h> | ||
| #include <cudaTypedefs.h> | ||
| #include <cuda_runtime.h> | ||
|
|
@@ -22,11 +23,28 @@ | |
| #include "../../util/math.h" | ||
| #include "../../util/ptx.cuh" | ||
| #include "../../utils.cuh" | ||
| #else | ||
| // NVRTC build: common.h (host-only: cuDNN/cutlass) cannot be parsed by NVRTC. | ||
| // utils.cuh, util/math.h and ptx.cuh are injected as in-memory headers by the | ||
| // RTC dispatch and already provide the integer typedefs, detail::is_same, and | ||
| // the fp8 element types. util/type_extrema.h (also injected) provides the | ||
| // transformer_engine-namespace fp4 aliases and detail::TypeExtrema | ||
| // specializations that would otherwise come from common.h. | ||
| #include "ptx.cuh" | ||
| #include "util/math.h" | ||
| #include "utils.cuh" | ||
| #endif // __CUDACC_RTC__ | ||
|
|
||
| #if FP4_TYPE_SUPPORTED | ||
| #include <cuda_fp4.h> | ||
| #endif // FP4_TYPE_SUPPORTED | ||
|
|
||
| #if defined(__CUDACC_RTC__) | ||
| namespace transformer_engine { | ||
| #include "util/type_extrema.h" | ||
| } // namespace transformer_engine | ||
| #endif // __CUDACC_RTC__ | ||
|
|
||
| namespace transformer_engine { | ||
| namespace dispatch { | ||
| namespace nvfp4 { | ||
|
|
@@ -94,6 +112,8 @@ __device__ __forceinline__ float compute_global_encode_scaling_factor_FP4(const | |
| return global_encode_scale; | ||
| } | ||
|
|
||
| #if !defined(__CUDACC_RTC__) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you are not including this in the NVRTC build then how do you handle the stochastic rounding?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This particular kernel rejects stochastic rounding We can do a guard like this, or move this get_rbits to a separate header which we then include in the other kernels which use it. |
||
| // The RTC 4over6 path rejects stochastic rounding; static transpose kernels use this helper. | ||
| __device__ __forceinline__ uint32_t get_rbits( | ||
| transformer_engine::curanddx::detail::philox4x32_native_state<NVTE_BUILD_NUM_PHILOX_ROUNDS> | ||
| &rng, | ||
|
|
@@ -108,6 +128,7 @@ __device__ __forceinline__ uint32_t get_rbits( | |
| const uint32_t rbits = rbits_arr[rnd_idx++]; | ||
| return rbits; | ||
| } | ||
| #endif // !__CUDACC_RTC__ | ||
|
|
||
| #endif // FP4_TYPE_SUPPORTED | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flag should be added to documentation.