-
Notifications
You must be signed in to change notification settings - Fork 748
Add bf16 avx2 8bit dequant and Nbit dequant #5634
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
Open
cyyever
wants to merge
6
commits into
pytorch:main
Choose a base branch
from
cyyever:impl-bf16-avx2-8bit-dequant
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
96a37b8
Add Bf16ConvertAvx2.h with shared fp32->bf16 helpers
cyyever 7691f5b
Add bf16 output support to AVX2 dequantization kernels
cyyever 2babe9c
Remove redundant direct AVX512-BF16 test, use generic dispatcher
cyyever 0ff36b8
Relax bf16 dequant test comparison to tolerance-based
cyyever 63d9e05
Forward is_uint16_t_of_type_bf16 to NEON N-bit dequant and add bf16 o…
cyyever b1b1739
Reuse cvt_fp32x16_bf16x16 helper in FloatToBfloat16_avx2
cyyever File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #ifdef __AVX2__ | ||
| #include <immintrin.h> | ||
|
|
||
| namespace fbgemm::internal { | ||
|
|
||
| // Round-nearest fp32→bf16: val + 0x8000, take high 16 bits. | ||
| inline __m256i cvt_fp32_to_bf16x8(__m256i val) { | ||
| return _mm256_srli_epi32( | ||
| _mm256_add_epi32(val, _mm256_set1_epi32(0x8000)), 16); | ||
| } | ||
|
|
||
| // Convert 2x8 fp32 to 16 packed bf16 | ||
| inline __m256i cvt_fp32x16_bf16x16(__m256 a, __m256 b) { | ||
| __m256i y0 = cvt_fp32_to_bf16x8(_mm256_castps_si256(a)); | ||
| __m256i y1 = cvt_fp32_to_bf16x8(_mm256_castps_si256(b)); | ||
| return _mm256_permute4x64_epi64(_mm256_packus_epi32(y0, y1), 0xd8); | ||
| } | ||
|
|
||
| // Convert 8 fp32 to 8 packed bf16 (128-bit result) | ||
| inline __m128i cvt_fp32x8_bf16x8(__m256 src) { | ||
| __m256i r = cvt_fp32_to_bf16x8(_mm256_castps_si256(src)); | ||
| return _mm_packus_epi32( | ||
| _mm256_castsi256_si128(r), _mm256_extracti128_si256(r, 1)); | ||
| } | ||
|
|
||
| } // namespace fbgemm::internal | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.