Skip to content

[WIP] Unify constants and parameters into single parameter_expr type#53

Open
Transurgeon wants to merge 8 commits intomainfrom
parameter-support-v2
Open

[WIP] Unify constants and parameters into single parameter_expr type#53
Transurgeon wants to merge 8 commits intomainfrom
parameter-support-v2

Conversation

@Transurgeon
Copy link
Copy Markdown
Collaborator

@Transurgeon Transurgeon commented Mar 25, 2026

Constants and updatable parameters are now represented by a single parameter_expr node. Constants use param_id == PARAM_FIXED (-1), while updatable parameters use param_id >= 0. Bivariate ops (left_matmul, right_matmul, scalar_mult, vector_mult) accept an optional param_source node and refresh their internal data on forward/jacobian/hessian evaluation. Adds problem_register_params and problem_update_params for problem-level parameter management. Also adds update_values to the Matrix interface for parameter refresh.

▎ - Unifies constants and updatable parameters into a single parameter_expr type (param_id == PARAM_FIXED for constants, >= 0 for updatable parameters)
▎ - Adds update_values to the Matrix interface for parameter refresh (sparse and dense)
▎ - Makes left_matmul, right_matmul, scalar_mult, and vector_mult parameter-aware via optional param_source pointer
▎ - Adds problem_register_params / problem_update_params for problem-level parameter management
▎ - Renames constant.c → parameter.c, const_scalar_mult.c → scalar_mult.c, const_vector_mult.c → vector_mult.c

▎ Test plan

▎ - All 196 existing tests pass (API updated to new signatures)
▎ - 4 new parameter problem-level tests: scalar_mult, vector_mult, left_matmul, right_matmul — each verifies correct evaluation after parameter update
▎ - clang-format clean

Constants and updatable parameters are now represented by a single
parameter_expr node. Constants use param_id == PARAM_FIXED (-1),
while updatable parameters use param_id >= 0. Bivariate ops
(left_matmul, right_matmul, scalar_mult, vector_mult) accept an
optional param_source node and refresh their internal data on
forward/jacobian/hessian evaluation. Adds problem_register_params
and problem_update_params for problem-level parameter management.
Also adds update_values to the Matrix interface for parameter refresh.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Transurgeon Transurgeon changed the title Unify constants and parameters into single parameter_expr type [WIP] Unify constants and parameters into single parameter_expr type Mar 26, 2026
Transurgeon and others added 3 commits March 26, 2026 23:33
- Remove redundant refresh_param_values calls from eval_jacobian and
  eval_wsum_hess in left_matmul (forward always runs first)
- Use memcpy in problem_register_params for pointer array copy
- Add PARAM_FIXED guard in problem_update_params to skip fixed constants
- Remove unused right_matmul_expr struct from subexpr.h
- Add test_param_fixed_skip_in_update covering mixed fixed/updatable params
- Add CLAUDE.md for Claude Code guidance

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Resolves conflicts from main's workspace refactor (iwork/dwork -> work->),
elementwise atom split (elementwise_univariate -> full_dom/restricted_dom),
chain rule refactor, vstack addition, and numerical diff checker.

Removed stale test_jacobian_composite_log tests (incompatible with main's
chain rule refactor; covered by test_chain_rule_jacobian and numerical diff).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Transurgeon
Copy link
Copy Markdown
Collaborator Author

Transurgeon commented Mar 27, 2026

@dance858 I synced the PR with master, then addressed your comments. Please have another look.
Also I will work on python side tests tomorrow.. then we can start thinking about merging this.

@dance858
Copy link
Copy Markdown
Collaborator

@dance858 I synced the PR with master, then addressed your comments. Please have another look. Also I will work on python side tests tomorrow.. then we can start thinking about merging this.

Thanks for looking into the comments. Let me know when you have added tests on the python side and we'll merge this nice PR.

Also, sorry for the refactoring which forces you to sync this PR... But in the long run the refactoring is good.

Transurgeon and others added 4 commits March 27, 2026 11:00
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Resolves conflicts from folder structure refactor (#63) and more tests (#62).
Moves scalar_mult/vector_mult to src/affine/ and test files to new
subdirectory structure. Updates affine.h declarations with parameter support
signatures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Resolve merge conflicts in parameter.c and scalar_mult.c: keep
parameter-support-v2 features (parameter_expr, param_id, free_type_data)
while adopting _impl suffix naming from main. Fix old 2-arg
new_left_matmul calls in test_chain_rule_jacobian.h to use new 3-arg
signature with NULL param_node.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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