Repository navigation
fix: align denoising score target with energy gradient - #333
Merged
soran-ghaderi merged 1 commit intoSep 15, 2026
Merged
Conversation
soran-ghaderi
approved these changes
Sep 15, 2026
soran-ghaderi
left a comment
Owner
There was a problem hiding this comment.
thanks. it's clean and woring correctly. will be included in the next release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
BaseScoreMatching.compute_score()returnsgrad E, but denoising score matching compared it with the conditional log-density score-noise / sigma^2. The opposite conventions make DSM train a quadratic energy in the wrong direction.Solution
Match the energy gradient against
noise / sigma^2, the negative of the conditional log-density score.The regression test starts a closed-form quadratic energy at zero scale. Standard normal data should push that scale positive, so the loss gradient must be negative. The test applies the same check to exact, denoising, and sliced score matching, pinning their shared convention. On the original code only the DSM case fails (
grad = +1.9391); after this change all three pass.Validation
pytest tests/losses/test_denoising_score_matching.py -v— 9 passed, 1 CUDA skippytest tests/ -v— 1764 passed, 108 skipped, 21 deselectedgit diff --checkCloses #318