Skip to content

UPSTREAM PR #18526: model: fix SWA per-layer freq_base#776

Open
loci-dev wants to merge 1 commit into
mainfrom
upstream-PR18526-branch_ngxson-xsn/fix_swa_freq
Open

UPSTREAM PR #18526: model: fix SWA per-layer freq_base#776
loci-dev wants to merge 1 commit into
mainfrom
upstream-PR18526-branch_ngxson-xsn/fix_swa_freq

Conversation

@loci-dev

@loci-dev loci-dev commented Jan 1, 2026

Copy link
Copy Markdown

Mirrored from ggml-org/llama.cpp#18526

I think the if constexpr (iswa) can be wrong here, so pushing this PR for discussion.

At least for gemma3, SWA layers are expected to use different freq_base than full attention layer. Using if constexpr (iswa) will make it a fixed value cross all layers.

Here is the original code of gemma3 (PR ggml-org/llama.cpp#12343) for reference:

        for (int il = 0; il < n_layer; ++il) {
            const bool is_sliding          = (il + 1) % sliding_window_pattern;
            const float freq_base_l        = is_sliding ? 10000.0f    : freq_base;
            const float freq_scale_l       = is_sliding ? 1.0f        : freq_scale;
            struct ggml_tensor * KQ_mask_l = is_sliding ? KQ_mask_swa : KQ_mask;

@loci-review

loci-review Bot commented Jan 1, 2026

Copy link
Copy Markdown

Explore the complete analysis inside the Version Insights

Perfect! I've retrieved the summary report for your project. Here are the key findings:

Summary Report for llama.cpp PR #776

Project Information:

Key Results:
No Significant Performance Regressions Detected

The analysis compared the base version against the target version and found:

  • No modified functions showed performance changes greater than 2%
  • Both Response Time and Throughput Time metrics remained stable
  • All performance variations are within the acceptable ±2% threshold

Conclusion:
This pull request maintains stable performance characteristics and does not introduce any concerning performance degradations. The changes are safe to proceed from a performance perspective.

@loci-dev loci-dev force-pushed the main branch 27 times, most recently from 118039a to cd122e2 Compare January 6, 2026 07:13
@loci-dev loci-dev force-pushed the main branch 30 times, most recently from 953f210 to 8b542ba Compare January 12, 2026 12:16
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.

2 participants