diff --git a/ggml/src/ggml-spacemit/ime.cpp b/ggml/src/ggml-spacemit/ime.cpp index 493c989d4ccf..bb51f229f3bc 100644 --- a/ggml/src/ggml-spacemit/ime.cpp +++ b/ggml/src/ggml-spacemit/ime.cpp @@ -829,7 +829,14 @@ template class tensor_ bool pad8_all = false; if constexpr (std::is_same_v && INTER_SIZE == 256) { - pad8_all = ids->ne[1] > 1 && quantize_a_i8_r4 != nullptr && ne01 % 32 == 0 && hp_aligned(); + // Skip M8 tail padding for the validated K=2048, N=512 projection + // with broadcast activations and 2-4 tokens. Full M8 groups remain + // eligible. Wider projections retain their existing padding policy. + const bool small_token_batch = ids->ne[1] >= 2 && ids->ne[1] <= 4; + const bool narrow_broadcast_shape = ne00 == 2048 && ne01 == 512 && ne11 == 1; + const bool skip_m8_tail_padding = small_token_batch && narrow_broadcast_shape; + pad8_all = ids->ne[1] > 1 && quantize_a_i8_r4 != nullptr && ne01 % 32 == 0 && hp_aligned() && + !skip_m8_tail_padding; } if (!pad8_all && ne11 == 1) { @@ -1860,10 +1867,6 @@ class tensor_traits_f16 : public ggml::spacemit::tensor_traits_base { const int ith = ctx.ith; const int nth = ctx.nth; - if (ith == 0 && getenv("GGML_SPACEMIT_Q41_TRACE") != nullptr) { - fprintf(stderr, "q41_mul_mat: N=%zu M=%zu K=%zu (%s)\n", N, M, K, M == 1 ? "decode" : "prefill"); - } - const size_t out_row_stride = dst->nb[1]; // bytes constexpr size_t m_tile = F16_M_TILE;