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 f16 support in the wgpu backend #1582

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

p1-0tr
Copy link

@p1-0tr p1-0tr commented Apr 7, 2024

Pull Request Template

Checklist

  • Confirmed that run-checks all script has been executed.
  • Made sure the book is up to date with changes in this PR.

Related Issues/PRs

Split from: #1475
Dawn support: #1583

Changes

The burn-wgpu backend currently does not support computations on 16 bit floats. This. for example, limits the ability to run LLMs on top of Burn, on widely available hardware. So, add 16 bit float support in burn-wgpu.

Testing

I used this change on top of my changes which add the ability to run with Dawn instead of wgpu, to run llama2-burn with f16.

The burn-wgpu backend currently does not support computations on 16 bit
floats. This. for example, limits the ability to run LLMs on top of
Burn, on widely available hardware. So, add 16 bit float support in
burn-wgpu.

Signed-off-by: Piotr Stankiewicz <piotr.stankiewicz@docker.com>
Copy link

codecov bot commented Apr 8, 2024

Codecov Report

Attention: Patch coverage is 9.30233% with 39 lines in your changes are missing coverage. Please review.

Project coverage is 86.35%. Comparing base (f3e0aa6) to head (ee7ec2c).
Report is 91 commits behind head on main.

Files Patch % Lines
crates/burn-jit/src/element.rs 0.00% 18 Missing ⚠️
crates/burn-wgpu/src/compiler/wgsl/shader.rs 14.28% 6 Missing ⚠️
crates/burn-jit/src/fusion/tracing/builder.rs 0.00% 5 Missing ⚠️
crates/burn-wgpu/src/compiler/wgsl/base.rs 0.00% 3 Missing ⚠️
crates/burn-wgpu/src/element.rs 0.00% 3 Missing ⚠️
crates/burn-wgpu/src/compiler/wgsl/compiler.rs 60.00% 2 Missing ⚠️
crates/burn-jit/src/codegen/dialect/gpu/shader.rs 0.00% 1 Missing ⚠️
crates/burn-jit/src/codegen/kernel.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1582      +/-   ##
==========================================
- Coverage   86.39%   86.35%   -0.05%     
==========================================
  Files         688      688              
  Lines       78676    78718      +42     
==========================================
+ Hits        67974    67977       +3     
- Misses      10702    10741      +39     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -21,6 +21,7 @@ pub enum Visibility {
#[allow(missing_docs)]
pub enum Elem {
Float,
Half,
Copy link
Member

Choose a reason for hiding this comment

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

There is no need to add Half here, Float should cover all float types of all precisions in this context.

Comment on lines +104 to +106
fn gpu_elem() -> gpu::Elem {
gpu::Elem::Half
}
Copy link
Member

Choose a reason for hiding this comment

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

The gpu element would be Float here.

Comment on lines +81 to +84
let features = match F::gpu_elem() {
gpu::Elem::Half => vec![wgsl::Feature::ShaderF16],
_ => vec![],
};
Copy link
Member

Choose a reason for hiding this comment

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

I would check using F::wgpu_elem() == Elem::F16 instead.

Comment on lines 137 to +138
gpu::Elem::Float => F::wgpu_elem(),
gpu::Elem::Half => F::wgpu_elem(),
Copy link
Member

Choose a reason for hiding this comment

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

This line pretty much explains why we don't need Half in the gpu::Elem enum :)

Copy link
Contributor

This PR has been marked as stale because it has not been updated for over a month

@github-actions github-actions bot added the stale The issue or pr has been open for too long label May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale The issue or pr has been open for too long
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants