Conversation
Member
Author
|
Waiting to merge until a new ezmsg-sigproc release, which is waiting on a new ezmsg release. |
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.
Summary
Extends Array API compliance across ezmsg-learn, following the pattern already established in
process/ssr.py. This enables the same code to run on NumPy, CuPy, PyTorch, and other Array API-compatible backends viaarray_api_compat.get_namespace().Phase 1: Kalman Filter (
model/refit_kalman.py,process/refit_kalman.py)fit(),predict(),update(): All linear algebra now uses Array API (xp.linalg.inv,xp.linalg.matrix_transpose,xp.linalg.pinv,xp_create(xp.eye, ...))._compute_gain(): DARE solver remains NumPy (no Array API equivalent forscipy.linalg.solve_discrete_are); results are converted back to the source namespace viaxp_asarray.refit(): Per-sample mutation loop stays NumPy (small-vectornp.linalg.norm, scalar indexing); final H/Q computation converted to xp._reset_state()/_process(): Derivexp/devfrommessage.data; output arrays created withxp_create..copy()calls (predict/update already return new arrays).Phase 2: Incremental CCA (
model/cca.py)scipy.linalg.inv(scipy.linalg.sqrtm(...))calls (4 occurrences) with_inv_sqrtm_spd()— an eigendecomposition-based inverse square root using only Array API ops (eigh,clip,sqrt,@,matrix_transpose).scipy.linalgdependency entirely from this module.np.linalg.norm->xp.linalg.matrix_norm,np.clip(scalar)-> Pythonmax(min(...)),.any()->bool(xp.any(...)).ref_arrayparameter toinitialize()for namespace derivation.tests/unit/test_cca.pywith 8 tests including numerical equivalence validation against scipy.Phase 3: Tier 2 Processors
process/slda.py:np.moveaxis->xp.permute_dims; NumPy boundary beforesklearn.predict_proba.process/adaptive_linear_regressor.py:np.any(np.isnan(...))->xp.any(xp.isnan(...)),np.moveaxis->xp.permute_dims; NumPy boundary before sklearn/river calls.dim_reduce/adaptive_decomp.py:np.prod->math.prod,.reshape->xp.reshape; NumPy boundary before sklearnpartial_fit/transform, convert back to source namespace after transform.Not changed
process/rnn.py(PyTorch-native)process/sklearn.py(generic wrapper, unknown models)process/linear_regressor.py,process/sgd.py(trivial: justnp.isnanguard + sklearn call)Test plan
_inv_sqrtm_spdvsscipy.linalg.sqrtmnumerical equivalence)