Skip to content

fix incorrect comment in StructuredDot.grad#1890

Merged
ricardoV94 merged 2 commits intopymc-devs:mainfrom
arpanjha234:fix-structured-dot-grad-comment
Feb 19, 2026
Merged

fix incorrect comment in StructuredDot.grad#1890
ricardoV94 merged 2 commits intopymc-devs:mainfrom
arpanjha234:fix-structured-dot-grad-comment

Conversation

@arpanjha234
Copy link
Contributor

@arpanjha234 arpanjha234 commented Feb 17, 2026

Description

This PR resolves #1871 by correcting outdated and misleading comments in the StructuredDot.grad method.

Changes:

  • Fixed the comment for ga. It previously described a standard dense dot product ($g_{out} \times B^T$), but the implementation uses structured_dot_grad to maintain the sparsity pattern of a.
  • Removed the incorrect claim that b and g_out must be dense.
  • Added a note specifying that sparse inputs are supported in the Python and Numba backends (referencing the work in Implement StructuredDotGradCSR and StructuredDotGradCSC in numba backend #1860) but are not yet supported by the C backend.

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

@arpanjha234 arpanjha234 marked this pull request as draft February 17, 2026 12:31
@arpanjha234 arpanjha234 marked this pull request as ready for review February 17, 2026 12:31
@arpanjha234 arpanjha234 marked this pull request as draft February 17, 2026 12:31
@arpanjha234 arpanjha234 marked this pull request as ready for review February 17, 2026 12:32
@ricardoV94
Copy link
Member

ricardoV94 commented Feb 17, 2026

I don't have the context of why that FIXME was added. I'll let @tomicapretto handle it (if he wants to)

@tomicapretto
Copy link
Contributor

I don't have the context of why that FIXME was added. I'll let @tomicapretto handle it (if he wants to)

@ricardoV94 the new comments reflect the state of things, but I think the real question is whether we want different backends to support different input types.

@ricardoV94
Copy link
Member

ricardoV94 commented Feb 17, 2026

@ricardoV94 the new comments reflect the state of things, but I think the real question is whether we want different backends to support different input types.

The alternative is for all the backends to support everything? That's WIP but why must such note live in this method? Is the implementation trying to change things because of this? It won't know which backend will be ultimately used...

@tomicapretto
Copy link
Contributor

The alternative is for all the backends to support everything?

I think so, although I don't know if there's appetite to update the C code.

That's WIP but why must such note live in this method?

The origin of this is there was a note, in the exact same place, saying b and g_out where dense.
I noticed it was wrong for Python and Numba backends, so I added a FIXME in tomicapretto@026202a

Is the implementation trying to change things because of this? It won't know which backend will be ultimately used..

Nope, but the original comment was wrong and I've noticed so they are the parameter names in structured_dot_grad are wrong too.

@ricardoV94 ricardoV94 merged commit 2d9a7ae into pymc-devs:main Feb 19, 2026
2 checks passed
@arpanjha234 arpanjha234 deleted the fix-structured-dot-grad-comment branch February 19, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comment in StructuredDot.grad is not correct

3 participants