autodiff
The tracking issue for this feature is: #124509.
This feature allows you to differentiate functions using automatic differentiation.
Set the -Zautodiff=<options> compiler flag to adjust the behaviour of the autodiff feature.
Multiple options can be separated with a comma.
Syntax
rustc -Z autodiff=Enable[,options]
Where options can be:
Enable- Required flag to enable autodiffPrintTA- print Type Analysis InformationPrintTAFn=<fn_name>- print Type Analysis Information for a specific function (consider combining it withno_mangle)PrintAA- print Activity Analysis InformationPrintPerf- print Performance Warnings from EnzymePrintSteps- prints all intermediate transformationsPrintModBefore- print the whole module, before running optsPrintModAfter- print the module after Enzyme differentiated everythingLooseTypes- Enzyme's loose type debug helper (can cause incorrect gradients)Inline- runs Enzyme specific InliningRuntimeActivity- allow specifying activity at runtime
Examples
# Enable autodiff via cargo, assuming `enzyme` being a toolchain that supports autodiff
"RUSTFLAGS=-Zautodiff=Enable" cargo +enzyme build
# Enable autodiff directly via rustc
rustc -Z autodiff=Enable
# Print TypeAnalysis updates for the function `foo`, as well as Activity Analysis for all differentiated code.
rustc -Z autodiff=Enable,PrintTAFn=foo,PrintAA