Skip to content

Conversation

@mayank31398
Copy link
Collaborator

@mayank31398 mayank31398 commented Feb 9, 2026

Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @mayank31398, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the implementation of decay gate mechanisms within the Mamba2 and GatedDeltaNet models. By extracting the decay gate logic into a dedicated SoftplusDecayGate class, it enhances modularity, simplifies parameter management, and ensures consistent initialization of decay-related parameters across different sequence mixer architectures. This change streamlines the codebase and improves maintainability for these complex model components.

Highlights

  • Refactoring Decay Gate Logic: Introduced a new SoftplusDecayGate class to encapsulate the A_log and dt_bias parameters and their initialization logic, centralizing decay gate functionality.
  • Configuration Inheritance: Created a new base class _SoftPlusDecayArgs in sequence_mixer.py for decay gate parameters, which _Mamba2Args and _GatedDeltaNetArgs now inherit from, promoting code reuse and consistency.
  • Module Integration: Integrated the SoftplusDecayGate module into both Mamba2 and GatedDeltaNet sequence mixer blocks, replacing direct parameter definitions and their reset_parameters methods.
  • Parameter Path Updates: Adjusted the parameter paths in model conversion utilities (granitemoehybrid.py) and parameter grouping configurations (mup.json, normal.json) to reflect the new decay_gate nesting.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • lm_engine/hf_models/config/sequence_mixer.py
    • Removed the original _Mamba2Args class definition.
    • Added a new _SoftPlusDecayArgs class to define common decay gate initialization parameters.
    • Modified _GatedDeltaNetArgs to inherit from _SoftPlusDecayArgs.
    • Re-defined _Mamba2Args to inherit from _SoftPlusDecayArgs.
  • lm_engine/hf_models/model_conversion/granitemoehybrid.py
    • Updated the state dictionary import and export logic to correctly map dt_bias and A_log parameters under the new decay_gate module path.
  • lm_engine/hf_models/modeling_utils/decay_gate.py
    • Added a new file defining the SoftplusDecayGate class, which encapsulates A_log and dt_bias as nn.Parameters, handles their initialization, and provides a forward method for decay calculation.
  • lm_engine/hf_models/modeling_utils/sequence_mixer_blocks/init.py
    • Modified the get_sequence_mixer function to pass decay gate initialization parameters (A_init_min, A_init_max, dt_init_min, dt_init_max, dt_init_floor) to the Mamba2 and GatedDeltaNet constructors.
  • lm_engine/hf_models/modeling_utils/sequence_mixer_blocks/gated_deltanet.py
    • Imported the new SoftplusDecayGate class.
    • Updated the __init__ method to accept decay gate initialization parameters.
    • Replaced direct A_log and dt_bias nn.Parameters with an instance of SoftplusDecayGate.
    • Modified the forward method to use self.decay_gate for decay calculations.
    • Removed the redundant reset_parameters method, as initialization is now handled by SoftplusDecayGate.
  • lm_engine/hf_models/modeling_utils/sequence_mixer_blocks/mamba2.py
    • Imported the new SoftplusDecayGate class.
    • Updated the __init__ method to accept decay gate initialization parameters.
    • Replaced direct A_log and dt_bias nn.Parameters with an instance of SoftplusDecayGate.
    • Updated _torch_forward and _cuda_forward methods to access A_log and dt_bias via self.decay_gate.
    • Modified normalization in _cuda_forward to apply silu activation before the main normalization step.
    • Removed the redundant reset_parameters method.
  • tests/training/params_group/groups/mup.json
    • Updated parameter names for dt_bias and A_log to reflect their new nesting under decay_gate.
  • tests/training/params_group/groups/normal.json
    • Updated parameter names for dt_bias and A_log to reflect their new nesting under decay_gate.
Activity
  • The pull request was initiated by mayank31398 to address initialization and modularity concerns for decay gate logic in Mamba2 and GatedDeltaNet models.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the decay gate logic for Mamba2 and GatedDeltaNet into a new, reusable SoftplusDecayGate class. This centralizes the parameter initialization and improves code modularity. The changes also include updates to model configuration, conversion scripts, and tests to accommodate this new structure. I've found a couple of critical issues related to incorrect attribute and argument names that would cause runtime errors, and a minor suggestion to improve numerical stability.

Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
@mayank31398 mayank31398 merged commit 02e4e9a into main Feb 9, 2026
2 checks passed
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.

1 participant