Repository navigation
Fix native D.UPM when exactly one degree is an integer - #200
Open
gitRasheed wants to merge 1 commit into
Open
gitRasheed wants to merge 1 commit into
gitRasheed wants to merge 1 commit into
Conversation
The vendored NNS-core d_upm swaps its two mixed-degree branches: with one integer and one fractional degree it applies repeated multiplication to the wrong side and drops the fractional power, so D.UPM(1, 1.5, ...) returned the D.UPM(1, 1, ...) value. Every public d_upm call goes through d_upm_v, which uses that kernel. Add src/nns/_r14_partial_moments.cpp, the vendored partial_moments.cpp with those two branches matched to R's DUPM_C, swap it in for the vendor translation unit in CMake, and register it with its hashes in sync/nns_source.json. extern/NNS-core is unchanged. The co-moment parity grid gains (1, 1.5), (1.5, 1), (2, 0.5), (0.5, 1) and (0, 0.5), with five new pm14.co_moments cache entries generated by the pinned NNS 14.0 archive under R 4.5.0, and checks the scalar native d_lpm/d_upm kernels too.
Collaborator
Author
|
The failing checks here aren't from this change. The Ubuntu 26.04 runner's GCC enables fused multiply-add, which moves about 28 bitwise tests by 1 to 4 ulp on main too (#201 fails the same ones). #202 builds the native kernels with |
This branch has not been deployed
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.
With the native extension,
d_upmis wrong whenever one degree is an integer and the other isn't. The 2.3.0 wheel on PyPI has it:The pure-Python path (
NNS_DISABLE_NATIVE=1) andd_lpmare correct.The cause is in the vendored NNS-core at a0d3b93. Its
d_upmhas the two mixed-degree branches swapped, so the integer fast path runs on the wrong side and the fractional degree gets truncated to an integer. NNS-core #39 fixes it, but that PR isn't merged, so the fix isn't vendored here. The parity grid only used (3, 1), (0.5, 1.5) and (2, 0), and none has exactly one integer degree.I added a hashed overlay, like the mreg_predict one.
src/nns/_r14_partial_moments.cppis the vendored file with only those two branches changed to match R'sDUPM_C. CMake builds it in place of the vendor file, and I registered it insync/nns_source.json.extern/NNS-coreis unchanged.The co-moment parity test now covers (1, 1.5), (1.5, 1), (2, 0.5), (0.5, 1) and (0, 0.5), for both native and fallback. It adds five cache entries I generated from the pinned NNS 14.0 archive under R 4.5.0. Before the fix, the five native cases fail on
dupm. After it, they all pass.