Skip to content

perf: speed up unit tests by 33% and fix FactorValue hash collision#1182

Merged
Jammy2211 merged 1 commit intomain_buildfrom
feature/unit-test-profiling
Apr 6, 2026
Merged

perf: speed up unit tests by 33% and fix FactorValue hash collision#1182
Jammy2211 merged 1 commit intomain_buildfrom
feature/unit-test-profiling

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

Reduces test suite runtime from 61s to 41s (33%) by shrinking observation counts, EP iteration steps, grid search steps, and sampler maxcall values in tests that used more data than needed to validate correctness.

Also fixes a latent bug in AbstractJacobian.grad() where FactorValue (which gets id=0 from the global counter) hash-collided with any GaussianPrior that also received id=0, causing the gradient dict to silently drop a variable. This manifested as a KeyError in test_gaussian.

API Changes

None — internal changes only.

Test Plan

  • All 1198 tests pass
  • test_gaussian (previously failing) now passes
  • Verified no numerical assertion changes — only data sizes, iteration counts, and query points adjusted
Full API Changes (for automation & release notes)

Changed Behaviour

  • AbstractJacobian.grad() in autofit/graphical/factor_graphs/jacobians.py — fixed bug where FactorValue key (id=0) could collide with a GaussianPrior key (id=0) in the gradient dict, silently dropping that variable's gradient. No public API change.

Migration

None required — this is a bugfix with no signature or behavioural contract change.

🤖 Generated with Claude Code

Reduces test suite runtime from 61s to 41s (33%) by shrinking observation
counts, EP iteration steps, grid search steps, and sampler maxcall values
in tests that used more data than needed to validate correctness.

Also fixes a bug in AbstractJacobian.grad() where FactorValue (id=0)
hash-collided with GaussianPrior id=0, causing test_gaussian to fail.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 merged commit 0cdffc8 into main_build Apr 6, 2026
1 check passed
@Jammy2211 Jammy2211 deleted the feature/unit-test-profiling branch April 6, 2026 17:06
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