model, mtmd: fix gemma4 vision handling (#28335)

* model, mtmd: fix gemma4 vision handling

* nits
This commit is contained in:
Xuan-Son Nguyen
2026-09-04 12:23:27 +02:00
committed by GitHub
parent 8f83678fd8
commit 163a40796f
7 changed files with 30 additions and 9 deletions
+8 -2
View File
@@ -1681,8 +1681,8 @@ static void set_input_kq_mask_impl(const args_set_input_kq_mask & args, T * data
// apply SWA if any
if (swa) {
// see llama_hparams::swa_full_non_causal
const bool in_span = !causal && args.hparams.swa_full_non_causal && p0 >= seq_pos_min[seq_id];
// see llama_non_causal_type
const bool in_span = !causal && args.hparams.non_causal_type == LLAMA_NON_CAUSAL_TYPE_SWA_FULL && p0 >= seq_pos_min[seq_id];
if (!in_span && llama_hparams::is_masked_swa(n_swa, swa_type, p0, p1)) {
goto skip;
}
@@ -1754,6 +1754,12 @@ void llama_kv_cache::set_input_kq_mask(ggml_tensor * dst, const llama_ubatch * u
// n_tps == n_tokens_per_stream
const int64_t n_tps = n_tokens/n_stream;
// see llama_non_causal_type
// only the SWA cache (or the SWA layers of a single cache) become non-causal
if (!causal_attn && hparams.non_causal_type == LLAMA_NON_CAUSAL_TYPE_SWA_ONLY) {
causal_attn = swa_type == LLAMA_SWA_TYPE_NONE;
}
//const int64_t t_start = ggml_time_us();
const args_set_input_kq_mask args = {