RWKV / rwkv.cpp

INT4/INT5/INT8 and FP16 inference on CPU for RWKV language model
MIT License
1.13k stars 82 forks source link

Can't build with ggml #127

Closed zzczzc20 closed 10 months ago

zzczzc20 commented 10 months ago

Hello the following errors occur when I try to build:

[  7%] Building C object CMakeFiles/ggml.dir/ggml/src/ggml.c.o
[  7%] Built target ggml
[ 15%] Building CXX object CMakeFiles/rwkv.dir/rwkv.cpp.o
/DCARD/repo/rwkv.cpp/rwkv.cpp: In function ‘bool rwkv_fread_string(FILE*, size_t, std::string&)’:
/DCARD/repo/rwkv.cpp/rwkv.cpp:151:18: warning: cast from type ‘const char*’ to type ‘void*’ casts away qualifiers [-Wcast-qual]
  151 |     return fread((void *) dest.data(), length, 1, file) == 1;
      |                  ^~~~~~~~~~~~~~~~~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp: At global scope:
/DCARD/repo/rwkv.cpp/rwkv.cpp:225:21: warning: ‘rwkv_type_to_string’ initialized and declared ‘extern’
  225 | extern const char * rwkv_type_to_string[TYPE_COUNT + 1] = {"FP32", "FP16", "Q4_0", "Q4_1", "Q4_1_O", "Q4_2", "Q4_3", "Q5_0", "Q5_1", "Q8_0", "unknown"};
      |                     ^~~~~~~~~~~~~~~~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp:293:5: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
  293 |     const size_t size() const;
      |     ^~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp:492:12: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
  492 |     static const size_t align(const size_t size) {
      |            ^~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp:530:12: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
  530 |     static const size_t size(const enum ggml_type type, const uint64_t width, const uint64_t height) {
      |            ^~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp: In member function ‘rwkv_future_tensor rwkv_future_tensor::layer_norm(rwkv_future_ctx&, const rwkv_future_tensor&, const rwkv_future_tensor&) const’:
/DCARD/repo/rwkv.cpp/rwkv.cpp:565:106: warning: unused parameter ‘weight’ [-Wunused-parameter]
  565 |     struct rwkv_future_tensor layer_norm(struct rwkv_future_ctx & ctx, const struct rwkv_future_tensor & weight, const struct rwkv_future_tensor & bias) const {
      |                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp:565:148: warning: unused parameter ‘bias’ [-Wunused-parameter]
  565 | rwkv_future_tensor layer_norm(struct rwkv_future_ctx & ctx, const struct rwkv_future_tensor & weight, const struct rwkv_future_tensor & bias) const {
      |                                                                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~

/DCARD/repo/rwkv.cpp/rwkv.cpp: In member function ‘rwkv_future_tensor rwkv_future_tensor::set_inplace(rwkv_future_ctx&, rwkv_future_tensor)’:
/DCARD/repo/rwkv.cpp/rwkv.cpp:573:105: warning: unused parameter ‘src’ [-Wunused-parameter]
  573 |     struct rwkv_future_tensor set_inplace(struct rwkv_future_ctx & ctx, const struct rwkv_future_tensor src) {
      |                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/DCARD/repo/rwkv.cpp/rwkv.cpp: In member function ‘rwkv_future_tensor rwkv_future_tensor::consume(rwkv_future_ctx&, const rwkv_future_tensor&)’:
/DCARD/repo/rwkv.cpp/rwkv.cpp:579:103: warning: unused parameter ‘other’ [-Wunused-parameter]
  579 |     struct rwkv_future_tensor consume(struct rwkv_future_ctx & ctx, const struct rwkv_future_tensor & other) {
      |                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp: In member function ‘rwkv_future_tensor rwkv_future_tensor::combine(rwkv_future_ctx&, const rwkv_future_tensor&) const’:
/DCARD/repo/rwkv.cpp/rwkv.cpp:583:103: warning: unused parameter ‘other’ [-Wunused-parameter]
  583 |     struct rwkv_future_tensor combine(struct rwkv_future_ctx & ctx, const struct rwkv_future_tensor & other) const {
      |                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp: At global scope:
/DCARD/repo/rwkv.cpp/rwkv.cpp:602:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
  602 | const size_t rwkv_tensor_header::size() const {
      | ^~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp: In function ‘rwkv_future_tensor rwkv_future_sequence_graph(rwkv_future_ctx&, rwkv_future_tensor, size_t, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, size_t, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor&, rwkv_future_tensor&, rwkv_future_tensor&, rwkv_future_tensor&, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor&, rwkv_future_tensor, rwkv_future_tensor, rwkv_future_tensor)’:
/DCARD/repo/rwkv.cpp/rwkv.cpp:1229:39: warning: variable ‘kt’ set but not used [-Wunused-but-set-variable]
 1229 |             struct rwkv_future_tensor kt = k.subview(ctx, emb.width);
      |                                       ^~
/DCARD/repo/rwkv.cpp/rwkv.cpp:1230:39: warning: variable ‘vt’ set but not used [-Wunused-but-set-variable]
 1230 |             struct rwkv_future_tensor vt = v.subview(ctx, emb.width);
      |                                       ^~
/DCARD/repo/rwkv.cpp/rwkv.cpp:1231:39: warning: variable ‘xt’ set but not used [-Wunused-but-set-variable]
 1231 |             struct rwkv_future_tensor xt = x_prev.subview(ctx, emb.width);
      |                                       ^~
/DCARD/repo/rwkv.cpp/rwkv.cpp: In function ‘rwkv_context* rwkv_new_context_impl(std::shared_ptr<rwkv_instance>, uint32_t)’:
/DCARD/repo/rwkv.cpp/rwkv.cpp:1504:26: error: ‘struct ggml_cgraph’ has no member named ‘n_threads’
 1504 |     serial_graph.cgraph->n_threads = n_threads;
      |                          ^~~~~~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp: In function ‘bool rwkv_gpu_offload_layers(rwkv_context*, uint32_t)’:
/DCARD/repo/rwkv.cpp/rwkv.cpp:1548:52: warning: unused parameter ‘ctx’ [-Wunused-parameter]
 1548 | bool rwkv_gpu_offload_layers(struct rwkv_context * ctx, const uint32_t n_layers) {
      |                              ~~~~~~~~~~~~~~~~~~~~~~^~~
/DCARD/repo/rwkv.cpp/rwkv.cpp:1548:72: warning: unused parameter ‘n_layers’ [-Wunused-parameter]
 1548 | bool rwkv_gpu_offload_layers(struct rwkv_context * ctx, const uint32_t n_layers) {
      |                                                         ~~~~~~~~~~~~~~~^~~~~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp: In function ‘bool rwkv_eval(rwkv_context*, uint32_t, const float*, float*, float*)’:
/DCARD/repo/rwkv.cpp/rwkv.cpp:1620:46: error: cannot convert ‘ggml_context*’ to ‘ggml_cgraph*’
 1620 |     ggml_graph_compute(ctx->serial_graph.ctx.ctx, ctx->serial_graph.cgraph.get());
      |                        ~~~~~~~~~~~~~~~~~~~~~~^~~
      |                                              |
      |                                              ggml_context*
In file included from /DCARD/repo/rwkv.cpp/rwkv.cpp:2:
/DCARD/repo/rwkv.cpp/ggml/include/ggml/ggml.h:1342:72: note:   initializing argument 1 of ‘int ggml_graph_compute(ggml_cgraph*, ggml_cplan*)’
 1342 |     GGML_API               int ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cplan * cplan);
      |                                                   ~~~~~~~~~~~~~~~~~~~~~^~~~~~
In file included from /DCARD/repo/rwkv.cpp/rwkv.cpp:2:
/DCARD/repo/rwkv.cpp/ggml/include/ggml/ggml.h:262:12: note: class type ‘ggml_context’ is incomplete
  262 |     struct ggml_context;
      |            ^~~~~~~~~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp: In function ‘bool rwkv_eval_sequence(rwkv_context*, const uint32_t*, size_t, const float*, float*, float*)’:
/DCARD/repo/rwkv.cpp/rwkv.cpp:1682:32: error: ‘struct ggml_cgraph’ has no member named ‘n_threads’
 1682 |         sequence_graph.cgraph->n_threads = 1;
      |                                ^~~~~~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp:1709:52: error: cannot convert ‘ggml_context*’ to ‘ggml_cgraph*’
 1709 |         ggml_graph_compute(ctx->sequence_graph.ctx.ctx, ctx->sequence_graph.cgraph.get());
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~^~~
      |                                                    |
      |                                                    ggml_context*
In file included from /DCARD/repo/rwkv.cpp/rwkv.cpp:2:
/DCARD/repo/rwkv.cpp/ggml/include/ggml/ggml.h:1342:72: note:   initializing argument 1 of ‘int ggml_graph_compute(ggml_cgraph*, ggml_cplan*)’
 1342 |     GGML_API               int ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cplan * cplan);
      |                                                   ~~~~~~~~~~~~~~~~~~~~~^~~~~~
In file included from /DCARD/repo/rwkv.cpp/rwkv.cpp:2:
/DCARD/repo/rwkv.cpp/ggml/include/ggml/ggml.h:262:12: note: class type ‘ggml_context’ is incomplete
  262 |     struct ggml_context;
      |            ^~~~~~~~~~~~
/DCARD/repo/rwkv.cpp/rwkv.cpp:1631:18: warning: unused variable ‘n_embed’ [-Wunused-variable]
 1631 |     const size_t n_embed = header.n_embed;
      |                  ^~~~~~~
gmake[2]: *** [CMakeFiles/rwkv.dir/build.make:76:CMakeFiles/rwkv.dir/rwkv.cpp.o] ERROR 1
gmake[1]: *** [CMakeFiles/Makefile2:152:CMakeFiles/rwkv.dir/all] ERROR 2
gmake: *** [Makefile:101:all] ERROR 2
saharNooby commented 10 months ago

Hi! How exactly did you obtain ggml source code?

zzczzc20 commented 10 months ago

Hi! I clone ggml from their repo

saharNooby commented 10 months ago

rwkv.cpp uses a specific commit of ggml to ensure best compatibility. You need to recursively clone this repo, so that git automatically clones the correct version of ggml. See this section of README for instructions.