Repository navigation
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/96076
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 6f8ed09: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
cc jgong5 XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
cc jgong5 XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
This patch is part of half float performance optimization on CPU: * add specification for dtype `Half` in `Vectorized<>` under both avx256 and avx512. * add specification for dtype `Half` in functional utils, e.g. `vec::map_reduce<>()`, which uses float32 as accumulate type. Also add a helper struct `vec_hold_type<scalar_t>`, since Vectorized<Half>::value_type is pointing to its underlying storage type which is `uint16_t`, leading to error if the kernel uses `Vec::value_type`. Half uses the same logic as BFloat16 in the Vectorized<>, each half vector is mapped to 2x float vectors for computation. cc jgong5 XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
malfet
left a comment
There was a problem hiding this comment.
Overall looks fine, but please reply on how code duplication can be avoided. If this can't be templatized, perhaps using preprocessor will do.
Also, use C++14/C++17 language features when possible
This patch is part of half float performance optimization on CPU: * add specification for dtype `Half` in `Vectorized<>` under both avx256 and avx512. * add specification for dtype `Half` in functional utils, e.g. `vec::map_reduce<>()`, which uses float32 as accumulate type. Also add a helper struct `vec_hold_type<scalar_t>`, since Vectorized<Half>::value_type is pointing to its underlying storage type which is `uint16_t`, leading to error if the kernel uses `Vec::value_type`. Half uses the same logic as BFloat16 in the Vectorized<>, each half vector is mapped to 2x float vectors for computation. cc jgong5 XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
|
@malfet @jgong5 since this patch modifies the cmake file (add f16c to AVX2 build), add some comments here: all the hardware platforms that have avx2 already have f16c support. source info: https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
|
This patch is part of half float performance optimization on CPU: * add specification for dtype `Half` in `Vectorized<>` under both avx256 and avx512. * add specification for dtype `Half` in functional utils, e.g. `vec::map_reduce<>()`, which uses float32 as accumulate type. Also add a helper struct `vec_hold_type<scalar_t>`, since Vectorized<Half>::value_type is pointing to its underlying storage type which is `uint16_t`, leading to error if the kernel uses `Vec::value_type`. Half uses the same logic as BFloat16 in the Vectorized<>, each half vector is mapped to 2x float vectors for computation. Notice that this patch modified the cmake files by adding **-mf16c** on AVX2 build, from https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html, we can see that all the hardware platforms that support **avx2** already have **f16c** cc jgong5 XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
This patch is part of half float performance optimization on CPU: * add specification for dtype `Half` in `Vectorized<>` under both avx256 and avx512. * add specification for dtype `Half` in functional utils, e.g. `vec::map_reduce<>()`, which uses float32 as accumulate type. Also add a helper struct `vec_hold_type<scalar_t>`, since Vectorized<Half>::value_type is pointing to its underlying storage type which is `uint16_t`, leading to error if the kernel uses `Vec::value_type`. Half uses the same logic as BFloat16 in the Vectorized<>, each half vector is mapped to 2x float vectors for computation. Notice that this patch modified the cmake files by adding **-mf16c** on AVX2 build, from https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html, we can see that all the hardware platforms that support **avx2** already have **f16c** cc jgong5 XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
This patch is part of half float performance optimization on CPU: * add specification for dtype `Half` in `Vectorized<>` under both avx256 and avx512. * add specification for dtype `Half` in functional utils, e.g. `vec::map_reduce<>()`, which uses float32 as accumulate type. Also add a helper struct `vec_hold_type<scalar_t>`, since Vectorized<Half>::value_type is pointing to its underlying storage type which is `uint16_t`, leading to error if the kernel uses `Vec::value_type`. Half uses the same logic as BFloat16 in the Vectorized<>, each half vector is mapped to 2x float vectors for computation. Notice that this patch modified the cmake files by adding **-mf16c** on AVX2 build, from https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html, we can see that all the hardware platforms that support **avx2** already have **f16c** cc jgong5 XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…96079) Use float32 as acc type for `min`, `max` and `minmax`, in the function ` vec::reduce_all`, float16 inputs will be accumulated in float32. The performance benefit basically comes from the vectorization of `Half` #96076 Tested on Intel(R) Xeon(R) Gold 6248 CPU @ 2.50GHz **single socket** ``` (before) ### using OMP_NUM_THREADS=20 ### using numactl --physcpubind=0-19 --membind=0 max: size: torch.Size([64, 128, 1024]) 2.071 ms (after) ### using OMP_NUM_THREADS=20 ### using numactl --physcpubind=0-19 --membind=0 max: size: torch.Size([64, 128, 1024]) 0.071 ms ``` **single core** ``` (before) ### using OMP_NUM_THREADS=1 ### using numactl --physcpubind=0 --membind=0 max: size: torch.Size([64, 128, 1024]) 33.488 ms (after) ### using OMP_NUM_THREADS=1 ### using numactl --physcpubind=0 --membind=0 max: size: torch.Size([64, 128, 1024]) 0.953 ms ``` Pull Request resolved: #96079 Approved by: https://github.com/jgong5, https://github.com/kit1980
…ytorch#96079) Use float32 as acc type for `min`, `max` and `minmax`, in the function ` vec::reduce_all`, float16 inputs will be accumulated in float32. The performance benefit basically comes from the vectorization of `Half` pytorch#96076 Tested on Intel(R) Xeon(R) Gold 6248 CPU @ 2.50GHz **single socket** ``` (before) ### using OMP_NUM_THREADS=20 ### using numactl --physcpubind=0-19 --membind=0 max: size: torch.Size([64, 128, 1024]) 2.071 ms (after) ### using OMP_NUM_THREADS=20 ### using numactl --physcpubind=0-19 --membind=0 max: size: torch.Size([64, 128, 1024]) 0.071 ms ``` **single core** ``` (before) ### using OMP_NUM_THREADS=1 ### using numactl --physcpubind=0 --membind=0 max: size: torch.Size([64, 128, 1024]) 33.488 ms (after) ### using OMP_NUM_THREADS=1 ### using numactl --physcpubind=0 --membind=0 max: size: torch.Size([64, 128, 1024]) 0.953 ms ``` Pull Request resolved: pytorch#96079 Approved by: https://github.com/jgong5, https://github.com/kit1980
|
@mingfeima Merging this PR breaks IBM POWER builds. |
This patch is part of half float performance optimization on CPU: * add specification for dtype `Half` in `Vectorized<>` under both avx256 and avx512. * add specification for dtype `Half` in functional utils, e.g. `vec::map_reduce<>()`, which uses float32 as accumulate type. Also add a helper struct `vec_hold_type<scalar_t>`, since Vectorized<Half>::value_type is pointing to its underlying storage type which is `uint16_t`, leading to error if the kernel uses `Vec::value_type`. Half uses the same logic as BFloat16 in the Vectorized<>, each half vector is mapped to 2x float vectors for computation. Notice that this patch modified the cmake files by adding **-mf16c** on AVX2 build, from https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html, we can see that all the hardware platforms that support **avx2** already have **f16c** Pull Request resolved: pytorch/pytorch#96076
Stack from ghstack (oldest at bottom):
This patch is part of half float performance optimization on CPU:
HalfinVectorized<>under both avx256 and avx512.Halfin functional utils, e.g.vec::map_reduce<>(), which uses float32 as accumulate type.Also add a helper struct
vec_hold_type<scalar_t>, since Vectorized::value_type is pointing to its underlying storage type which isuint16_t, leading to error if the kernel usesVec::value_type.Half uses the same logic as BFloat16 in the Vectorized<>, each half vector is mapped to 2x float vectors for computation.
Notice that this patch modified the cmake files by adding -mf16c on AVX2 build, from https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html, we can see that all the hardware platforms that support avx2 already have f16c
cc @jgong5 @XiaobingSuper @sanchitintel @ashokei @jingxu10