Skip to content

Preserve Gauss-von-Mises single-point autograd - #5255

Merged
FlorianPfaff merged 1 commit into
mainfrom
agent/preserve-gauss-von-mises-single-point-autograd
Aug 12, 2026
Merged

Preserve Gauss-von-Mises single-point autograd#5255
FlorianPfaff merged 1 commit into
mainfrom
agent/preserve-gauss-von-mises-single-point-autograd

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Bug

GaussVonMisesDistribution.pdf(...) kept backend-native values for batched evaluation, but the single-point path returned float(p[0]).

On the PyTorch backend, a query tensor with requires_grad=True therefore produced a Python float. The conversion silently detached the density from the computation graph, so callers could not differentiate a single-point likelihood even though the equivalent batched path remained differentiable.

Fix

Return the backend scalar p[0] directly for single-point evaluation instead of converting it to Python float.

This preserves the existing numerical value while keeping the active backend's dtype, device, and autograd history.

Regression coverage

Add a PyTorch-backend regression that evaluates a single Gauss-von-Mises point with requires_grad=True and verifies:

  • the result is a scalar PyTorch tensor;
  • dtype and device match the query;
  • the density is finite and positive;
  • backpropagation reaches both query coordinates with finite, nonzero gradients.

Validation

  • independently confirmed that converting a differentiable PyTorch scalar with float(...) returns a plain Python float and loses autograd;
  • final production diff is one line;
  • branch is based directly on current main (f196ec41d1d8681e279936db9f1a0a3abfa276e7) and is 2 commits ahead / 0 behind;
  • GitHub Actions is authoritative for the full backend, lint, packaging, documentation, and integration matrix.

@FlorianPfaff
FlorianPfaff marked this pull request as ready for review August 6, 2026 19:42
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 7, 2026 02:19
auto-merge was automatically disabled August 10, 2026 14:46

Pull request was closed

@FlorianPfaff FlorianPfaff reopened this Aug 10, 2026
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 10, 2026 14:46
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 7.69s
✅ JSON prettier 7 0 0 0 0.6s
✅ JSON v8r 7 0 0 4.7s
✅ MARKDOWN markdownlint 68 0 0 0 2.05s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.5s
✅ PYTHON black 1876 91 0 0 72.32s
✅ PYTHON isort 1876 150 0 0 2.88s
✅ REPOSITORY betterleaks yes no no 1.13s
✅ REPOSITORY checkov yes no no 36.77s
✅ REPOSITORY git_diff yes no no 0.25s
✅ REPOSITORY secretlint yes no no 103.95s
✅ REPOSITORY syft yes no no 2.98s
✅ REPOSITORY trivy-sbom yes no no 2.42s
✅ YAML prettier 11 0 0 0 0.76s
✅ YAML v8r 11 0 0 17.8s
✅ YAML yamllint 11 0 0 1.08s

Notices

⚠️ Your configuration references items that have been removed from MegaLinter and are ignored: MAKEFILE_CHECKMAKE. See Removed linters to find their replacements.

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@10.0.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is provided by OX Security
Show us your support by starring ⭐ the repository

@FlorianPfaff
FlorianPfaff force-pushed the agent/preserve-gauss-von-mises-single-point-autograd branch from cc97fdf to 019e982 Compare August 12, 2026 10:23
@FlorianPfaff
FlorianPfaff merged commit 6fd8244 into main Aug 12, 2026
20 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant