feat(math): PCA warm start in clojure-legacy engine mode (PR-B)#2619
Closed
jucor wants to merge 1 commit into
Closed
feat(math): PCA warm start in clojure-legacy engine mode (PR-B)#2619jucor wants to merge 1 commit into
jucor wants to merge 1 commit into
Conversation
This was referenced Jul 18, 2026
jucor
marked this pull request as draft
July 18, 2026 01:48
Threads the previous tick's unit components into the power-iteration PCA as
start vectors when POLISMATH_ENGINE_MODE=clojure-legacy, matching Clojure
(conversation.clj:381-387 passes :start-vectors (get-in conv [:pca :comps])
into powerit-pca, pca.clj:86-105; new columns absorbed by 1-padding,
pca.clj:46-49). Default 'improved' mode is unchanged (cold recompute).
- pca_project_dataframe gains start_vectors (default None) and require_powerit
(default False). With both absent the code path is BYTE-IDENTICAL to before.
When a warm start is supplied — or required by legacy mode — and
POLISMATH_PCA_IMPL=sklearn is set, we warn and fall back to power iteration:
sklearn's SVD has no start-vector hook, so running it would silently drop the
warm start (documented at the guard).
- powerit_pca already supported start_vectors + 1-padding + all-zero->None;
this just wires production callers to it.
- Conversation._compute_pca: in legacy mode sets require_powerit=True and, when
prev_pca has real comps, start_vectors = prev comps (empty/cold -> None, the
deterministic random cold draw). prev_pca is captured in recompute() (PR-A).
Semantic judgment calls (integrator, please verify vs Clojure):
- Warm start is POSITIONAL: prev comps align to current columns by index, and
new (appended) comments are 1-padded — exactly Clojure's behavior. Column
removal/reorder would misalign, but Clojure is append-only here and
_power_iteration truncates a too-long start vector defensively (pre-existing,
pca.py:124-127) where Clojure would error.
- "legacy implies powerit" is enforced via require_powerit=True even on the
cold first tick, so an operator setting PCA_IMPL=sklearn + legacy still gets
powerit (with a warning).
TDD RED evidence (before implementing):
test_start_vectors_reach_powerit:
"TypeError: pca_project_dataframe() got an unexpected keyword argument
'start_vectors'"
test_legacy_tick2_receives_tick1_comps: "assert None is not None"
(tick 2 ran cold; no comps threaded)
Tests: 8 new (start_vectors threading, sklearn-conflict warning, improved
byte-identity, two-tick legacy warm start via spy, angle stability, cold-tick
cross-mode identity). Full suite 422 passed, 17 skipped, 47 xfailed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
commit-id:b39add7e
This was referenced Jul 18, 2026
Collaborator
Author
|
Closing pull request: commit has gone away |
Collaborator
Author
|
Superseded by #2640 (an spr commit-id mishap force-closed this PR; content and history continue there). |
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.
Threads the previous tick's unit components into the power-iteration PCA as
start vectors when POLISMATH_ENGINE_MODE=clojure-legacy, matching Clojure
(conversation.clj:381-387 passes :start-vectors (get-in conv [:pca :comps])
into powerit-pca, pca.clj:86-105; new columns absorbed by 1-padding,
pca.clj:46-49). Default 'improved' mode is unchanged (cold recompute).
(default False). With both absent the code path is BYTE-IDENTICAL to before.
When a warm start is supplied — or required by legacy mode — and
POLISMATH_PCA_IMPL=sklearn is set, we warn and fall back to power iteration:
sklearn's SVD has no start-vector hook, so running it would silently drop the
warm start (documented at the guard).
this just wires production callers to it.
prev_pca has real comps, start_vectors = prev comps (empty/cold -> None, the
deterministic random cold draw). prev_pca is captured in recompute() (PR-A).
Semantic judgment calls (integrator, please verify vs Clojure):
new (appended) comments are 1-padded — exactly Clojure's behavior. Column
removal/reorder would misalign, but Clojure is append-only here and
_power_iteration truncates a too-long start vector defensively (pre-existing,
pca.py:124-127) where Clojure would error.
cold first tick, so an operator setting PCA_IMPL=sklearn + legacy still gets
powerit (with a warning).
TDD RED evidence (before implementing):
test_start_vectors_reach_powerit:
"TypeError: pca_project_dataframe() got an unexpected keyword argument
'start_vectors'"
test_legacy_tick2_receives_tick1_comps: "assert None is not None"
(tick 2 ran cold; no comps threaded)
Tests: 8 new (start_vectors threading, sklearn-conflict warning, improved
byte-identity, two-tick legacy warm start via spy, angle stability, cold-tick
cross-mode identity). Full suite 422 passed, 17 skipped, 47 xfailed.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
commit-id:b39add7e
Stack: