Skip to content

fix(billing): include rank-dependent work in truncated SVD prices - #318

Merged
dipamc merged 1 commit into
mainfrom
fix/svd-rank-cost
Oct 16, 2026
Merged

dipamc merged 1 commit into
mainfrom
fix/svd-rank-cost

Conversation

@dipamc

@dipamc dipamc commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Truncated SVD previously billed only 4mnk while returning exact economy-SVD factors. Near-full-rank calls could recover the missing triplet in quadratic work, or zero-pad a matrix and request all its original components, for substantially less than the full-SVD price.

Use the approved rank-dependent formulas for 1 <= k < b, with a=max(m,n) and b=min(m,n):

Result Charge
With vectors min(4mnk + 6(m+n)k² + 20k³, 6ab² + 20b³)
Values only min(4mnk + 2(m+n)k² + 2k³, 2ab² + 2b³)

The shared cost helper drives svd, svd(compute_uv=False), svdvals, and analytical cost queries. Full calls and their existing thin/full-vector/values-only prices remain unchanged, as do exact numerical outputs, upfront budget checks, dtype/complex/weight factors, and batch multiplication. This does not depend on other open PRs and does not bump or publish a package version.

The formulas are analytical pricing conventions, not literal counts of the NumPy backend. They close the reported large-matrix near-full-rank/padding discounts, but do not establish a universal lower bound on small-matrix or composite reconstruction algorithms. Documentation removes that earlier absolute claim.

Validation

  • New/updated pricing regressions first failed on the previous implementation: 24 failed, 58 passed.
  • Full default core suite: 10,702 passed, 125 skipped, 2 xfailed; coverage 85.40% (85% gate).
  • Focused SVD/linalg/accounting/cost tests: 729 passed.
  • Actual ZMQ client/server integration with a NumPy-free client: 63 passed, including new vector/values/svdvals, cap and batched cases.
  • Fast differential parity: 135 passed.
  • Ruff lint/format passed; Pyright: 0 errors, 4 preexisting warnings.
  • Generated API docs verification, client synchronization, and package-version synchronization passed.

Tests exercise the reported complement and zero-padding routes, rectangular/transposed shapes, small-matrix residual behavior, both values-only entry points, production float/complex multipliers, and rejection before backend execution when the new price exceeds budget.

Cost model, public docstrings/examples, registry notes, generated ops.json and the Unreleased billing-impact notes are updated. Per-command hooks were bypassed to avoid resyncing a shared virtualenv; the direct checks above were executed on this branch. GitHub CI will verify the supported-version matrix.

@dipamc
dipamc merged commit 1d8d00c into main Oct 16, 2026
24 checks passed
@dipamc
dipamc deleted the fix/svd-rank-cost branch October 16, 2026 07:44
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.

1 participant