[compat] gdn compat mcore main#34
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a compatibility check in the GatedDeltaNet constructor to handle the cp_comm_type parameter based on the signature of the underlying _GatedDeltaNet class. A review comment suggests optimizing this implementation by moving the inspect.signature check to the module level to avoid redundant introspection calls for every layer instance during model initialization.
| if 'cp_comm_type' not in inspect.signature(_GatedDeltaNet).parameters: | ||
| kwargs.pop('cp_comm_type', None) |
There was a problem hiding this comment.
Calling inspect.signature inside the __init__ method is inefficient because it will be executed for every instance of GatedDeltaNet (e.g., for every layer in the model). It is recommended to perform this check once at the module level, right after _GatedDeltaNet is defined, and store the result in a boolean constant. This avoids redundant introspection during model initialization.
No description provided.