Document not found (404)
+This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..c90d4c3 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,39 @@ +name: Deploy +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: write # To push a branch + pull-requests: write # To create a PR from that branch + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install latest mdbook + run: | + tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') + url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" + mkdir mdbook + curl -sSL $url | tar -xz --directory=./mdbook + echo `pwd`/mdbook >> $GITHUB_PATH + - name: Deploy GitHub Pages + run: | + # This assumes your book is in the root of your repository. + # Just add a `cd` here if you need to change to another directory. + mdbook build + git worktree add gh-pages + git config user.name "Deploy from CI" + git config user.email "" + cd gh-pages + # Delete the ref to avoid keeping history. + git update-ref -d refs/heads/gh-pages + rm -rf * + mv ../book/* . + git add . + git commit -m "Deploy $GITHUB_SHA to gh-pages" + git push --force --set-upstream origin gh-pages diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c4e8e9c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +book +target/ +Cargo.lock diff --git a/404.html b/404.html new file mode 100644 index 0000000..4b8e721 --- /dev/null +++ b/404.html @@ -0,0 +1,220 @@ + + +
+ + +This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +Since Rust-AD is still in early development, crashes are not unlikely.
+The first case is that you cause a crash of our Rust frontend.
+Luckily, these are trivial to debug. In most cases it will be enough
+to remove the whole body of the function being differentiated
+(or consider replacing it with loop {}
,
+which matches almost every return type).
+Such a reproducer is trivial to fix, so please let us know!
For the unexpected case, that you produce an ICE in our frontend that +is harder to minimize, please consider using icemelter.
+Few lines of Rust code will expand into much larger LLVM-IR. +It is therefore beneficial to reduce a Rust reproducer as +far as possible, before trying to minimize the generated LLVM-IR. +While manual minimization can not always be avoided, here are +some tools, that might help.
+This is probably the most simple automated approach: +cargo-minimize
+Otherwise we have various alternatives, including +treereduce, +halfempty, or +picireny
+Potentially also +creduce
+To support you while debugging, we have added support for various environment variables,
+which allow changing the behaviour of Enzyme, without recompiling rustc.
+If you change your environment variables, you may need to run cargo clean
to see the new behaviour.
+We currently support:
export ENZYME_PRINT_TA=1
+export ENZYME_PRINT_AA=1
+export ENZYME_PRINT_PERF=1
+export ENZYME_PRINT=1
+export ENZYME_PRINT_MOD_BEFORE=1
+export ENZYME_PRINT_MOD_AFTER_ENZYME=1
+export ENZYME_PRINT_MOD_AFTER_OPTS=1
+export ENZYME_LOOSE_TYPES=1
+
+For performance experiments and benchmarking we also support
+export ENZYME_NO_MOD_OPT_AFTER=1
+export ENZYME_ENABLE_FNC_OPT=1
+export ENZYME_NO_VEC_UNROLL=1
+export ENZYME_NO_SAFETY_CHECKS=1
+export ENZYME_INLINE=1
+export ENZYME_ALT_PIPELINE=1
+
+The normal compilation pipeline of Rust-Enzyme is
+The alt pipeline will not run opts before AD, but 2x after AD - the first time without vectorization or loop unrolling, the second time with.
+The two flags above allow you to adjust this default behaviour.
+ +Automatic/algorithmic differentiation, or autodiff, is...
+TODO with examples.
+ +When using forward mode, we only have three choices of activity values, Dual
, DualOnly
and Const
.
+Dual arguments get a second "shadow" variable.
+Usually we will only seed the shadow variable of one Dual input to one and all others to zero,
+and then read the shadow values of our output arguments.
+We can also seed more then one input shadow, in which case the shadow of output variables will
+be a linear combination based on the seed values.
+If we use a &mut
reference as input and output argument and mark it as Dual,
+the corresponding shadow seed might get overwritten. Otherwise, the seed value will remain unchanged.
Activity | Dual | DualOnly | Const |
---|---|---|---|
Non integer input T | Accept T ,T | Accept byVal(T) , T | Unchanged |
Integer scalar input | N/A | N/A | Unchanged |
f32 or f64 output T | Return (T,T) | Return T | Unchanged |
Other output types | N/A | N/A | Unchanged |
DualOnly
is a potentially faster version of Dual
.
When applied to a return type, it will cause the primal return to not be computed.
+So in the case of fn f(x: f32) -> f32 { x * x }
,
+we would now only return 2.0 * x
, instead of
+(x * x, 2.0 * x)
, which we would get with Dual
.
In the case of an input variable, DualOnly
will cause the first value to be
+passed by Value, even when passed by Reference in the original function.
+So fn f(x: &f32, out: &mut f32) {..}
would become
+fn df(x: f32, dx &mut f32, out: f32, dout: &mut f32) {..}
.
+This makes x
and out
inaccessible for the user, so we can use it as buffer
+and potentially skip certain computations. This is mostly valuable for larger Types, or more complex functions.
Automatic/algorithmic differentiation, or autodiff, is...
+TODO with examples.
+ +