Skip to content

fix(autogram): Raise error on forward pass without backward pass - #793

Merged
ValerianRey merged 2 commits into
SimplexLab:mainfrom
ppraneth:bugss
Oct 7, 2026
Merged

ValerianRey merged 2 commits into
SimplexLab:mainfrom
ppraneth:bugss

Conversation

@ppraneth

@ppraneth ppraneth commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@ppraneth
ppraneth requested review from a team, PierreQuinton and ValerianRey as code owners October 5, 2026 13:18

@ValerianRey ValerianRey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

I think the formulation is a bit wrong. It's not that a forward pass is not used to compute the output, it's that it's a forward pass that doesn't have an associated backward pass.

In your example, the output is losses, which does depend on target, so the forward pass of encoder used to compute target is actually used to compute the output. It's just that we won't ever backward through the target because of the detach.

Could you fix the formulation? Then I think we can merge this!

@ppraneth ppraneth changed the title fix(autogram): Raise error when a forward pass is not used to compute the output fix(autogram): Raise error on forward pass without backward pass Oct 6, 2026
@ppraneth
ppraneth requested a review from ValerianRey October 6, 2026 02:51
@ValerianRey ValerianRey added cc: fix Conventional commit type for bug fixes of the actual library (changes to src). package: autogram labels Oct 6, 2026
@ValerianRey

Copy link
Copy Markdown
Member

Basically, for future reference, as discussed on discord privately, the reason of this bug is that during a forward pass, the remaining_counter of the module is always incremented, but sometimes (when the output of the module is detached, like in the example), the backward pass of the module is never called, so the remaining_counter never reaches zero, and the contribution from other backward passes of this same module is thus never added to the global gramian. Since the reasons making the remaining_counter not reach 0 could also be different, it's safer to just raise an error, which this PR adds.

cc @PierreQuinton

@ValerianRey
ValerianRey merged commit 120272a into SimplexLab:main Oct 7, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: fix Conventional commit type for bug fixes of the actual library (changes to src). package: autogram

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants