feat(math): small-N degenerate parity — run the real math on tiny matrices in clojure-legacy mode#2653
Draft
jucor wants to merge 1 commit into
Draft
feat(math): small-N degenerate parity — run the real math on tiny matrices in clojure-legacy mode#2653jucor wants to merge 1 commit into
jucor wants to merge 1 commit into
Conversation
…rices in clojure-legacy mode Clojure has NO small-dim guards: a 1x1 single-vote conversation computes center = the vote, a rank-capped zero component, a repness entry (the best-agree guarantee holds for one comment; rest-stats over zero other groups fall back to the (0+1)/(0+2) prior) and a consensus selection — pinned exactly by the vw every-vote step-0 recording (journal 2026-07-22 'every-vote step-0 diagnosis COMPLETE'). Python short-circuited to zeros/ empties below 2x2, which made the every-vote battery entry diverge from step 0 (4650/4683 steps). Legacy-gated changes (improved keeps every historical guard): - _compute_pca + pca_project_dataframe: <2 guards only fire on truly EMPTY dims in legacy; the powerit path runs at any size (comps already rank-capped; zero-variance yields Clojure's zero vector). Projections zero-pad to 2-D (Clojure's [pc1 pc2] destructure zero-fills a missing second component), as does the emitted comment-projection. - conv_repness: the shape<2 early return yields to the real computation. TDD: single-vote fixtures with exact Clojure-derived values (center -1.0, p-success 2/3, repness 4/3, best-agree), RED observed; improved-mode guards pinned unchanged. commit-id:00d8bc52
This was referenced Jul 22, 2026
docs(delphi): R1-parity goal docs, journal (2026-07-18 → 07-24 s5), quirks + divergence ledger
#2626
Draft
Draft
Draft
This was referenced Jul 24, 2026
Draft
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Clojure parity for degenerate small-N conversations in clojure-legacy engine mode by allowing the real PCA/repness math to run on tiny (e.g., 1×1) vote matrices, matching the Clojure behavior used by the step-0 “every-vote” oracle. It keeps the historical “short-circuit to zeros/empties” behavior unchanged in improved mode.
Changes:
- Relax PCA and repness “<2 rows/cols” guards in legacy mode so 1×1 conversations compute real center/comps/repness/consensus instead of returning empties.
- Zero-pad legacy PCA projections to keep the emitted shapes consistent with Clojure (notably 2D projections / 2-row comment-projection emission).
- Add targeted tests that pin exact legacy outputs for a single-vote fixture while asserting improved-mode behavior is unchanged.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
delphi/tests/test_legacy_blob_shape.py |
Adds single-vote degenerate fixtures asserting legacy runs real math and improved mode keeps existing guards. |
delphi/polismath/pca_kmeans_rep/repness.py |
Makes repness/consensus run for 1×1 in clojure-legacy while preserving the historical guard in improved. |
delphi/polismath/pca_kmeans_rep/pca.py |
Adjusts PCA small-dim guard behavior for the require_powerit (legacy) path and pads projections for legacy parity. |
delphi/polismath/conversation/conversation.py |
Updates PCA guard logic by engine mode and pads legacy comment-projection output to match Clojure’s always-2-row emission. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Clojure has NO small-dim guards: a 1x1 single-vote conversation computes
center = the vote, a rank-capped zero component, a repness entry (the
best-agree guarantee holds for one comment; rest-stats over zero other
groups fall back to the (0+1)/(0+2) prior) and a consensus selection —
pinned exactly by the vw every-vote step-0 recording (journal 2026-07-22
'every-vote step-0 diagnosis COMPLETE'). Python short-circuited to zeros/
empties below 2x2, which made the every-vote battery entry diverge from
step 0 (4650/4683 steps).
Legacy-gated changes (improved keeps every historical guard):
EMPTY dims in legacy; the powerit path runs at any size (comps already
rank-capped; zero-variance yields Clojure's zero vector). Projections
zero-pad to 2-D (Clojure's [pc1 pc2] destructure zero-fills a missing
second component), as does the emitted comment-projection.
TDD: single-vote fixtures with exact Clojure-derived values (center -1.0,
p-success 2/3, repness 4/3, best-agree), RED observed; improved-mode
guards pinned unchanged.
commit-id:00d8bc52
Stack: