Skip to content

Propagate norm and activation config to chess features#99

Merged
lukifer23 merged 1 commit intomasterfrom
codex/extend-chessspecificfeatures-with-norm/activation-options
Oct 6, 2025
Merged

Propagate norm and activation config to chess features#99
lukifer23 merged 1 commit intomasterfrom
codex/extend-chessspecificfeatures-with-norm/activation-options

Conversation

@lukifer23
Copy link
Owner

Summary

  • allow ChessSpecificFeatures to accept norm and activation settings from the model config
  • update PolicyValueNet to forward the configured norm/activation to chess-specific layers
  • add regression coverage asserting the chess feature extractor honors the chosen norm/activation while preserving output shapes

Testing

  • pytest tests/test_attention.py tests/test_chess_features.py

https://chatgpt.com/codex/tasks/task_e_68e4127a93c08323906d16112e5e70f5

Copilot AI review requested due to automatic review settings October 6, 2025 19:07
@lukifer23 lukifer23 merged commit 5520093 into master Oct 6, 2025
1 of 2 checks passed
@lukifer23 lukifer23 deleted the codex/extend-chessspecificfeatures-with-norm/activation-options branch October 6, 2025 19:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Enhances the ChessSpecificFeatures module to respect model-wide normalization and activation configurations by propagating these settings from the main model config through the PolicyValueNet constructor.

  • Adds norm and activation parameters to ChessSpecificFeatures constructor with appropriate defaults
  • Updates PolicyValueNet to forward configured norm/activation settings to chess-specific layers
  • Adds comprehensive test coverage verifying the chess feature extractor honors the chosen settings while preserving output shapes

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
azchess/model/resnet.py Updated ChessSpecificFeatures constructor to accept norm/activation parameters and modified PolicyValueNet to pass these from config
tests/test_chess_features.py Added parametrized test verifying chess features respect norm and activation config settings

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

self.piece_square_tables = piece_square_tables


activation_cls = nn.SiLU if activation == "silu" else nn.ReLU
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

The activation selection logic only handles 'silu' and defaults to ReLU for all other values. Consider adding explicit validation or support for other common activations to make the behavior more predictable.

Suggested change
activation_cls = nn.SiLU if activation == "silu" else nn.ReLU
activation_map = {
"relu": nn.ReLU,
"silu": nn.SiLU,
"gelu": nn.GELU,
"tanh": nn.Tanh,
"leaky_relu": nn.LeakyReLU,
"elu": nn.ELU,
}
if activation.lower() not in activation_map:
raise ValueError(
f"Unsupported activation '{activation}'. Supported activations are: {list(activation_map.keys())}"
)
activation_cls = activation_map[activation.lower()]

Copilot uses AI. Check for mistakes.
self.pst_conv = nn.Conv2d(channels, channels, kernel_size=1, bias=False)
self.pst_norm = _norm(channels)

self.pst_norm = _norm(channels, norm)
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

The _norm function is called without validating the norm parameter first. Consider adding validation in the constructor to fail fast if an unsupported norm type is provided, rather than letting the error bubble up from _norm.

Copilot uses AI. Check for mistakes.
self.interaction_conv = nn.Conv2d(channels, channels, kernel_size=3, padding=1, bias=False)
self.interaction_norm = _norm(channels)

self.interaction_norm = _norm(channels, norm)
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

The _norm function is called without validating the norm parameter first. Consider adding validation in the constructor to fail fast if an unsupported norm type is provided, rather than letting the error bubble up from _norm.

Copilot uses AI. Check for mistakes.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

self.pst_norm = _norm(channels)

self.pst_norm = _norm(channels, norm)
self.pst_activation = activation_cls(inplace=True)
Copy link

Choose a reason for hiding this comment

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

Bug: Conditional Attribute Initialization Causes API Inconsistency

The pst_activation attribute in ChessSpecificFeatures is only initialized when piece_square_tables is True. This conditional setup can cause an AttributeError if piece_square_tables is False and code attempts to access it, creating an inconsistent API compared to interaction_activation.

Fix in Cursor Fix in Web

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants