Skip to content

Preserve Complex Bingham single-point autograd - #5258

Open
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/preserve-complex-bingham-single-point-autograd
Open

Preserve Complex Bingham single-point autograd#5258
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/preserve-complex-bingham-single-point-autograd

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Bug

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

On the PyTorch backend, a complex query tensor with requires_grad=True therefore produced a Python float. That conversion silently detached the likelihood from the computation graph, so callers could not differentiate a single-point Complex Bingham density 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 numerical value while retaining the active backend's scalar type and PyTorch autograd history.

Regression coverage

Add a PyTorch-backend regression that evaluates a unit-norm complex point with requires_grad=True and verifies:

  • the result is a scalar PyTorch tensor;
  • the result is float64 on the same device as the query;
  • the density is finite and positive;
  • the density remains differentiable;
  • backpropagation reaches the complex query with finite, nonzero gradients.

Validation

  • independently reproduced that float(...) turns a differentiable PyTorch scalar into a plain Python float and prevents .backward();
  • verified the backend scalar path backpropagates finite, nonzero gradients with PyTorch 2.10;
  • final diff is limited to a one-line production fix and one focused 43-line regression module;
  • 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.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 29.16s
✅ JSON prettier 7 0 0 0 1.32s
✅ JSON v8r 7 0 0 4.5s
✅ MARKDOWN markdownlint 68 0 0 0 1.8s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.89s
✅ PYTHON black 1867 87 0 0 97.52s
✅ PYTHON isort 1867 141 0 0 2.81s
✅ REPOSITORY betterleaks yes no no 2.61s
✅ REPOSITORY checkov yes no no 54.16s
✅ REPOSITORY gitleaks yes no no 17.33s
✅ REPOSITORY git_diff yes no no 0.62s
✅ REPOSITORY secretlint yes no no 83.49s
✅ REPOSITORY syft yes no no 6.16s
✅ REPOSITORY trivy-sbom yes no no 5.88s
✅ REPOSITORY trufflehog yes no no 32.23s
✅ YAML prettier 11 0 0 0 0.83s
✅ YAML v8r 11 0 0 10.81s
✅ YAML yamllint 11 0 0 0.6s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

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@9.6.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_GITLEAKS,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

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

@FlorianPfaff
FlorianPfaff marked this pull request as ready for review August 7, 2026 17:53
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 7, 2026 17:53
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