Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some optimize and build warning fix for LoongArch #11709

Merged
merged 3 commits into from
Feb 7, 2025

Conversation

MQ-mengqing
Copy link
Contributor

  • ggml : optimize convert f32<->f16 for loongarch_asx
  • ggml : optimize loongarch_asx extend i16,i8,u8 to i32,i16
  • ggml : Fix warnings when run cpu CI locally on LoongArch

@github-actions github-actions bot added the ggml changes relating to the ggml tensor library for machine learning label Feb 6, 2025
@ggerganov
Copy link
Member

cc @junchao-loongson

@junchao-loongson
Copy link
Collaborator

perf record -e cache-misses ./build/bin/llama-cli -m ../qwen2-1_5b-instruct-q3_k_m.gguf -p "I believe the meaning of life is" -n 128

Before:
  26.02%  llama-cli  libggml-cpu.so                 [.] ggml_vec_dot_q3_K_q8_K
  21.30%  llama-cli  libggml-cpu.so                 [.] ggml_vec_dot_f16
  20.03%  llama-cli  libggml-cpu.so                 [.] ggml_vec_dot_q4_K_q8_K
  10.55%  llama-cli  libggml-cpu.so                 [.] ggml_vec_dot_q6_K_q8_K  

After:
  33.47%  llama-cli  libggml-cpu.so                 [.] ggml_vec_dot_q3_K_q8_K
  25.05%  llama-cli  libggml-cpu.so                 [.] ggml_vec_dot_q4_K_q8_K
  11.67%  llama-cli  libggml-cpu.so                 [.] ggml_vec_dot_q6_K_q8_K
   5.35%  llama-cli  libc.so.6                      [.] memcpy
   4.63%  llama-cli  libggml-cpu.so                 [.] ggml_compute_forward_mul_mat
   2.94%  llama-cli  llama-cli                      [.] common_sampler_sample(common_sampler*, llama_context*, int, bool)
   2.19%  llama-cli  libc.so.6                      [.] memset
   1.89%  llama-cli  libggml-cpu.so                 [.] ggml_vec_dot_f16

The ggml_vec_dot_f16 hotspot function is clearly mitigated

Before:
> $ ./build/bin/llama-bench -m ../qwen2-1_5b-instruct-q3_k_m.gguf                                                                                                                                                                                   [±master]
| model                          |       size |     params | backend    | threads |          test |                  t/s |
| ------------------------------ | ---------: | ---------: | ---------- | ------: | ------------: | -------------------: |
| qwen2 1.5B Q3_K - Medium       | 780.32 MiB |     1.54 B | CPU        |       8 |         pp512 |         21.40 ± 0.01 |
| qwen2 1.5B Q3_K - Medium       | 780.32 MiB |     1.54 B | CPU        |       8 |         tg128 |         20.91 ± 0.07 |

build: c3db0480 (4645)

After:
> $ ./build/bin/llama-bench -m ../qwen2-1_5b-instruct-q3_k_m.gguf                                                                                                                                                                                  [±pr11709]
| model                          |       size |     params | backend    | threads |          test |                  t/s |
| ------------------------------ | ---------: | ---------: | ---------- | ------: | ------------: | -------------------: |
| qwen2 1.5B Q3_K - Medium       | 780.32 MiB |     1.54 B | CPU        |       8 |         pp512 |         23.09 ± 0.07 |
| qwen2 1.5B Q3_K - Medium       | 780.32 MiB |     1.54 B | CPU        |       8 |         tg128 |         21.44 ± 0.09 |

build: 99bbe263 (4656)

Benchmark has a small improvement

LGTM!

@ggerganov ggerganov merged commit 225bbbf into ggml-org:master Feb 7, 2025
44 of 46 checks passed
tinglou pushed a commit to tinglou/llama.cpp that referenced this pull request Feb 13, 2025
* ggml : optimize convert f32<->f16 for loongarch_asx

* ggml : optimize loongarch_asx extend i16,i8,u8 to i32,i16

* ggml : Fix warnings when run cpu CI locally on LoongArch
orca-zhang pushed a commit to orca-zhang/llama.cpp that referenced this pull request Feb 26, 2025
* ggml : optimize convert f32<->f16 for loongarch_asx

* ggml : optimize loongarch_asx extend i16,i8,u8 to i32,i16

* ggml : Fix warnings when run cpu CI locally on LoongArch
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Feb 26, 2025
* ggml : optimize convert f32<->f16 for loongarch_asx

* ggml : optimize loongarch_asx extend i16,i8,u8 to i32,i16

* ggml : Fix warnings when run cpu CI locally on LoongArch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ggml changes relating to the ggml tensor library for machine learning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants