Skip to content
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

Add NEON-accelerated int8mm for bfloat16 #125290

Closed
wants to merge 2 commits into from
Closed

Conversation

malfet
Copy link
Contributor

@malfet malfet commented May 1, 2024

As apparently vshlq_u32 is faster than vcvt_f32_f16

Refactor NEON tinygemm_kernel to rely on load_as_float32x4 and load_as_float32x4x2 and implement them for float16 (using vcvt), bfloat16 (using left shift) and plain float32 (not using anything)

As result stories110M run at 60 tokens/sec with f16, but at 66 tokens/sec with bf16 and 75 tokens/sec with f32, though more bandwith demand starts to favor reduced floating types as model size gets bigger.

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10

Apparently `vshlq_u32` is faster than `vcvt_f32_f16`

I.e. the same stories110M run at 60 tokens/sec with f16, but at 66 tokens/sec with bf16
@malfet malfet added release notes: performance_as_product release notes category topic: improvements topic category labels May 1, 2024
Copy link

pytorch-bot bot commented May 1, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/125290

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 954400e with merge base ea347fa (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the module: cpu CPU specific problem (e.g., perf, algorithm) label May 1, 2024
Copy link
Contributor

@mikekgfb mikekgfb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@malfet malfet added the ciflow/trunk Trigger trunk jobs on your pull request label May 1, 2024
@malfet
Copy link
Contributor Author

malfet commented May 1, 2024

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@mikekgfb mikekgfb deleted the malfet/add-bf16-int8pack branch May 1, 2024 19:55
andoorve pushed a commit to andoorve/pytorch that referenced this pull request May 1, 2024
As apparently `vshlq_u32` is faster than `vcvt_f32_f16`

Refactor NEON `tinygemm_kernel` to rely on `load_as_float32x4` and `load_as_float32x4x2` and implement them for float16 (using vcvt), bfloat16 (using left shift) and plain float32 (not using anything)

As result stories110M run at 60 tokens/sec with f16, but at 66 tokens/sec with bf16 and  75 tokens/sec with f32, though more bandwith demand starts to favor reduced floating types as model size gets bigger.

Pull Request resolved: pytorch#125290
Approved by: https://github.com/mikekgfb
petrex pushed a commit to petrex/pytorch that referenced this pull request May 3, 2024
As apparently `vshlq_u32` is faster than `vcvt_f32_f16`

Refactor NEON `tinygemm_kernel` to rely on `load_as_float32x4` and `load_as_float32x4x2` and implement them for float16 (using vcvt), bfloat16 (using left shift) and plain float32 (not using anything)

As result stories110M run at 60 tokens/sec with f16, but at 66 tokens/sec with bf16 and  75 tokens/sec with f32, though more bandwith demand starts to favor reduced floating types as model size gets bigger.

Pull Request resolved: pytorch#125290
Approved by: https://github.com/mikekgfb
malfet added a commit that referenced this pull request May 17, 2024
It used to be vectorized only for f16, but no reason not to do the same for bf16 or f32

Spiritual followup of #125290
pytorchmergebot pushed a commit that referenced this pull request May 17, 2024
It used to be vectorized only for f16, but no reason not to do the same for bf16 or f32

Spiritual followup of #125290

Pull Request resolved: #126512
Approved by: https://github.com/Skylion007
ZelboK pushed a commit to ZelboK/pytorch that referenced this pull request May 19, 2024
It used to be vectorized only for f16, but no reason not to do the same for bf16 or f32

Spiritual followup of pytorch#125290

Pull Request resolved: pytorch#126512
Approved by: https://github.com/Skylion007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged module: cpu CPU specific problem (e.g., perf, algorithm) release notes: performance_as_product release notes category topic: improvements topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants