Skip to content

Fix missing groups in EfficientNet MBConv depthwise convolution - #1042

Open
Amitesh-Sinha5 wants to merge 1 commit into
mlcommons:masterfrom
Amitesh-Sinha5:fix-efficientnet-mbconv6-groups-1041
Open

Fix missing groups in EfficientNet MBConv depthwise convolution#1042
Amitesh-Sinha5 wants to merge 1 commit into
mlcommons:masterfrom
Amitesh-Sinha5:fix-efficientnet-mbconv6-groups-1041

Conversation

@Amitesh-Sinha5

@Amitesh-Sinha5 Amitesh-Sinha5 commented Jul 22, 2026

Copy link
Copy Markdown

Fixes #1041

Proposed Changes

  • Add the missing groups=6 * num_in_feats argument to _MBConv6.depthconv1 in GANDLF/models/efficientnet.py, so it is a depthwise convolution as an MBConv block requires (it was silently running as a dense conv with groups=1). _MBConv1 already sets groups correctly; this brings _MBConv6 in line, matching the reference EfficientNet (Tan & Le, 2019).
  • Add a regression test (testing/test_mbconv6_is_depthwise.py) asserting _MBConv6.depthconv1 is depthwise and that a block stays within a sane parameter budget.

Why it matters

Because the depthwise conv is the defining op of an MBConv block, making it dense inflates the whole network:

EfficientNet-B0 Params GFLOPs
Before (bug) ~164.96 M ~18.26
After (fixed) ~7.15 M ~0.49
Reference B0 ~5.3 M ~0.39

So efficientnetb0 was ~23× larger than a real EfficientNet-B0 — heavier than the densenet121 baseline it is meant to be a lighter alternative to. This affects every efficientnetb* architecture.

Block-level repro (no training needed):

import torch.nn as nn
from GANDLF.models.efficientnet import _MBConv6
b = _MBConv6(num_in_feats=80, num_out_feats=112, kernel_size=5, stride=1,
             output_size=[14, 14], Norm=nn.BatchNorm2d, Conv=nn.Conv2d,
             Pool=nn.AdaptiveAvgPool2d, reduction=4)
print(b.depthconv1.groups)  # before: 1 (dense) ; after: 480 (depthwise)

Checklist

  • CONTRIBUTING guide has been followed.
  • PR is based on the current GaNDLF master.
  • Non-breaking change (does not break existing functionality). Note: the corrected _MBConv6 has different weight shapes, so any checkpoint saved from the buggy efficientnetb* will not load into the fixed model — those weights corresponded to an unintended dense conv and would need retraining.
  • Function/class source code documentation added/updated. N/A — one-line fix, no API/signature change.
  • Code has been blacked for style consistency and linting.
  • If applicable, version information has been updated in GANDLF/version.py. N/A — bugfix, no version bump.
  • If adding a git submodule, add to list of exceptions for black styling in pyproject.toml. N/A.
  • Usage documentation has been updated, if appropriate. N/A.
  • Tests added or modified to cover the changes.
  • If customized dependency installation is required, reflect it in the CI files. N/A — no new dependencies.
  • The logging library is being used and no print statements are left.

@Amitesh-Sinha5
Amitesh-Sinha5 requested a review from a team as a code owner July 22, 2026 13:54
@github-actions

Copy link
Copy Markdown
Contributor

MLCommons CLA bot:
Thank you very much for your submission; we really appreciate it. Before we can accept your contribution,
we ask that you sign the MLCommons CLA (Apache 2). Please submit your GitHub ID to our onboarding form to initiate
authorization. If you are from a MLCommons member organization, we will request that you be added to the CLA.
If you are not from a member organization, we will email you a CLA to sign. For any questions, please contact
support@mlcommons.org.
0 out of 1 committers have signed the MLCommons CLA.
@Amitesh-Sinha5
You can retrigger this bot by commenting recheck in this Pull Request

@github-actions

This comment has been minimized.

@codacy-production

codacy-production Bot commented Jul 22, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 4 complexity · 0 duplication

Metric Results
Complexity 4
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@Amitesh-Sinha5 Amitesh-Sinha5 changed the title Fix EfficientNet _MBConv6 depthwise convolution (add missing groups) Fix missing groups in EfficientNet MBConv depthwise convolution Jul 22, 2026
@Amitesh-Sinha5
Amitesh-Sinha5 force-pushed the fix-efficientnet-mbconv6-groups-1041 branch 3 times, most recently from cbd3856 to f4cc6be Compare July 22, 2026 14:16
…ixes mlcommons#1041

Signed-off-by: Amitesh Sinha <amiteshsinha005@gmail.com>
@Amitesh-Sinha5
Amitesh-Sinha5 force-pushed the fix-efficientnet-mbconv6-groups-1041 branch from f4cc6be to a6525b9 Compare July 22, 2026 14:47
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.

EfficientNet _MBConv6 depthwise conv is missing groups=, making it a dense conv (~23× params)

1 participant