You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DifferentiationInterface/docs/src/explanation/advanced.md
+17-1Lines changed: 17 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,10 +71,26 @@ But after preparation, the more zeros are present in the matrix, the greater the
71
71
### Tuning the coloring algorithm
72
72
73
73
The complexity of sparse Jacobians or Hessians grows with the number of distinct colors in a coloring of the sparsity pattern.
74
-
To reduce this number of colors, [`GreedyColoringAlgorithm`](@ref) has two main settings: the order used for vertices and the decompression method.
74
+
To reduce this number of colors, [`GreedyColoringAlgorithm`](@extref SparseMatrixColorings.GreedyColoringAlgorithm) has two main settings: the order used for vertices and the decompression method.
75
75
Depending on your use case, you may want to modify either of these options to increase performance.
76
76
See the documentation of [SparseMatrixColorings.jl](https://github.com/gdalle/SparseMatrixColorings.jl) for details.
77
77
78
+
### Mixed mode
79
+
80
+
When a Jacobian matrix has both dense rows and dense columns, it can be more efficient to use "mixed-mode" differentiation, a mixture of forward and reverse.
81
+
The associated bidirectional coloring algorithm automatically decides how to cover the Jacobian using a set of columns (computed in forward mode) plus a set of rows (computed in reverse mode).
82
+
This behavior is triggered as soon as you put a [`MixedMode`](@ref) object inside `AutoSparse`, like so:
83
+
84
+
```julia
85
+
AutoSparse(
86
+
MixedMode(forward_backend, reverse_backend);
87
+
sparsity_detector,
88
+
coloring_algorithm
89
+
)
90
+
```
91
+
92
+
At the moment, mixed mode tends to work best when the [`GreedyColoringAlgorithm`](@extref SparseMatrixColorings.GreedyColoringAlgorithm) is provided with a [`RandomOrder`](@extref SparseMatrixColorings.RandomOrder) instead of the usual [`NaturalOrder`](@extref SparseMatrixColorings.NaturalOrder).
In such cases, sparse AD is only beneficial in "mixed mode", where we combine a forward and a reverse backend.
205
+
This is achieved using the [`MixedMode`](@ref) wrapper, for which we recommend a random coloring order (see [`RandomOrder`](@extref SparseMatrixColorings.RandomOrder)):
0 commit comments