Skip to content

Commit

Permalink
Merge branch 'main' into vc/string2
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy authored Jan 17, 2025
2 parents f343d45 + b95c737 commit 75f18b7
Show file tree
Hide file tree
Showing 14 changed files with 387 additions and 269 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"
64 changes: 18 additions & 46 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- '1.11'
- 'nightly'
os:
- ubuntu-20.04
- ubuntu-24.04
- macOS-latest
- windows-latest
arch:
Expand All @@ -38,17 +38,17 @@ jobs:
arch: x64
libEnzyme: local
include:
- os: ubuntu-20.04
- os: ubuntu-24.04
arch: x86
libEnzyme: packaged
version: '1.10'
assertions: false
- os: ubuntu-20.04
- os: ubuntu-24.04
arch: x64
libEnzyme: packaged
version: '1.10'
assertions: true
- os: ubuntu-20.04
- os: ubuntu-24.04
arch: x64
libEnzyme: packaged
version: '1.11'
Expand All @@ -72,16 +72,7 @@ jobs:
sed -i.bak 's/exit 2/exit 0/g' julia/deps/tools/jlchecksum
make -C julia -j $(nproc) FORCE_ASSERTIONS=1 LLVM_ASSERTIONS=1 JULIA_PRECOMPILE=0
echo $PWD/julia/usr/bin >> $GITHUB_PATH
- uses: actions/cache@v2
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/cache@v2
- name: add EnzymeCore
shell: julia --color=yes --project=. {0}
run: |
Expand All @@ -95,16 +86,16 @@ jobs:
continue-on-error: ${{ matrix.version == 'nightly' }}
id: build_libenzyme
run: |
julia --project=deps -e 'using Pkg; Pkg.instantiate()'
julia --project=deps deps/build_local.jl
julia --color=yes --project=deps -e 'using Pkg; Pkg.instantiate()'
julia --color=yes --project=deps deps/build_local.jl
cp LocalPreferences.toml test/
- name: Build libEnzyme MacOS
if: ${{ matrix.libEnzyme == 'local' && matrix.os == 'macOS-latest'}}
continue-on-error: ${{ matrix.version == 'nightly' }}
id: build_libenzyme_mac
run: |
julia --project=deps -e 'using Pkg; Pkg.instantiate()'
SDKROOT=`xcrun --show-sdk-path` julia --project=deps deps/build_local.jl
julia --color=yes --project=deps -e 'using Pkg; Pkg.instantiate()'
SDKROOT=`xcrun --show-sdk-path` julia --color=yes --project=deps deps/build_local.jl
cp LocalPreferences.toml test/
- uses: julia-actions/julia-buildpkg@v1
if: matrix.version != 'nightly' || steps.build_libenzyme.outcome == 'success' || steps.build_libenzyme_mac.outcome == 'success'
Expand All @@ -120,10 +111,10 @@ jobs:
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
- uses: julia-actions/julia-processcoverage@v1
if: matrix.version != 'nightly' || steps.run_tests.outcome == 'success'
- uses: codecov/codecov-action@v4
- uses: codecov/codecov-action@v5
if: matrix.version != 'nightly' || steps.run_tests.outcome == 'success'
with:
file: lcov.info
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # or true if you want CI to fail when Codecov fails
enzymetestutils:
Expand All @@ -150,16 +141,7 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v2
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/cache@v2
- name: setup EnzymeTestUtils
shell: julia --color=yes {0}
id: setup_testutils
Expand All @@ -182,7 +164,7 @@ jobs:
if: matrix.version != 'nightly' || steps.run_tests.outcome == 'success'
with:
directories: lib/EnzymeTestUtils/src
- uses: codecov/codecov-action@v4
- uses: codecov/codecov-action@v5
if: matrix.version != 'nightly' || steps.run_tests.outcome == 'success'
with:
files: lcov.info
Expand Down Expand Up @@ -212,16 +194,7 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v2
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/cache@v2
- name: setup EnzymeCore
shell: julia --color=yes {0}
id: setup_testutils
Expand All @@ -244,7 +217,7 @@ jobs:
if: matrix.version != 'nightly' || steps.run_tests.outcome == 'success'
with:
directories: lib/EnzymeCore/src
- uses: codecov/codecov-action@v4
- uses: codecov/codecov-action@v5
if: matrix.version != 'nightly' || steps.run_tests.outcome == 'success'
with:
files: lcov.info
Expand Down Expand Up @@ -287,19 +260,18 @@ jobs:
version: '1'
- uses: julia-actions/cache@v2
- run: |
julia --project=docs -e '
julia --color=yes --project=docs -e '
using Pkg
Pkg.develop([PackageSpec(path="lib/EnzymeCore"), PackageSpec(path="lib/EnzymeTestUtils"), PackageSpec(path=pwd())])
Pkg.instantiate()'
env:
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
- run: |
julia --project=docs -e '
julia --color=yes --project=docs -e '
using Documenter: DocMeta, doctest
using Enzyme
DocMeta.setdocmeta!(Enzyme, :DocTestSetup, :(using Enzyme); recursive=true)
doctest(Enzyme)'
- run: julia --project=docs docs/make.jl
- run: julia --color=yes --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
55 changes: 55 additions & 0 deletions .github/workflows/Format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 'Format'

on:
pull_request_target:
paths: ['**/*.jl']
types: [opened, synchronize, reopened, ready_for_review]

permissions:
contents: read

# needed for julia-actions/cache to delete old caches
actions: write

# needed for googleapis/code-suggester
pull-requests: write

jobs:
runic:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0

- name: Setup Julia
uses: julia-actions/setup-julia@v2
with:
version: '1'
arch: 'x64'
- uses: julia-actions/cache@v2

- name: Install Runic
run: |
julia --project=@runic -e 'using Pkg; Pkg.add("Runic")'
curl -o git-runic https://raw.githubusercontent.com/fredrikekre/Runic.jl/master/bin/git-runic
chmod +x git-runic
sudo mv git-runic /usr/local/bin
- name: Run Runic
run: |
set +e
git runic origin/master
[ $? -eq 2 ] && exit 1 || exit 0
- name: Suggest changes
uses: googleapis/code-suggester@v2
env:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
command: review
pull_number: ${{ github.event.pull_request.number }}
git_dir: '.'
2 changes: 1 addition & 1 deletion .github/workflows/PreviewCleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Delete preview and history + push changes
Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/benchmark_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@ on:
permissions:
pull-requests: write

concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
generate_plots:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: "1"
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- name: Extract Package Name from Project.toml
id: extract-package-name
run: |
Expand All @@ -26,8 +32,8 @@ jobs:
JULIA_NUM_THREADS: 2
run: |
# Lightweight build step, as sometimes the runner runs out of memory:
julia -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.add("AirspeedVelocity")'
julia -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.build("AirspeedVelocity")'
julia --color=yes -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.add("AirspeedVelocity")'
julia --color=yes -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.build("AirspeedVelocity")'
- name: Add ~/.julia/bin to PATH
run: |
echo "$HOME/.julia/bin" >> $GITHUB_PATH
Expand Down Expand Up @@ -60,15 +66,15 @@ jobs:
echo 'Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).' >> body.md
- name: Find Comment
uses: peter-evans/find-comment@v2
uses: peter-evans/find-comment@v3
id: fcbenchmark
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Benchmark Results

- name: Comment on PR
uses: peter-evans/create-or-update-comment@v3
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fcbenchmark.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/scripts_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ on:

jobs:
docs:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- run: |
julia --project=docs -e '
julia --color=yes --project=docs -e '
using Pkg
Pkg.develop([PackageSpec(path="lib/EnzymeCore"), PackageSpec(path=pwd()), PackageSpec(path="lib/EnzymeTestUtils")])
Pkg.instantiate()'
env:
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
- run: |
julia --project=docs -e '
julia --color=yes --project=docs -e '
using Documenter: DocMeta, doctest
using Enzyme
DocMeta.setdocmeta!(Enzyme, :DocTestSetup, :(using Enzyme); recursive=true)
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ lib/EnzymeCore/Manifest.toml
/test/Manifest.toml
/docs/Manifest.toml
/docs/build/
/docs/src/generated/

.vscode
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/fredrikekre/runic-pre-commit
rev: v1.0.0
hooks:
- id: runic
7 changes: 7 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869"
EnzymeTestUtils = "12d8515a-0907-448a-8884-5fe00fdf1c5a"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Documenter = "1"
Literate = "2"

[sources]
Enzyme = {path = ".."}
EnzymeCore = {path = "../lib/EnzymeCore"}
EnzymeTestUtils = {path = "../lib/EnzymeTestUtils"}
3 changes: 0 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
pushfirst!(LOAD_PATH, joinpath(@__DIR__, "..")) # add Enzyme to environment stack
pushfirst!(LOAD_PATH, joinpath(@__DIR__, "..", "lib")) # add EnzymeCore to environment stack

using Enzyme
using EnzymeCore
using EnzymeTestUtils
Expand Down
6 changes: 3 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Enzyme provides convenience functions for second-order derivative computations,

Unlike [`autodiff`](@ref) and [`gradient`](@ref), a mode is not specified. Here, Enzyme will choose to perform forward over reverse mode (generally the fastest for this type of operation).

```jldoctest hvp; filter = r"([0-9]+\\.[0-9]{8})[0-9]+" => s"\\1***"
```jldoctest hvp; filter = r"([0-9]+\.[0-9]{8})[0-9]+" => s"\1***"
julia> f(x) = sin(x[1] * x[2]);
julia> hvp(f, [2.0, 3.0], [5.0, 2.7])
Expand All @@ -238,7 +238,7 @@ julia> hvp(f, [2.0, 3.0], [5.0, 2.7])

Enzyme also provides an in-place variant which will store the hessian vector product in a pre-allocated array (this will, however, still allocate another array for storing an intermediate gradient).

```jldoctest hvp2; filter = r"([0-9]+\\.[0-9]{8})[0-9]+" => s"\\1***"
```jldoctest hvp2; filter = r"([0-9]+\.[0-9]{8})[0-9]+" => s"\1***"
julia> f(x) = sin(x[1] * x[2])
f (generic function with 1 method)
Expand All @@ -254,7 +254,7 @@ julia> res

Finally. Enzyme provides a second in-place variant which simultaneously computes both the hessian vector product, and the gradient. This function uses no additional allocation, and is much more efficient than separately computing the hvp and the gradient.

```jldoctest hvp3; filter = r"([0-9]+\\.[0-9]{8})[0-9]+" => s"\\1***"
```jldoctest hvp3; filter = r"([0-9]+\.[0-9]{8})[0-9]+" => s"\1***"
julia> f(x) = sin(x[1] * x[2]);
julia> res = Vector{Float64}(undef, 2);
Expand Down
Loading

0 comments on commit 75f18b7

Please sign in to comment.