Skip to content

Commit

Permalink
Merge branch 'master' into jas-complete
Browse files Browse the repository at this point in the history
  • Loading branch information
ViralBShah authored Sep 17, 2024
2 parents 75db320 + 3953e14 commit e5b0bc4
Show file tree
Hide file tree
Showing 11 changed files with 462 additions and 156 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
19 changes: 13 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@ jobs:
matrix:
version:
- '1.6'
# - 'nightly'
- '1'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
include:
- os: macos-latest
arch: aarch64
version: '1'

steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -40,6 +45,8 @@ jobs:
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v4
with:
file: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}

45 changes: 45 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CompatHelper
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Check if Julia is already available in the PATH
id: julia_in_path
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v2
with:
version: '1'
arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main()
shell: julia --color=yes {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
23 changes: 21 additions & 2 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: 3
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
Expand Down
9 changes: 7 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
name = "BFloat16s"
uuid = "ab4f0b2a-ad5b-11e8-123f-65d77653426b"
authors = ["Keno Fischer <keno@alumni.harvard.edu>", "Jeffrey Sarnoff <jeffrey.sarnoff@gmail.com>"]
version = "0.4.1"
version = "0.5.1"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
julia = "1.6"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
45 changes: 36 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
# BFloat16s
# BFloat16s.jl
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)

This package defines the [BFloat16 data type](https://en.wikipedia.org/wiki/Bfloat16_floating-point_format).
The only currently available hardware implementation of this datatype are
Google's [Cloud TPUs](https://en.wikipedia.org/wiki/Tensor_processing_unit).
As such, this package is suitable to evaluate whether using TPUs would cause
precision problems for any particular algorithm, even without access to TPU
This package defines the [BFloat16 data type](https://en.wikipedia.org/wiki/Bfloat16_floating-point_format),
a floating-point format with 1 sign bit, 8 exponent bits and 7 mantissa bits.

Hardware implementation of this datatype is available in Google's
[Cloud TPUs](https://en.wikipedia.org/wiki/Tensor_processing_unit) as well as
in a growing number of CPUs, GPUs, and more specialized processors. See the
[wikipedia entry](https://en.wikipedia.org/wiki/Bfloat16_floating-point_format)
for more information.

This package is suitable to evaluate whether using BFloat16 would cause
precision problems for any particular algorithm, even without access to supporting
hardware. Note that this package is designed for functionality, not performance,
so this package should be used for precision experiments only, not performance
experiments.

# Usage
## Usage

This package exports the `BFloat16` data type. This datatype behaves
just like any built-in floating-point type

```julia
julia> using BFloat16s

julia> a = BFloat16(2)
BFloat16(2.0)

julia> sqrt(a)
BFloat16(1.4140625)
```

However, in practice you may hit a `MethodError` indicating that this package does not implement
a method for `BFloat16` although it should. In this case, please raise an issue so that we can
close the gap in support compared to other low-precision types like `Float16`. The usage
of `BFloat16` should be as smooth as the following example, solving a linear equation system

This package exports the BFloat16 data type. This datatype should behave
just like any builtin floating point type (e.g. you can construct it from
Expand All @@ -32,7 +57,8 @@ supposed to emulate the kind of matmul operation that TPUs do well
are peformed in Float32 (as they would be on a TPU) while matrix multiplies
are performed in BFloat16 with Float32 accumulates, e.g.

```

```julia
julia> A = LowPrecArray(rand(Float32, 5, 5))
5×5 LowPrecArray{2,Array{Float32,2}}:
0.252818 0.619702 0.553199 0.75225 0.30819
Expand Down Expand Up @@ -66,6 +92,7 @@ julia> Float64.(A.storage)^2
1.22742 1.90498 1.70653 1.63928 2.18076
```

Note that the low precision result differs from (is less precise than) the
Note that the low-precision result differs from (is less precise than) the
result computed in Float32 arithmetic (which matches the result in Float64
precision).

5 changes: 5 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage:
status:
patch: false
project: false
changes: false
1 change: 0 additions & 1 deletion src/BFloat16s.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ export BFloat16, LowPrecArray

include("bfloat16.jl")
include("lowprecarrays.jl")
include("printf.jl")

end # module BFloat16s
Loading

0 comments on commit e5b0bc4

Please sign in to comment.