Code coverage not tracking custom EnzymeRules.augmented_primal and EnzymeRules.reverse implementations

I’m working on a package that implements custom autodiff rules for Enzyme. I’ve defined augmented_primal and reverse methods for EnzymeRules.

These functions are called indirectly through autodiff.

When I run my test suite, the code coverage tool doesn’t track that these augmented_primal and reverse methods are being executed, even though the tests pass and produce correct results.

I suspect this is because Enzyme calls these rules at compile-time/code generation rather than through normal Julia runtime dispatch, so coverage tools can’t track them.

My Questions:

  • What’s the recommended way to test custom Enzyme rules to ensure they’re covered in tests?

  • Is there a way to directly call augmented_primal and reverse in tests (e.g., by manually constructing the RevConfigWidth{1} config)?

Yes, Enzyme code is bypassing code coverage and fixing that is quite hard.

We test the rules, by just directly calling autodiff(Reverse, fixed_point!, Duplicated...)

Directly call not work for unknown reason:

Finally, I tested those function in a hard way: