Validate feature_group_count in nnx.Conv constructor #5624
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.47) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 279 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.337
Real PR Conversation Timeline
1 comments
"Review active on #5624"
general
weight: 0.35
samanklesaria
What does this PR do?
nnx.Convaccepts afeature_group_countthat does not dividein_features. It builds a kernel of the wrong shape and only fails on the first call, with a bareAssertionErrorthat has no message:This PR checks both conditions in
Conv.__init__, wherein_featuresandfeature_group_countare both known. It raisesValueErrorwith the offending values, for examplein_features (3) must be divisible by feature_group_count (2).It also removes the now-redundantassertinConv.__call__, and adds one sentence to thefeature_group_countdocstring. This follows the same pattern as #5505.I left
out_featuresdivisibility alone.lax.conv_general_dilatedalready raises a clearValueErrorfor it at call time, and checking it in__init__would also reject a customconv_general_dilatedthat handles it.Tests: a new
TestConvValidationclass intests/nnx/nn/conv_test.py. It has four invalid cases (3/2, 8/3, 0, -2) and one valid grouped case that checks the kernel shape and a forward pass. The four invalid cases fail onmainand pass with this change.tests/nnx/nn/conv_test.py,tests/nnx/nnandruff checkon both files were run on Windows with CPU jax 0.12.0.1; CI covers Linux.No linked issue. This is a small bug found while reading
flax/nnx/nn/linear.py.Checklist