Skip to content

Comments

Refactor FalconMamba: replace class-name checks with generic attribute detection#424

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/refactor-falcon-mamba
Draft

Refactor FalconMamba: replace class-name checks with generic attribute detection#424
Copilot wants to merge 2 commits intomainfrom
copilot/refactor-falcon-mamba

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

The codebase had hard-coded config.__class__.__name__ == "FalconMambaConfig" checks in three places in text_generation.py, tightly coupling Mamba-model handling to a single model class.

Changes

  • Generic detection: Replace all config.__class__.__name__ == "FalconMambaConfig" guards with hasattr(config, "use_mambapy") — the attribute already cited in check_hasattr calls as the Mamba-model indicator, making the branches work for any Mamba-based config, not just FalconMambaConfig.
  • Rename: _get_input_falcon_mamba_get_input_mamba to reflect its model-agnostic role.
  • Comment: Updated inline comment to clarify the pattern.
# Before
if config.__class__.__name__ == "FalconMambaConfig":
    ...

# After
if hasattr(config, "use_mambapy"):
    ...

Affected functions: reduce_model_config, get_inputs, random_input_kwargs.

Original prompt

This section details on the original issue you should resolve

<issue_title>Refactor FalconMamba</issue_title>
<issue_description>There are significant amount of codes specifically written for the model tiiuae/falcon-mamba-tiny-dev

if config.__class__.__name__ == "FalconMambaConfig":
    pass

if config.__class__.__name__ == "FalconMambaConfig":

We should simplify/merge it to the main stream of code if possible.

cc @xadupre </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…config, 'use_mambapy')

Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor code for FalconMamba model Refactor FalconMamba: replace class-name checks with generic attribute detection Feb 23, 2026
Copilot AI requested a review from xadupre February 23, 2026 21:21
@xadupre
Copy link
Collaborator

xadupre commented Feb 23, 2026

unittest?

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.

Refactor FalconMamba

2 participants