Skip to content

Compose a rule with trailing transforms, and scale by a schedule - #108

Merged
jessegrabowski merged 2 commits into
pymc-devs:mainfrom
jessegrabowski:compose-rule-with-transforms
Aug 25, 2026
Merged

Compose a rule with trailing transforms, and scale by a schedule#108
jessegrabowski merged 2 commits into
pymc-devs:mainfrom
jessegrabowski:compose-rule-with-transforms

Conversation

@jessegrabowski

Copy link
Copy Markdown
Member

chain already worked with a rule at the head — the body threads whatever it's handed into the first callable — but the signature said transforms only, and mypy rejected chain(adam(1e-3), clip_by_global_norm(1.0), scale(0.5)). That's overloads now. head stays unannotated: any type wide enough to accept both is a union, and a union return won't pass to compile_train, so that one head(...) call is unchecked.

scale_by_schedule schedules the rate after the rule instead of inside it. Those are different graphs once a clip sits between the two — the clip bounds a step at unit rate, so its bound stays in gradient units rather than moving with whatever the schedule currently holds. It owns its clock, and compile_train advances it.

Closes #81
Closes #82

The body already threaded its incoming argument straight into the head, so a rule-headed chain ran correctly all along; only the signature and the docstring said transforms only, and a type checker rejected the composition the issue asks for.

Closes pymc-devs#81
Scheduling the rate after the rule is a different graph from scheduling it inside, whenever a clip sits between the two: the clip then bounds a step at unit rate, so its bound stays in gradient units rather than moving with whatever rate the schedule currently holds.

Closes pymc-devs#82
@codecov-commenter

codecov-commenter commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.52%. Comparing base (497d21b) to head (bcd6e04).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #108   +/-   ##
=======================================
  Coverage   97.52%   97.52%           
=======================================
  Files          61       61           
  Lines        3069     3076    +7     
=======================================
+ Hits         2993     3000    +7     
  Misses         76       76           

☔ View full report in Codecov by Harness.
📢 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.

@jessegrabowski
jessegrabowski merged commit 85ebae4 into pymc-devs:main Aug 25, 2026
10 checks passed
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.

Nothing scales the assembled step by a schedule since scale_by_schedule went away No public way to compose a rule with trailing transforms

2 participants