Skip to content

fix(config): add fnmatch glob support for ConditionalParameter filter#689

Open
jaytoone wants to merge 1 commit into
arcee-ai:mainfrom
jaytoone:fix/filter-substring-fnmatch
Open

fix(config): add fnmatch glob support for ConditionalParameter filter#689
jaytoone wants to merge 1 commit into
arcee-ai:mainfrom
jaytoone:fix/filter-substring-fnmatch

Conversation

@jaytoone

@jaytoone jaytoone commented May 31, 2026

Copy link
Copy Markdown

Problem

ConditionalParameter.filter uses a plain substring check, which causes silent mismatches in hybrid-attention models (e.g. FLA / linear-attention architectures).

A filter of "attn" substring-matches both self_attn and linear_attn weights, causing unintended blending of SSM state tensors (A_log, dt_bias, etc.) that must remain intact during merging.

Solution

Add glob metacharacter detection (*, ?, [) in _filter_matches(). When the filter string contains any of these characters, use fnmatch.fnmatch instead of the substring check. Plain strings retain the original substring behaviour for backward compatibility.

# Before: "attn" matches BOTH self_attn AND linear_attn
filter: "attn"   # unintentionally blends SSM parameters

# After: precise control with glob
filter: "*self_attn*"   # matches self_attn only, skips linear_attn

Changes

  • mergekit/config.py: add fnmatch import, _GLOB_CHARS frozenset, and _filter_matches() helper; update evaluate_setting() to use it
  • tests/test_config_filter.py: 13 new tests covering plain substring (backward compat), glob patterns, and the linear_attn collision case

Tests

pytest tests/test_config_filter.py -v
# 13 passed

Motivation

Discovered while merging FLA-based models (e.g. Jackrong-27B) with standard-attention bases using DARE-TIES. The substring collision corrupted linear-attention SSM parameters, silently degrading model quality. This fix allows users to opt into precise control by writing "*self_attn*" while preserving existing configs that use plain substrings.


Note

Medium Risk
Changes which tensors match conditional merge parameters; glob patterns alter behavior vs old substring-only configs, though plain filters are unchanged.

Overview
ConditionalParameter filter matching in merge YAML now supports optional glob patterns (*, ?, [) via a new _filter_matches() helper, while plain strings still use substring matching for backward compatibility.

When a filter contains glob metacharacters, evaluate_setting() uses fnmatch (with *{pattern}* wrapping) so patterns like *self_attn* can target standard attention weights without also matching linear_attn tensors—avoiding unintended blending of SSM state (e.g. A_log, dt_bias) on hybrid / linear-attention models.

Adds tests/test_config_filter.py with unit and integration coverage for substring compat, glob behavior, and the attn vs linear_attn collision case.

Reviewed by Cursor Bugbot for commit 2ada4e6. Bugbot is set up for automated code reviews on this repo. Configure here.

The filter field in ConditionalParameter previously used plain substring
matching. This causes issues on FLA/hybrid-attention models where 'attn'
matches both self_attn and linear_attn tensors (A_log, dt_bias, etc.)
which are SSM state tensors that must not be donor-blended.

Add fnmatch glob support: when filter contains * ? [ metacharacters,
use fnmatch.fnmatch instead of substring match. Backward compatible.

Users should write filter: '*self_attn*' instead of filter: 'attn' on
FLA-hybrid models to avoid the cross-match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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