Skip to content

Stress test parameter groups and fix from_valid bug in multi-group fill_params#84

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/stress-test-parameter-group-options
Draft

Stress test parameter groups and fix from_valid bug in multi-group fill_params#84
Copilot wants to merge 4 commits intomainfrom
copilot/stress-test-parameter-group-options

Conversation

Copy link

Copilot AI commented Mar 16, 2026

Adds comprehensive test coverage for parameter groups across all major caskade features, and fixes a bug discovered during testing.

Bug fix

fill_params called from_valid(params_g, param_list_g) without passing group=group, causing from_valid to re-enter its multi-group branch and attempt to iterate a single group's tensor as a list of group tensors. This produces an IndexError when using ValidContext with multi-group parameters.

# This would crash before the fix
m = BoundedSim()  # module with valid bounds
m.to_dynamic(False)
m.b.group = 1

with ValidContext(m):
    params = m.get_values()
    m.run(5.0, params)  # IndexError: too many indices for tensor of dimension 0

Fix in module.py:173: pass group=group to self.from_valid().

Test coverage (65 tests)

  • Hierarchical models — groups at top-level, within sub-modules, mixed across levels, 3-level deep nesting
  • Batch dimensions — independent batch dims per group, different batch sizes across groups, multi-dimensional batch shapes
  • get/set values — all three schemes (array, list, dict), specific group retrieval, round-trip consistency
  • find_param / find_index — group-aware lookups, error cases
  • ValidContext + to_valid/from_valid — multi-group transforms, round-trips, per-group argument
  • @forward + fill_params — multi-group param passing (positional and kwarg), single vs multi-group result consistency
  • ActiveContext, active_cache, OverrideParam — state management, caching, value overrides with groups
  • Collections — NodeList, NodeTuple with grouped params
  • Pointer params — shared params across modules with groups
  • Dynamic/static transitions — group preservation across state changes, empty group removal
  • Edge cases — 10+ groups, non-contiguous group IDs, reassignment collapse, None-value params
Original prompt

This section details on the original issue you should resolve

<issue_title>Stress test parameter group options</issue_title>
<issue_description>We need to write a more complete unit test suite for parameter groups under a number of edge cases. For example, we should test parameter groups in hierarchical models (both at the top level and within the hierarchy). It would also be good to test groups with varying batch dimensions, the batch dims of two separate groups should be independent. Parameter groups should be tested against basically all other features of caskade to make sure everything runs smoothly.</issue_description>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI and others added 3 commits March 16, 2026 15:02
Co-authored-by: ConnorStoneAstro <78555321+ConnorStoneAstro@users.noreply.github.com>
… in fill_params

Add 65 tests covering parameter groups across:
- Basic group creation and graph tracking
- Hierarchical models (top-level and within hierarchy)
- get_values/set_values with all schemes (array, list, dict)
- Varying batch dimensions (independent per group)
- find_param/find_index
- to_valid/from_valid and ValidContext
- @forward decorator and fill_params
- ActiveContext
- active_cache
- NodeList/NodeTuple collections
- Pointer params
- Dynamic/static transitions
- OverrideParam
- Edge cases (many groups, non-contiguous, reassignment)

Fix bug in fill_params where from_valid was called without group=
parameter, causing IndexError when using ValidContext with multi-group
parameters.

Co-authored-by: ConnorStoneAstro <78555321+ConnorStoneAstro@users.noreply.github.com>
Co-authored-by: ConnorStoneAstro <78555321+ConnorStoneAstro@users.noreply.github.com>
Copilot AI changed the title [WIP] Add stress test parameter group options Stress test parameter groups and fix from_valid bug in multi-group fill_params Mar 16, 2026
Copilot AI requested a review from ConnorStoneAstro March 16, 2026 15:19
@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (bd7e02b) to head (8a495ed).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #84   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines         1612      1612           
=========================================
  Hits          1612      1612           
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Stress test parameter group options

2 participants