Skip to content

Let every layer take its initializers - #78

Merged
jessegrabowski merged 6 commits into
pymc-devs:mainfrom
jessegrabowski:layer-initialization
Aug 10, 2026
Merged

Let every layer take its initializers#78
jessegrabowski merged 6 commits into
pymc-devs:mainfrom
jessegrabowski:layer-initialization

Conversation

@jessegrabowski

Copy link
Copy Markdown
Member

No layer accepted an initializer, so changing how a parameter was drawn meant poking param.initializer between construction and Model.initialize() — undocumented, and silently reverted if you did it the other way round. Every leaf layer now takes one per parameter it owns, keyword-only, setting the declaration mechanism from #70 rather than adding a second source of truth. Omitting a keyword changes nothing: Linear's bias still starts at zeros and the norms at the identity transform.

A NormalInitializer comes with it, which the registry was missing. Composed layers are untouched on purpose; threading a keyword through Attention and TransformerBlock for per-layer scaled init is next.

Passes as written: it pins the behavior gh pymc-devs#70 established so the initializer keywords landing next cannot quietly strip a declaration, which is the one way they break something.
Its two arguments both default, which is what lets it into a registry whose entries are built with no arguments; a differently parameterized initializer can only be passed as an instance.
@codecov-commenter

codecov-commenter commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.46%. Comparing base (37b643c) to head (e281091).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #78      +/-   ##
==========================================
+ Coverage   95.43%   95.46%   +0.02%     
==========================================
  Files          45       45              
  Lines        1798     1809      +11     
==========================================
+ Hits         1716     1727      +11     
  Misses         82       82              

☔ 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 added enhancement New feature or request layer New or improvement to existing LayerOp labels Aug 10, 2026
@jessegrabowski
jessegrabowski merged commit f0b7651 into pymc-devs:main Aug 10, 2026
7 checks passed
@jessegrabowski
jessegrabowski deleted the layer-initialization branch August 11, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request layer New or improvement to existing LayerOp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants