Skip to content

implement group-norm - #790

Open
GHOpenonic wants to merge 1 commit into
mainfrom
group-norm
Open

implement group-norm#790
GHOpenonic wants to merge 1 commit into
mainfrom
group-norm

Conversation

@GHOpenonic

Copy link
Copy Markdown
Collaborator

implement group and layer normalization with tests. Change norm selection to use build_norm_layer that is more extensible than old if/elif logic.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba3f6ddeec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/samudra/config.py
BlockType = Literal["conv_next_block", "conv_block"]
ActivationType = Literal["relu", "gelu", "capped_gelu"]
NormType = Literal["batch", "instance", "layer"]
NormType = Literal["batch", "instance", "group", "nonorm", "layer"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not accept group/no-norm for ConvBlock until wired

When a config sets core_block.block_type: "conv_block" with the newly accepted norm: "group" or "nonorm", validation now succeeds, but the BlockConfig.build conv_block branch still constructs ConvBlock without passing self.norm, and ConvBlock hard-codes BatchNorm2d. That silently runs experiments with batch norm despite the YAML requesting group/no normalization, so either reject these values for conv_block or thread the norm setting through that block too.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my 🐑 suggestion above about the NormBuilder -- that idea could help address this concern.

@alxmrs alxmrs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few ideas that could improve this group norm PR.

self.checkpoint_simple = checkpoint_simple

@staticmethod
def _build_norm_layer(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this doesn't use any class members, therefore I think it could be a pure function not in the class rather than a method. Further, I think this could be generally useful -- how about we make it a public function?


@staticmethod
def _build_norm_layer(
norm: str, channels: int, group_norm_groups: int

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the parameter could just be groups?

🐑 maybe it could be an optional param since it's only used with group norm.

self.checkpoint_simple = checkpoint_simple

@staticmethod
def _build_norm_layer(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐑 idea: potentially, we could pass in to the core block a "NormBuilder" so we could set all of the hparams for which norm to use in our config system -- see the CoreBlockBuilder(Protocol) at the bottom of this file.

Comment thread src/samudra/config.py
BlockType = Literal["conv_next_block", "conv_block"]
ActivationType = Literal["relu", "gelu", "capped_gelu"]
NormType = Literal["batch", "instance", "layer"]
NormType = Literal["batch", "instance", "group", "nonorm", "layer"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my 🐑 suggestion above about the NormBuilder -- that idea could help address this concern.

Comment thread tests/test_blocks.py
width=st.integers(min_value=1, max_value=16),
)
@settings(max_examples=20)
@settings(max_examples=20, deadline=None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove this -- if there's a timeout in our property based tests, that's a concern worth knowing about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants