Skip to content

Check the df cache budget before factoring C (Copilot review of #126) - #127

Merged
fabian-s merged 1 commit into
pffr-refactorfrom
df-budget-order
Sep 18, 2026
Merged

fabian-s merged 1 commit into
pffr-refactorfrom
df-budget-order

Conversation

@fabian-s

Copy link
Copy Markdown
Member

Addresses the Copilot review on #126: pffr_influence_core() computed and verified chol(C) before testing the cache budget, so df_precompute_bytes = 0 still paid the O(p^3) factorization. The budget test now runs first; verification and the fallback path are unchanged. A test mocks base::chol to assert it is never called at zero budget and that df / expected sampling variance match the cached path to 1e-12.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QSoB6DyAfeyS9PytuzQs3x

pffr_influence_core() computed and verified a full chol(C) unconditionally
before testing whether the per-cluster residualization blocks would even
fit the df_precompute_bytes budget. That defeated the documented opt-out
(df_precompute_bytes = 0) and could add an unnecessary O(p^3) cost. Move
the byte-budget test ahead of the factorization; the verification and
fallback behavior are unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSoB6DyAfeyS9PytuzQs3x
Copilot AI lite review requested due to automatic review settings September 18, 2026 11:12
@fabian-s
fabian-s merged commit 7406d28 into pffr-refactor Sep 18, 2026
1 check passed
@fabian-s
fabian-s deleted the df-budget-order branch September 18, 2026 11:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

A moderate issue remains for zero-budget, all-zero-rank designs.

Pull request overview

This PR checks the df cache budget before factoring C and adds regression coverage.

Changes:

  • Gates chol(C) on the cache budget.
  • Tests zero-budget behavior and numerical equivalence.
  • An all-zero-rank case still calls chol(C) at zero budget and needs a guard plus boundary test.
File summaries
File Summary
R/pffr-influence.R Checks the cache budget before factoring C; all-zero-rank handling remains unresolved.
tests/testthat/test-pffr-inference-core.R Adds zero-budget and equivalence tests; needs all-zero-rank coverage.
Review details

Suppressed comments (1)

R/pffr-influence.R:188

  • When every cluster has rank 0, sum(rank) is zero, so this condition is true even for df_precompute_bytes = 0 and line 189 still calls chol(C). No cached blocks are needed in that case, so the zero-budget opt-out still pays the O(p^3) factorization for an all-zero design. Add a nonzero-rank guard (and cover this boundary case in the test).
  within_budget <- 8 * p * sum(rank) <= df_precompute_bytes
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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