Type the two error conventions crossing the hybrid-pipeline boundary#403
Merged
Conversation
d6713da to
291396b
Compare
aa62ab2 to
2fa62cc
Compare
96f6501 to
91237d2
Compare
2fa62cc to
99da34b
Compare
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
99da34b to
913253b
Compare
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.
In pyhgf's "hybrid" / mixed pipelines, you can chain together two kinds of building blocks:
These two conventions are exact negatives of each other. If you accidentally mix them up the code runs fine, but training silently diverges. That's a nasty class of bug: invisible, and only detectable by noticing the model won't learn.
This PR makes this sign convention explicit and self-documenting so those bugs are caught or avoided, without changing any runtime behavior:
DescentError(gradient-like: positive = output too high) andObservedMinusPredicted(PyHGF's prediction error: positive = observation exceeded prediction) are now distinct annotated types, withvalidate_error_conventionas a runtime sanity check. The hybrid-pipeline docstrings spell out where the single descent ↔ observed-minus-predicted conversion happens (the executor's backward pass forDeepNetworkAdapter), andEquinoxAdapter.backward_fn's signature declares the convention it must respect. A missing negation at this boundary trains silently in the wrong direction; the types make that mistake visible.