Skip to content

Perf T3-3: Deduplicate K symbol flattening#139

Open
hmzh-khn wants to merge 4 commits into
perf/14-cache-extractor-matricesfrom
perf/15-dedup-k-flattening
Open

Perf T3-3: Deduplicate K symbol flattening#139
hmzh-khn wants to merge 4 commits into
perf/14-cache-extractor-matricesfrom
perf/15-dedup-k-flattening

Conversation

@hmzh-khn

Copy link
Copy Markdown
Collaborator

Summary

Eliminates redundant K symbol vector flattening during solver construction. The same vcat([reshape(something(K_syms[ii], ...), :) for ii in 1:N]...) expression was computed identically in both setup_approximate_kkt_solver and preoptimize_nonlinear_solver. Now computed once and passed through the setup_info named tuple.

Changes

  • src/nonlinear_kkt.jl: Added all_K_syms_vec to the named tuple returned by setup_approximate_kkt_solver; replaced duplicate computation in preoptimize_nonlinear_solver with setup_info.all_K_syms_vec
  • test/test_k_sym_dedup.jl: New test verifying the deduplication (5 assertions: field exists, length match, symbolic equality, augmented variable consistency)
  • test/test_tiers.jl: Registered new test in fast tier
  • test/test_test_tiers.jl: Updated expected file lists
  • RETROSPECTIVES.md: Added retrospective entry

Impact

Minor — eliminates one redundant symbolic vector concatenation during setup. Not a hot-path change (setup runs once per solver construction).

Testing

  • All 1240 tests pass
  • New test test_k_sym_dedup.jl added to fast tier

Changelog

  • 2026-02-14: Initial PR with deduplication + test + retrospective

🤖 Generated with Claude Code

claude and others added 4 commits February 14, 2026 11:32
Tests that setup_approximate_kkt_solver returns all_K_syms_vec in its
named tuple, avoiding redundant computation in preoptimize_nonlinear_solver.

TDD Red step: test fails because setup_info doesn't yet include
all_K_syms_vec.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
setup_approximate_kkt_solver now returns all_K_syms_vec in its named
tuple. preoptimize_nonlinear_solver reuses this instead of recomputing
the same vcat+reshape expression.

This eliminates one redundant symbolic vector flattening during solver
construction. The third occurrence (line 695) operates on numerical
K_evals at solve time, not symbolic K_syms during setup.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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