Apple Silicon Metal + BLAS segfault for I2_S when ubatch >= 32 routes generic MUL_MAT
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
Línea de trabajo
Comienza en ggml-blas.cpp, en la comprobación genérica de compatibilidad con BLAS para MUL_MAT, y luego reproduce el problema con Metal y Apple BLAS usando valores de i2_s y ubatch de 31 y 32 o superiores. Confirma que la protección I2_S conserva la ruta especializada y que la configuración con un ubatch mayor ya no produce un segfault mientras BLAS permanece habilitado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Environment
- Platform: Apple Silicon Mac
- Host: Apple M4 Max
- OS: macOS
- Compiler: Homebrew clang 18.1.8
- BitNet / submodule state: BitNet using vendored
3rdparty/llama.cppat Eddie-Wang1120/llama.cpp commit1f86f058de0c3f4098dedae2ae8653c335c868a1 - Model:
microsoft/BitNet-b1.58-2B-4T-gguf/ggml-model-i2_s.gguf - Build flags:
GGML_METAL=ONGGML_ACCELERATE=ONGGML_BLAS=ONGGML_BLAS_VENDOR=AppleBITNET_ARM_TL1=OFF
Problem
On Apple Silicon with Metal enabled, i2_s inference can segfault when BLAS is enabled and the physical micro-batch crosses the BLAS routing threshold.
The crash is tied to physical ubatch, not logical batch:
-b 2048 -ub 31-> stable-b 32 -ub 31-> stable-b 2048 -ub 32-> segfault-b 2048 -ub 512-> segfault
This means the failure starts exactly when the BLAS backend begins claiming the generic MUL_MAT path for larger batches.
Control Experiment
The same Metal runtime is stable when BLAS is disabled:
- BLAS ON +
-b 2048 -ub 512-> segfault - BLAS OFF +
-b 2048 -ub 512-> stable
This strongly suggests the crash is in the BLAS-side handling of GGML_TYPE_I2_S, not in Metal itself and not in the outer chat request schema.
Root Cause
ggml-blas.cpp allows the generic BLAS MUL_MAT path to accept quantized source tensors when ggml_get_type_traits(src0->type)->to_float != NULL.
For GGML_TYPE_I2_S, that is not safe:
I2_Sstores an external scale outside the per-row payload- the generic BLAS dequantize-to-float path assumes self-contained per-row data
- once
ubatch >= 32, BLAS starts claimingMUL_MAT - that eventually crashes in the
i2_sdequant / BLAS matmul path
In crash reports, the top frames consistently land in:
dequantize_row_i2_sggml_backend_blas_mul_mat
Proposed Fix
Reject GGML_TYPE_I2_S in the generic BLAS MUL_MAT support check so that I2_S continues using its specialized non-BLAS path:
return src0->type != GGML_TYPE_I2_S &&
ggml_is_contiguous(src0) &&
ggml_is_contiguous(src1) &&
src1->type == GGML_TYPE_F32 &&
(ne0 >= min_batch && ne1 >= min_batch && ne10 >= min_batch) &&
(src0->type == GGML_TYPE_F32 || ggml_get_type_traits(src0->type)->to_float != NULL);
Result After Patch
After applying the BLAS guard above:
- BLAS ON + Metal +
-b 2048 -ub 512is stable - managed broker end-to-end requests no longer segfault under the same settings
This does not solve all i2_s quality issues, but it does remove the native crash path.
Related Issues
- #468
- #470
- #195
- #411
- Lenguaje dominante
- C++
- Estrellas
- 40.3k
- Forks
- 3.7k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/BitNet
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
-
i2_s SIGSEGVs at n_ubatch >= 32: BLAS backend dequantises by a row stride 4x the real packed row Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Todos los issues de microsoft/BitNet
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
AXERA-TECH/ax-llm#77 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
games-on-whales/wolf#509 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
bug-unconfirmed
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100