google / gemma.cpp

lightweight, standalone C++ inference engine for Google's Gemma models.
Apache License 2.0
5.9k stars 499 forks source link

Remove allocation from GEMM_4x4_Tile when decoding compressed weights by implementing #303

Closed copybara-service[bot] closed 1 month ago

copybara-service[bot] commented 1 month ago

Remove allocation from GEMM_4x4_Tile when decoding compressed weights by implementing SfpCodec::Dec2F and ComressTraits::Decompress2 for all supported types. It also allows to remove one of the specializations of GEMM_4x4_Tile, handling compressed MatB with one function. As before even when MatA is bf16 it is using 32-bit registers for computations.

Measurements for a 2b-it sfp-encoded model on a AMD Ryzen Threadripper PRO 3945WX 12-Cores: baseline:

32.6254 prefill tokens / sec
8.91429 tokens / sec
115 milliseconds time to first token

this change:

54.3045 prefill tokens / sec
16.8191 tokens / sec
56 milliseconds time to first token