Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrimalSubstituteOf attribute causes internal compiler error #5867

Open
tunabrain opened this issue Dec 14, 2024 · 2 comments
Open

PrimalSubstituteOf attribute causes internal compiler error #5867

tunabrain opened this issue Dec 14, 2024 · 2 comments
Assignees
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang

Comments

@tunabrain
Copy link

The following snippet causes an internal compiler error with Slang compilation aborted due to an exception of class Slang::InternalError: assert failure: udfDecor:

struct BufferWithGrad
{
    RWStructuredBuffer<float> primal;
    StructuredBuffer<float> grad;

    [Differentiable]
    void set(float value) { primal[0] = detach(value); }

    [PrimalSubstituteOf(set)]
    void set_subst(float value)
    {
    }

    [BackwardDerivativeOf(set)]
    void set_bwd(inout DifferentialPair<float> d)
    {
        d = diffPair(d.p, grad[0]);
    }
}

BufferWithGrad result;

[Differentiable]
void diffCall()
{
    result.set(0.0f);
}

[shader("compute")]
[numthreads(32, 1, 1)]
void main(uint3 dispatchThreadID: SV_DispatchThreadID)
{
    bwd_diff(diffCall)();
}

@bmillsNV bmillsNV added this to the Q1 2025 (Winter) milestone Dec 16, 2024
@bmillsNV bmillsNV added the goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang label Dec 16, 2024
@bmillsNV
Copy link
Collaborator

@tunabrain is this blocking you right now or is Q1 OK for this issue?

@tunabrain
Copy link
Author

If there is a workaround then it's not blocking. If not, then it becomes a tricky issue, since it means we can't compute gradients without invoking side effects from the primal function. Is this a known issue or does this need investigation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang
Projects
None yet
Development

No branches or pull requests

3 participants