Skip to content

Feature request: Allow -enzyme-auto-sparsity=1 to successfully compile if the Jacobian is null #2778

@nkoukpaizan

Description

@nkoukpaizan

The current behavior of -enzyme-auto-sparsity=1 is to error out when the resulting Jacobian is null with the message:

Found no stores for sparsification

This is technically correct, but it leaves some automation on the table.

In GridKit, e.g. PR 364, we are having to specialize some Jacobian evaluations for models where we know which terms are null. However, this requires the adequate selection of the the specializations by the developers with some understanding of the equations implemented. This approach will not be sustainable long term as the complexity of the equations increases and the multivariate dependencies get less obvious. it would be great if Enzyme could return without error in those cases (perhaps with a warning).

Essentially, I would like the following to be able to compile __enzyme_fwddiff for the null $\frac{\partial f}{\partial y}$ with -enzyme-auto-sparsity=1

void residual(size_t n, double* x, double* y, double * f)
{
    for (size_t i = 0; i < n; ++i)
    { 
       f[i] = some_sparse_expression(x); // no dependency on y
    }
}

cc @pelesh @wsmoses

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions