Repository navigation
Fix native D.UPM when exactly one degree is an integer - #200
Merged
Merged
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 |
OVVO-Financial
pushed a commit
that referenced
this pull request
Nov 21, 2026
…ns-r14-parity-fidelity-rgag0e #200 and #203 both added src/nns/_r14_partial_moments.cpp: #200's is the vendor partial-moment overlay with the D.UPM fix, #203's the R 14.2 normalisation helpers for the nD moments and PM.matrix. #200's keeps the name; #203's becomes src/nns/_r14_pm_norm.{cpp,hpp}. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wws6NpuQ72C5sfEYVoVmGt
OVVO-Financial
pushed a commit
that referenced
this pull request
Nov 21, 2026
- r_commit f0387ed and NNS_14.2.tar.gz as stored there (sha256 a4e04b26...), the archive the cache builder downloads; its R/ and src/ files equal the Git tree apart from CRLF line endings and final newlines. - The central-tendency and M.reg prediction overlays now port f0387ed's sources. The dependence and D.UPM overlays keep their source commits: R 14.2 changes those files only in label ordering and the zero-total rule. - #203's normalisation helper is tracked under its new name, src/nns/_r14_pm_norm.cpp, beside #200's D.UPM overlay, so there are six overlays, all verified against f0387ed. - Cache summary: 150 shards, 3124 entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wws6NpuQ72C5sfEYVoVmGt
4 of 5 tasks
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.