Autodiff for max-flow

Hi @PaterPen!
Can you explain why you need derivatives for a max flow? Is your output the total cost of the flow, or its breakdown along each edge? Is your input only the capacity matrix, or also the edge costs?
Typically, in such cases, one wants to avoid differentiating through the optimization algorithm, and instead use problem knowledge to speed up the differentiation process. Examples of packages for this purpose are DiffOpt.jl and InferOpt.jl.
Nowadays, Enzyme.jl can handle type instabilities, but perhaps not that many. GraphsFlows.jl is an old package, so the code may not be ideal for autodiff. However it’s exactly my area of study, and I maintain both the JuliaGraphs and JuliaDiff ecosystems, so I’m the ideal person to help you!

1 Like