PR #1, Weeks 3-4: implement core protocol + bind_observation#1876
PR #1, Weeks 3-4: implement core protocol + bind_observation#1876Jocho-Smith wants to merge 1 commit into
Conversation
Implements the first GSoC 2026 deliverable for the PotentialFunction API redesign. Layer 1 - Core Protocol: - Add PotentialFunction protocol (stateless callable: theta, x -> log_prob) - Add PotentialFunctionWithDevice protocol with device property - Add validate_potential() helper for runtime protocol validation Layer 2 - Binding Utilities: - Add bind_observation() utility for creating sampler-ready functions - Add BoundPotential class as alternative class-based binding - Implement IID handling via sum_iid parameter - Implement device validation with clear error messages Testing: - Add comprehensive unit tests (18 tests) covering: - Protocol validation and compliance - bind_observation functionality - IID handling (sum_iid) - Device validation and mismatch errors - Statelessness (property-based: repeated calls yield identical outputs) - Gradient tracking - Backward compatibility with existing LikelihoodBasedPotential This enables: - Stateless potential functions without hidden state - Easy integration with PyMC, and custom PyTorch samplers - Clear device handling with explicit error messages - Backward compatibility: existing potentials continue to work
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1876 +/- ##
==========================================
- Coverage 87.89% 87.85% -0.04%
==========================================
Files 143 145 +2
Lines 13353 13417 +64
==========================================
+ Hits 11736 11788 +52
- Misses 1617 1629 +12
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I was thinking the same thing. For NN Builder API Refactor also there would be 8 PRs. Also my upcoming PR 2 requires my PR 1 to be merged, so I would be creating PR 2 as draft PR. Maybe a GSoC specific branch would be a good thing. Am okay with whatever maintainers prefer. |
|
Thanks, @Jocho-Smith and @satwiksps! just briefly here to unblock you. Yes, it's actually a good idea, if your PRs are introducing breaking changes. We are planning to do a release soon, and we don't want to introduce breaking changes in there. That said, the PRs that go into that branch should be treated as if they go into So, yes, let's merge your PRs, into an intermediate Hope this helps! |
Implements the first GSoC 2026 deliverable for the PotentialFunction API redesign.
Layer 1 - Core Protocol:
Layer 2 - Binding Utilities:
Testing:
Open questions:
Note: