Skip to content

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
spr/edge/7c20f8e1from
spr/edge/00d8bc52
Draft

feat(math): small-N degenerate parity — run the real math on tiny matrices in clojure-legacy mode#2653
jucor wants to merge 1 commit into
spr/edge/7c20f8e1from
spr/edge/00d8bc52

Conversation

@jucor

@jucor jucor commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

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


Stack:


⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.

…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
@jucor jucor changed the title feat(math): small-N degenerate parity — run the real math on tiny matrices in clojure-legacy mode feat(math): small-N degenerate parity — run the real math on tiny mat… Jul 22, 2026
@jucor
jucor changed the base branch from spr/edge/7c20f8e1 to edge July 22, 2026 08:11
@jucor jucor changed the title feat(math): small-N degenerate parity — run the real math on tiny mat… feat(math): small-N degenerate parity — run the real math on tiny matrices in clojure-legacy mode Jul 22, 2026
@jucor
jucor changed the base branch from edge to spr/edge/7c20f8e1 July 22, 2026 08:11
@jucor jucor changed the title feat(math): small-N degenerate parity — run the real math on tiny matrices in clojure-legacy mode feat(math): small-N degenerate parity — run the real math on tiny mat… Jul 22, 2026
@jucor
jucor changed the base branch from spr/edge/7c20f8e1 to edge July 22, 2026 09:58
@jucor jucor changed the title feat(math): small-N degenerate parity — run the real math on tiny mat… feat(math): small-N degenerate parity — run the real math on tiny matrices in clojure-legacy mode Jul 22, 2026
@jucor
jucor changed the base branch from edge to spr/edge/7c20f8e1 July 22, 2026 09:58
@jucor jucor changed the title feat(math): small-N degenerate parity — run the real math on tiny matrices in clojure-legacy mode feat(math): small-N degenerate parity — run the real math on tiny mat… Jul 22, 2026
@jucor
jucor changed the base branch from spr/edge/7c20f8e1 to edge July 22, 2026 11:20
@jucor jucor changed the title feat(math): small-N degenerate parity — run the real math on tiny mat… feat(math): small-N degenerate parity — run the real math on tiny matrices in clojure-legacy mode Jul 22, 2026
@jucor
jucor changed the base branch from edge to spr/edge/7c20f8e1 July 22, 2026 11:21
@jucor jucor changed the title feat(math): small-N degenerate parity — run the real math on tiny matrices in clojure-legacy mode feat(math): small-N degenerate parity — run the real math on tiny mat… Jul 24, 2026
@jucor
jucor changed the base branch from spr/edge/7c20f8e1 to edge July 24, 2026 06:02
@jucor jucor changed the title feat(math): small-N degenerate parity — run the real math on tiny mat… feat(math): small-N degenerate parity — run the real math on tiny matrices in clojure-legacy mode Jul 24, 2026
@jucor
jucor changed the base branch from edge to spr/edge/7c20f8e1 July 24, 2026 06:02
@jucor
jucor requested a review from Copilot July 25, 2026 22:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants