-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllama_rdma_server.cpp
11455 lines (9537 loc) · 433 KB
/
llama_rdma_server.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#define LLAMA_API_INTERNAL
#include "llama.h"
#include "unicode.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "cuda_runtime.h"
#ifdef GGML_USE_CUBLAS
# include "ggml-cuda.h"
#elif defined(GGML_USE_CLBLAST)
# include "ggml-opencl.h"
#endif
#ifdef GGML_USE_METAL
# include "ggml-metal.h"
#endif
#ifdef GGML_USE_MPI
# include "ggml-mpi.h"
#endif
#ifndef QK_K
# ifdef GGML_QKK_64
# define QK_K 64
# else
# define QK_K 256
# endif
#endif
#ifdef __has_include
#if __has_include(<unistd.h>)
#include <unistd.h>
#if defined(_POSIX_MAPPED_FILES)
#include <sys/mman.h>
#endif
#if defined(_POSIX_MEMLOCK_RANGE)
#include <sys/resource.h>
#endif
#endif
#endif
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
#include <io.h>
#include <stdio.h> // for _fseeki64
#include <direct.h>
#define F_OK 0
#else
#include <libgen.h>
#endif
#include <algorithm>
#include <array>
#include <cassert>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <forward_list>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <map>
#include <memory>
#include <mutex>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <thread>
#include <unordered_map>
#include <vector>
#include "rdma_common.h"
#if defined(_MSC_VER)
#pragma warning(disable: 4244 4267) // possible loss of data
#endif
#ifdef __GNUC__
#ifdef __MINGW32__
#define LLAMA_ATTRIBUTE_FORMAT(...) __attribute__((format(gnu_printf, __VA_ARGS__)))
#else
#define LLAMA_ATTRIBUTE_FORMAT(...) __attribute__((format(printf, __VA_ARGS__)))
#endif
#else
#define LLAMA_ATTRIBUTE_FORMAT(...)
#endif
#define LLAMA_MAX_NODES 4096
void * rdma_idx_vec;
//
// global variables (should be removed after a better design)
//
size_t vram_budget_bytes = 0;
//
// logging
//
LLAMA_ATTRIBUTE_FORMAT(2, 3)
static void llama_log_internal (ggml_log_level level, const char* format, ...);
static void llama_log_callback_default(ggml_log_level level, const char * text, void * user_data);
#define LLAMA_LOG_INFO(...) llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
#define LLAMA_LOG_WARN(...) llama_log_internal(GGML_LOG_LEVEL_WARN , __VA_ARGS__)
#define LLAMA_LOG_ERROR(...) llama_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
//
// helpers
//
//===============rdma================
static struct rdma_event_channel *cm_event_channel = NULL;
static struct rdma_cm_id *cm_server_id = NULL, *cm_client_id = NULL;
static struct ibv_pd *pd = NULL;
static struct ibv_comp_channel *io_completion_channel = NULL;
static struct ibv_cq *cq = NULL;
static struct ibv_qp_init_attr qp_init_attr;
static struct ibv_qp *client_qp = NULL;
/* RDMA memory resources */
static struct ibv_mr *client_metadata_mr = NULL, *server_buffer_mr = NULL, *server_metadata_mr = NULL;
static struct rdma_buffer_attr client_metadata_attr, server_metadata_attr;
static struct ibv_recv_wr client_recv_wr, *bad_client_recv_wr = NULL;
static struct ibv_send_wr server_send_wr, *bad_server_send_wr = NULL;
static struct ibv_sge client_recv_sge, server_send_sge;
static struct rdma_buffer_attr_vec server_metadata_attrs;
static struct rdma_buffer_attr_vec client_metadata_attrs;
std::vector<struct ibv_mr *> server_buffer_mrs;
void printf_dim(ggml_tensor * t ,char * str ="") {
printf("%s:%s %s: %d %d %d %d\n", __func__, t->name, str,t->ne[0], t->ne[1], t->ne[2], t->ne[3]);
}
void printf_value(struct ggml_tensor * tensor,int num =10)
{
int ne0=tensor->ne[0];
int ne1=tensor->ne[1];
int ne2=tensor->ne[2];
int ne3=tensor->ne[3];
for(int i=0;i<ne3;i++)
{
for(int j=0;j<ne2;j++)
{
for(int k=0;k<ne1;k++)
{
for(int l=0;l<ne0;l++)
{
if(--num)
{
printf("%f ",ggml_get_f32_nd(tensor,l,k,j,i));
}
else
{
return;
}
}
}
}
}
}
/* Starts an RDMA server by allocating basic connection resources */
static int start_rdma_server(struct sockaddr_in *server_addr)
{
struct rdma_cm_event *cm_event = NULL;
int ret = -1;
/* Open a channel used to report asynchronous communication event */
cm_event_channel = rdma_create_event_channel(); // 创建一个用于报告异步通信事件的通道
if (!cm_event_channel) {
rdma_error("Creating cm event channel failed with errno : (%d)", -errno);
return -errno;
}
debug("RDMA CM event channel is created successfully at %p \n",
cm_event_channel);
/* rdma_cm_id is the connection identifier (like socket) which is used
* to define an RDMA connection.
*/
ret = rdma_create_id(cm_event_channel, &cm_server_id, NULL, RDMA_PS_TCP); //创建一个 RDMA 连接标识符 cm_server_id,用于定义一个 RDMA 连接。rdma_create_id() 函数使用指定的通道和传输协议(这里是 TCP)创建一个 RDMA 连接标识符。
if (ret) {
rdma_error("Creating server cm id failed with errno: %d ", -errno);
return -errno;
}
debug("A RDMA connection id for the server is created \n");
/* Explicit binding of rdma cm id to the socket credentials */
ret = rdma_bind_addr(cm_server_id, (struct sockaddr*) server_addr); //rdma_bind_addr() 函数将 RDMA 连接标识符绑定到指定的地址。
if (ret) {
rdma_error("Failed to bind server address, errno: %d \n", -errno);
return -errno;
}
debug("Server RDMA CM id is successfully binded \n");
/* Now we start to listen on the passed IP and port. However unlike
* normal TCP listen, this is a non-blocking call. When a new client is
* connected, a new connection management (CM) event is generated on the
* RDMA CM event channel from where the listening id was created. Here we
* have only one channel, so it is easy. */
ret = rdma_listen(cm_server_id, 8); /* backlog = 8 clients, same as TCP, see man listen*/ //开始监听传入的 IP 和端口。并指定最大连接数(这里是 8)。
if (ret) {
rdma_error("rdma_listen failed to listen on server address, errno: %d ",
-errno);
return -errno;
}
printf("Server is listening successfully at: %s , port: %d \n",
inet_ntoa(server_addr->sin_addr),
ntohs(server_addr->sin_port));
/* now, we expect a client to connect and generate a RDMA_CM_EVNET_CONNECT_REQUEST
* We wait (block) on the connection management event channel for
* the connect event.
*/
ret = process_rdma_cm_event(cm_event_channel,
RDMA_CM_EVENT_CONNECT_REQUEST,
&cm_event);
if (ret) {
rdma_error("Failed to get cm event, ret = %d \n" , ret);
return ret;
}
/* Much like TCP connection, listening returns a new connection identifier
* for newly connected client. In the case of RDMA, this is stored in id
* field. For more details: man rdma_get_cm_event
*/
cm_client_id = cm_event->id; //获取新连接的客户端标识符
/* now we acknowledge the event. Acknowledging the event free the resources
* associated with the event structure. Hence any reference to the event
* must be made before acknowledgment. Like, we have already saved the
* client id from "id" field before acknowledging the event.
*/
ret = rdma_ack_cm_event(cm_event); //函数确认接收到的连接管理事件,并释放与事件相关的资源。
if (ret) {
rdma_error("Failed to acknowledge the cm event errno: %d \n", -errno);
return -errno;
}
debug("A new RDMA client connection id is stored at %p\n", cm_client_id);
return ret;
}
static int setup_client_resources() //该函数用于准备客户端连接之前的一些资源设置。
{
int ret = -1;
if(!cm_client_id){
rdma_error("Client id is still NULL \n");
return -EINVAL;
}
/* We have a valid connection identifier, lets start to allocate
* resources. We need:
* 1. Protection Domains (PD) //保护域(Protection Domains,PD):保护域类似于操作系统中的“进程抽象”,它是一组资源的集合,所有的资源都与特定的保护域相关联。在这里,我们需要为客户端连接创建一个保护域。
* 2. Memory Buffers //为了进行RDMA通信,我们需要为客户端连接分配内存缓冲区,用于存储发送和接收的数据
* 3. Completion Queues (CQ) //完成队列用于存储RDMA操作完成的通知。在这里,我们需要为客户端连接创建一个完成队列。
* 4. Queue Pair (QP) //队列对是RDMA通信的基本单元,它包含了发送和接收数据的队列。在这里,我们需要为客户端连接创建一个队列对。
* Protection Domain (PD) is similar to a "process abstraction"
* in the operating system. All resources are tied to a particular PD.
* And accessing recourses across PD will result in a protection fault.
*/
pd = ibv_alloc_pd(cm_client_id->verbs //这行代码使用ibv_alloc_pd函数为客户端连接分配一个保护域(Protection Domain)
/* verbs defines a verb's provider,
* i.e an RDMA device where the incoming
* client connection came */);
if (!pd) {
rdma_error("Failed to allocate a protection domain errno: %d\n",
-errno);
return -errno;
}
debug("A new protection domain is allocated at %p \n", pd);
/* Now we need a completion channel, were the I/O completion
* notifications are sent. Remember, this is different from connection
* management (CM) event notifications.
* A completion channel is also tied to an RDMA device, hence we will
* use cm_client_id->verbs.
*/
io_completion_channel = ibv_create_comp_channel(cm_client_id->verbs);//ibv_create_comp_channel函数创建一个完成通道(Completion Channel),用于接收I/O完成事件的通知。完成通道与RDMA设备相关联,因此我们使用cm_client_id->verbs来指定RDMA设备。
if (!io_completion_channel) {
rdma_error("Failed to create an I/O completion event channel, %d\n",
-errno);
return -errno;
}
debug("An I/O completion event channel is created at %p \n",
io_completion_channel);
/* Now we create a completion queue (CQ) where actual I/O
* completion metadata is placed. The metadata is packed into a structure
* called struct ibv_wc (wc = work completion). ibv_wc has detailed
* information about the work completion. An I/O request in RDMA world
* is called "work" ;)
*/
cq = ibv_create_cq(cm_client_id->verbs /* which device*/, //ibv_create_cq函数创建一个完成队列(Completion Queue),用于存储RDMA操作完成的通知。完成队列中的元数据被打包到一个叫做struct ibv_wc的结构体中,它包含了有关工作完成的详细信息。在RDMA世界中,一个I/O请求被称为“工作”。
CQ_CAPACITY /* maximum capacity*/,
NULL /* user context, not used here */,
io_completion_channel /* which IO completion channel */,
0 /* signaling vector, not used here*/);
if (!cq) {
rdma_error("Failed to create a completion queue (cq), errno: %d\n",
-errno);
return -errno;
}
debug("Completion queue (CQ) is created at %p with %d elements \n",
cq, cq->cqe);
/* Ask for the event for all activities in the completion queue*/
ret = ibv_req_notify_cq(cq /* on which CQ */, //这行代码使用ibv_req_notify_cq函数请求在完成队列上接收所有活动的通知。这里的cq是指定的完成队列,0表示接收所有类型的事件通知,没有过滤。
0 /* 0 = all event type, no filter*/);
if (ret) {
rdma_error("Failed to request notifications on CQ errno: %d \n",
-errno);
return -errno;
}
/* Now the last step, set up the queue pair (send, recv) queues and their capacity.
* The capacity here is define statically but this can be probed from the
* device. We just use a small number as defined in rdma_common.h */ //
bzero(&qp_init_attr, sizeof qp_init_attr); //这一系列代码用于初始化一个队列对(Queue Pair)的属性。队列对是RDMA通信的基本单元,它包含了发送和接收数据的队列。在这里,我们设置了队列对的最大接收和发送工作请求数量,以及队列对的类型(这里是可靠连接类型)和关联的完成队列。
qp_init_attr.cap.max_recv_sge = MAX_SGE; /* Maximum SGE per receive posting */
qp_init_attr.cap.max_recv_wr = MAX_WR; /* Maximum receive posting capacity */
qp_init_attr.cap.max_send_sge = MAX_SGE; /* Maximum SGE per send posting */
qp_init_attr.cap.max_send_wr = MAX_WR; /* Maximum send posting capacity */
qp_init_attr.qp_type = IBV_QPT_RC; /* QP type, RC = Reliable connection */
/* We use same completion queue, but one can use different queues */
qp_init_attr.recv_cq = cq; /* Where should I notify for receive completion operations */
qp_init_attr.send_cq = cq; /* Where should I notify for send completion operations */
/*Lets create a QP */
ret = rdma_create_qp(cm_client_id /* which connection id */, //这行代码使用rdma_create_qp函数创建一个队列对(Queue Pair)。它需要指定连接ID、保护域和队列对的初始属性。函数执行成功后,队列对的引用将保存在client_qp变量中。
pd /* which protection domain*/,
&qp_init_attr /* Initial attributes */);
if (ret) {
rdma_error("Failed to create QP due to errno: %d\n", -errno);
return -errno;
}
/* Save the reference for handy typing but is not required */
client_qp = cm_client_id->qp;
debug("Client QP created at %p\n", client_qp);
return ret;
}
/* Pre-posts a receive buffer and accepts an RDMA client connection */
static int accept_client_connection()
{
struct rdma_conn_param conn_param;
struct rdma_cm_event *cm_event = NULL;
struct sockaddr_in remote_sockaddr;
int ret = -1;
if(!cm_client_id || !client_qp) {
rdma_error("Client resources are not properly setup\n");
return -EINVAL;
}
memset(&conn_param, 0, sizeof(conn_param)); //我们准备一个连接参数结构体conn_param,并将其初始化为零。这个结构体用于指定连接的一些参数,比如我们可以设置期望的请求深度(initiator_depth)和响应方资源数(responder_resources)
/* this tell how many outstanding requests can we handle */
conn_param.initiator_depth = 15; /* For this exercise, we put a small number here */
/* This tell how many outstanding requests we expect other side to handle */
conn_param.responder_resources = 15; /* For this exercise, we put a small number */
//rdma_accept函数接受客户端的连接请求,并传入连接参数。
printf("cm_client_id:%p\n",cm_client_id);
ret = rdma_accept(cm_client_id, &conn_param);
if (ret) {
rdma_error("Failed to accept the connection, errno: %d \n", -errno);
return -errno;
}
/* We expect an RDMA_CM_EVNET_ESTABLISHED to indicate that the RDMA
* connection has been established and everything is fine on both, server
* as well as the client sides.
*/
debug("Going to wait for : RDMA_CM_EVENT_ESTABLISHED event \n");
//使用process_rdma_cm_event函数等待指定类型的RDMA CM事件,并将事件保存在cm_event变量中
ret = process_rdma_cm_event(cm_event_channel,
RDMA_CM_EVENT_ESTABLISHED,
&cm_event);
if (ret) {
rdma_error("Failed to get the cm event, errnp: %d \n", -errno);
return -errno;
}
/* We acknowledge the event */
ret = rdma_ack_cm_event(cm_event);
if (ret) {
rdma_error("Failed to acknowledge the cm event %d\n", -errno);
return -errno;
}
//我们使用rdma_get_peer_addr函数获取连接的对端地址,并将其保存在remote_sockaddr变量中。
/* Just FYI: How to extract connection information */
memcpy(&remote_sockaddr /* where to save */,
rdma_get_peer_addr(cm_client_id) /* gives you remote sockaddr */,
sizeof(struct sockaddr_in) /* max size */);
printf("A new connection is accepted from %s \n",
inet_ntoa(remote_sockaddr.sin_addr));
return ret;
}
/* This function sends server side buffer metadata to the connected client */
static int register_mrs_to_client(std::vector<ggml_tensor*> tensor_dsts ) //该函数用于向连接的客户端发送服务器端缓冲区的元数据。
{
struct ibv_wc wc; //工作完成(work completion)结构体
int ret = -1;
size_t size = tensor_dsts.size();
server_buffer_mrs.resize(size);
for(int i=0;i<size;++i)
{
server_buffer_mrs[i] = rdma_buffer_register(pd /* which protection domain */,
tensor_dsts[i]->data,
ggml_nbytes(tensor_dsts[i]) /* what size to allocate */,
(ibv_access_flags)(IBV_ACCESS_LOCAL_WRITE|
IBV_ACCESS_REMOTE_READ|
IBV_ACCESS_REMOTE_WRITE) /* access permissions */);
if(!server_buffer_mrs[i]){
rdma_error("Server failed to create a buffer \n");
/* we assume that it is due to out of memory error */
return -ENOMEM;
}
server_metadata_attrs.address[i] = (uint64_t) server_buffer_mrs[i]->addr;
server_metadata_attrs.length[i] = (uint32_t) server_buffer_mrs[i]->length;
server_metadata_attrs.stags[i].local_stag = (uint32_t) server_buffer_mrs[i]->lkey;
}
/* This buffer is used to transmit information about the above
* buffer to the client. So this contains the metadata about the server
* buffer. Hence this is called metadata buffer. Since this is already
* on allocated, we just register it.
* We need to prepare a send I/O operation that will tell the
* client the address of the server buffer.
*/
//代码准备一个发送操作,用于告知客户端服务器端缓冲区的地址。代码将服务器端缓冲区的地址、长度和本地标签信息填充到server_metadata_attr 结构体中
server_metadata_mr = rdma_buffer_register(pd /* which protection domain*/, //调用 rdma_buffer_register() 函数将其注册到保护域中
&server_metadata_attrs /* which memory to register */,
sizeof(server_metadata_attrs) /* what is the size of memory */,
IBV_ACCESS_LOCAL_WRITE /* what access permission */);
if(!server_metadata_mr){
rdma_error("Server failed to create to hold server metadata \n");
/* we assume that this is due to out of memory error */
return -ENOMEM;
}
/* We need to transmit this buffer. So we create a send request.
* A send request consists of multiple SGE elements. In our case, we only
* have one
*/
//代码创建一个发送请求,并将 server_metadata_attr 结构体的信息填充到 server_send_sge 结构体中。接着,代码将 server_send_sge 结构体与发送请求关联,并设置发送请求的操作码为 IBV_WR_SEND,表示这是一个发送请求。代码还设置发送请求的标志为 IBV_SEND_SIGNALED,表示希望接收到发送完成的通知。
server_send_sge.addr = (uint64_t) &server_metadata_attrs;
server_send_sge.length = sizeof(server_metadata_attrs);
server_send_sge.lkey = server_metadata_mr->lkey;
/* now we link this sge to the send request */
bzero(&server_send_wr, sizeof(server_send_wr));
server_send_wr.sg_list = &server_send_sge;
server_send_wr.num_sge = 1; // only 1 SGE element in the array
server_send_wr.opcode = IBV_WR_SEND; // This is a send request
server_send_wr.send_flags = IBV_SEND_SIGNALED; // We want to get notification
/* This is a fast data path operation. Posting an I/O request */
// sleep(50);
ret = ibv_post_send(client_qp /* which QP */,
&server_send_wr /* Send request that we prepared before */,
&bad_server_send_wr /* In case of error, this will contain failed requests */);
if (ret) {
rdma_error("Posting of server metdata failed, errno: %d \n",
-errno);
return -errno;
}
//代码调用 ibv_post_send() 函数将发送请求提交到客户端的队列对列(QP)中,并检查是否提交成功。
/* We check for completion notification */
ret = process_work_completion_events(io_completion_channel, &wc, 1);
if (ret != 1) {
rdma_error("Failed to send server metadata, ret = %d \n", ret);
return ret;
}
debug("Local buffer metadata has been sent to the client \n");
return 0;
}
/* This is server side logic. Server passively waits for the client to call
* rdma_disconnect() and then it will clean up its resources */
static int disconnect_and_cleanup_LLM_vec()
{
// sleep(1000);
struct rdma_cm_event *cm_event = NULL;
int ret = -1;
/* Now we wait for the client to send us disconnect event */
debug("Waiting for cm event: RDMA_CM_EVENT_DISCONNECTED\n");
ret = process_rdma_cm_event(cm_event_channel, //函数等待客户端发送断开连接事件。它调用了 process_rdma_cm_event 函数来处理 RDMA_CM_EVENT_DISCONNECTED 事件,并将返回的事件存储在 cm_event 中。
RDMA_CM_EVENT_DISCONNECTED,
&cm_event);
if (ret) {
rdma_error("Failed to get disconnect event, ret = %d \n", ret);
return ret;
}
/* We acknowledge the event */
ret = rdma_ack_cm_event(cm_event);
if (ret) {
rdma_error("Failed to acknowledge the cm event %d\n", -errno);
return -errno;
}
printf("A disconnect event is received from the client...\n");
/* We free all the resources */
/* Destroy QP */
rdma_destroy_qp(cm_client_id); //首先,它销毁 QP(Queue Pair)。
/* Destroy client cm id */
ret = rdma_destroy_id(cm_client_id);//然后,销毁客户端的 cm id(Connection Manager Identifier)
if (ret) {
rdma_error("Failed to destroy client id cleanly, %d \n", -errno);
// we continue anyways;
}
/* Destroy CQ */
ret = ibv_destroy_cq(cq); //函数销毁完成通道(Completion Channel)。
if (ret) {
rdma_error("Failed to destroy completion queue cleanly, %d \n", -errno);
// we continue anyways;
}
/* Destroy completion channel */
ret = ibv_destroy_comp_channel(io_completion_channel);
if (ret) {
rdma_error("Failed to destroy completion channel cleanly, %d \n", -errno);
// we continue anyways;
}
/* Destroy memory buffers */
size_t size = server_buffer_mrs.size();
for(int i=0;i<size;++i)
{
// tensor_dsts[i]->data = server_buffer_mrs[i]->addr;
// printf_value(tensor_dsts[i]); //函数释放内存缓冲区。它调用 rdma_buffer_free 函数来释放服务器缓冲区的内存资源,
printf("\n");
}
for(int i=0;i<size;++i)
{
rdma_buffer_free(server_buffer_mrs[i]); //函数释放内存缓冲区。它调用 rdma_buffer_free 函数来释放服务器缓冲区的内存资源,
// free(tensor_dsts[i]->data);
}
rdma_buffer_deregister(server_metadata_mr); //并调用 rdma_buffer_deregister 函数来注销客户端和服务器的元数据内存资源
rdma_buffer_deregister(client_metadata_mr);
/* Destroy protection domain */
ret = ibv_dealloc_pd(pd); //最后,函数销毁 rdma 服务器 id(Identifier)。
if (ret) {
rdma_error("Failed to destroy client protection domain cleanly, %d \n", -errno);
// we continue anyways;
}
/* Destroy rdma server id */
ret = rdma_destroy_id(cm_server_id); //最后,函数销毁 rdma 服务器 id(Identifier)。
if (ret) {
rdma_error("Failed to destroy server id cleanly, %d \n", -errno);
// we continue anyways;
}
rdma_destroy_event_channel(cm_event_channel);
printf("Server shut-down is complete \n");
return 0;
}
/* This is server side logic. Server passively waits for the client to call
* rdma_disconnect() and then it will clean up its resources */
sockaddr_in get_server_sockaddr(char *ip, char * port) {
struct sockaddr_in server_sockaddr;
int ret, option;
bzero(&server_sockaddr, sizeof server_sockaddr);
server_sockaddr.sin_family = AF_INET;
server_sockaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
if(ip)
{
ret = get_addr(ip, (struct sockaddr*) &server_sockaddr);
if(ret) {
rdma_error("Invalid IP \n");
exit(1);
}
}
if (!port) {
/* no port provided, use the default port */
server_sockaddr.sin_port = htons(DEFAULT_RDMA_PORT);
}
else
{ printf("port is %s\n",port);
server_sockaddr.sin_port = htons(strtol(port, NULL, 0));
}
return server_sockaddr;
}
//====================rdma====================
static size_t utf8_len(char src) {
const size_t lookup[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 4 };
uint8_t highbits = static_cast<uint8_t>(src) >> 4;
return lookup[highbits];
}
static void replace_all(std::string & s, const std::string & search, const std::string & replace) {
std::string result;
for (size_t pos = 0; ; pos += search.length()) {
auto new_pos = s.find(search, pos);
if (new_pos == std::string::npos) {
result += s.substr(pos, s.size() - pos);
break;
}
result += s.substr(pos, new_pos - pos) + replace;
pos = new_pos;
}
s = std::move(result);
}
static bool is_float_close(float a, float b, float abs_tol) {
// Check for non-negative tolerance
if (abs_tol < 0.0) {
throw std::invalid_argument("Tolerance must be non-negative");
}
// Exact equality check
if (a == b) {
return true;
}
// Check for infinities
if (std::isinf(a) || std::isinf(b)) {
return false;
}
// Regular comparison using the provided absolute tolerance
return std::fabs(b - a) <= abs_tol;
}
#ifdef GGML_USE_CPU_HBM
#include <hbwmalloc.h>
#endif
static void zeros(std::ofstream & file, size_t n) {
char zero = 0;
for (size_t i = 0; i < n; ++i) {
file.write(&zero, 1);
}
}
LLAMA_ATTRIBUTE_FORMAT(1, 2)
static std::string format(const char * fmt, ...) {
va_list ap;
va_list ap2;
va_start(ap, fmt);
va_copy(ap2, ap);
int size = vsnprintf(NULL, 0, fmt, ap);
GGML_ASSERT(size >= 0 && size < INT_MAX); // NOLINT
std::vector<char> buf(size + 1);
int size2 = vsnprintf(buf.data(), size + 1, fmt, ap2);
GGML_ASSERT(size2 == size);
va_end(ap2);
va_end(ap);
return std::string(buf.data(), size);
}
static size_t llama_set_vram_budget(double budget_gb, int gpu_device) {
#if defined(GGML_USE_CUBLAS)
if (!ggml_cublas_loaded()) {
throw std::runtime_error("CUDA is not loaded");
}
if (budget_gb < 0) {
// if the user didn't specify a budget, use all available memory
// and leave 256 MB as a safety margin
vram_budget_bytes = ggml_cuda_get_free_memory(gpu_device) - 256 * 1024 * 1024;
} else {
// otherwise, use the specified budget
vram_budget_bytes = (size_t) (budget_gb * 1024 * 1024 * 1024);
}
return vram_budget_bytes;
#else
return 0;
#endif
}
static bool llama_reduce_vram_budget(size_t budget_bytes) {
#if not defined(GGML_USE_CUBLAS)
throw std::runtime_error("CUDA is not enabled");
#endif
if (vram_budget_bytes >= budget_bytes) {
vram_budget_bytes -= budget_bytes;
return true;
}
return false;
}
//
// gguf constants (sync with gguf.py)
//
enum llm_arch {
LLM_ARCH_LLAMA,
LLM_ARCH_FALCON,
LLM_ARCH_BAICHUAN,
LLM_ARCH_GPT2,
LLM_ARCH_GPTJ,
LLM_ARCH_GPTNEOX,
LLM_ARCH_MPT,
LLM_ARCH_STARCODER,
LLM_ARCH_PERSIMMON,
LLM_ARCH_REFACT,
LLM_ARCH_BLOOM,
LLM_ARCH_STABLELM,
LLM_ARCH_UNKNOWN,
};
static std::map<llm_arch, std::string> LLM_ARCH_NAMES = {
{ LLM_ARCH_LLAMA, "llama" },
{ LLM_ARCH_FALCON, "falcon" },
{ LLM_ARCH_GPT2, "gpt2" },
{ LLM_ARCH_GPTJ, "gptj" },
{ LLM_ARCH_GPTNEOX, "gptneox" },
{ LLM_ARCH_MPT, "mpt" },
{ LLM_ARCH_BAICHUAN, "baichuan" },
{ LLM_ARCH_STARCODER, "starcoder" },
{ LLM_ARCH_PERSIMMON, "persimmon" },
{ LLM_ARCH_REFACT, "refact" },
{ LLM_ARCH_BLOOM, "bloom" },
{ LLM_ARCH_STABLELM, "stablelm" },
{ LLM_ARCH_UNKNOWN, "unknown" },
};
enum llm_kv {
LLM_KV_GENERAL_ARCHITECTURE,
LLM_KV_GENERAL_QUANTIZATION_VERSION,
LLM_KV_GENERAL_ALIGNMENT,
LLM_KV_GENERAL_NAME,
LLM_KV_GENERAL_AUTHOR,
LLM_KV_GENERAL_URL,
LLM_KV_GENERAL_DESCRIPTION,
LLM_KV_GENERAL_LICENSE,
LLM_KV_GENERAL_SOURCE_URL,
LLM_KV_GENERAL_SOURCE_HF_REPO,
LLM_KV_CONTEXT_LENGTH,
LLM_KV_EMBEDDING_LENGTH,
LLM_KV_BLOCK_COUNT,
LLM_KV_FEED_FORWARD_LENGTH,
LLM_KV_USE_PARALLEL_RESIDUAL,
LLM_KV_TENSOR_DATA_LAYOUT,
LLM_KV_ATTENTION_HEAD_COUNT,
LLM_KV_ATTENTION_HEAD_COUNT_KV,
LLM_KV_ATTENTION_MAX_ALIBI_BIAS,
LLM_KV_ATTENTION_CLAMP_KQV,
LLM_KV_ATTENTION_LAYERNORM_EPS,
LLM_KV_ATTENTION_LAYERNORM_RMS_EPS,
LLM_KV_ROPE_DIMENSION_COUNT,
LLM_KV_ROPE_FREQ_BASE,
LLM_KV_ROPE_SCALE_LINEAR,
LLM_KV_ROPE_SCALING_TYPE,
LLM_KV_ROPE_SCALING_FACTOR,
LLM_KV_ROPE_SCALING_ORIG_CTX_LEN,
LLM_KV_ROPE_SCALING_FINETUNED,
LLM_KV_TOKENIZER_MODEL,
LLM_KV_TOKENIZER_LIST,
LLM_KV_TOKENIZER_TOKEN_TYPE,
LLM_KV_TOKENIZER_SCORES,
LLM_KV_TOKENIZER_MERGES,
LLM_KV_TOKENIZER_BOS_ID,
LLM_KV_TOKENIZER_EOS_ID,
LLM_KV_TOKENIZER_UNK_ID,
LLM_KV_TOKENIZER_SEP_ID,
LLM_KV_TOKENIZER_PAD_ID,
LLM_KV_TOKENIZER_HF_JSON,
LLM_KV_TOKENIZER_RWKV,
LLM_KV_SPARSE_THRESHOLD,
LLM_KV_SPLIT_VRAM_CAPACITY,
};
static std::map<llm_kv, std::string> LLM_KV_NAMES = {
{ LLM_KV_GENERAL_ARCHITECTURE, "general.architecture" },
{ LLM_KV_GENERAL_QUANTIZATION_VERSION, "general.quantization_version" },
{ LLM_KV_GENERAL_ALIGNMENT, "general.alignment" },
{ LLM_KV_GENERAL_NAME, "general.name" },
{ LLM_KV_GENERAL_AUTHOR, "general.author" },
{ LLM_KV_GENERAL_URL, "general.url" },
{ LLM_KV_GENERAL_DESCRIPTION, "general.description" },
{ LLM_KV_GENERAL_LICENSE, "general.license" },
{ LLM_KV_GENERAL_SOURCE_URL, "general.source.url" },
{ LLM_KV_GENERAL_SOURCE_HF_REPO, "general.source.huggingface.repository" },
{ LLM_KV_CONTEXT_LENGTH, "%s.context_length" },
{ LLM_KV_EMBEDDING_LENGTH, "%s.embedding_length" },
{ LLM_KV_BLOCK_COUNT, "%s.block_count" },
{ LLM_KV_FEED_FORWARD_LENGTH, "%s.feed_forward_length" },
{ LLM_KV_USE_PARALLEL_RESIDUAL, "%s.use_parallel_residual" },
{ LLM_KV_TENSOR_DATA_LAYOUT, "%s.tensor_data_layout" },
{ LLM_KV_ATTENTION_HEAD_COUNT, "%s.attention.head_count" },
{ LLM_KV_ATTENTION_HEAD_COUNT_KV, "%s.attention.head_count_kv" },
{ LLM_KV_ATTENTION_MAX_ALIBI_BIAS, "%s.attention.max_alibi_bias" },
{ LLM_KV_ATTENTION_CLAMP_KQV, "%s.attention.clamp_kqv" },
{ LLM_KV_ATTENTION_LAYERNORM_EPS, "%s.attention.layer_norm_epsilon" },
{ LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, "%s.attention.layer_norm_rms_epsilon" },
{ LLM_KV_ROPE_DIMENSION_COUNT, "%s.rope.dimension_count" },
{ LLM_KV_ROPE_FREQ_BASE, "%s.rope.freq_base" },
{ LLM_KV_ROPE_SCALE_LINEAR, "%s.rope.scale_linear" },
{ LLM_KV_ROPE_SCALING_TYPE, "%s.rope.scaling.type" },
{ LLM_KV_ROPE_SCALING_FACTOR, "%s.rope.scaling.factor" },
{ LLM_KV_ROPE_SCALING_ORIG_CTX_LEN, "%s.rope.scaling.original_context_length" },
{ LLM_KV_ROPE_SCALING_FINETUNED, "%s.rope.scaling.finetuned" },
{ LLM_KV_TOKENIZER_MODEL, "tokenizer.ggml.model" },
{ LLM_KV_TOKENIZER_LIST, "tokenizer.ggml.tokens" },
{ LLM_KV_TOKENIZER_TOKEN_TYPE, "tokenizer.ggml.token_type" },
{ LLM_KV_TOKENIZER_SCORES, "tokenizer.ggml.scores" },
{ LLM_KV_TOKENIZER_MERGES, "tokenizer.ggml.merges" },
{ LLM_KV_TOKENIZER_BOS_ID, "tokenizer.ggml.bos_token_id" },
{ LLM_KV_TOKENIZER_EOS_ID, "tokenizer.ggml.eos_token_id" },
{ LLM_KV_TOKENIZER_UNK_ID, "tokenizer.ggml.unknown_token_id" },
{ LLM_KV_TOKENIZER_SEP_ID, "tokenizer.ggml.seperator_token_id" },
{ LLM_KV_TOKENIZER_PAD_ID, "tokenizer.ggml.padding_token_id" },
{ LLM_KV_TOKENIZER_HF_JSON, "tokenizer.huggingface.json" },
{ LLM_KV_TOKENIZER_RWKV, "tokenizer.rwkv.world" },
{ LLM_KV_SPARSE_THRESHOLD, "powerinfer.sparse_threshold" },
{ LLM_KV_SPLIT_VRAM_CAPACITY, "split.vram_capacity" },
};
struct LLM_KV {
LLM_KV(llm_arch arch) : arch(arch) {}
llm_arch arch;
std::string operator()(llm_kv kv) const {
return ::format(LLM_KV_NAMES[kv].c_str(), LLM_ARCH_NAMES[arch].c_str());
}
};
enum llm_tensor {
LLM_TENSOR_TOKEN_EMBD,
LLM_TENSOR_TOKEN_EMBD_NORM,
LLM_TENSOR_POS_EMBD,
LLM_TENSOR_OUTPUT,
LLM_TENSOR_OUTPUT_NORM,
LLM_TENSOR_ROPE_FREQS,
LLM_TENSOR_ATTN_Q,
LLM_TENSOR_ATTN_K,
LLM_TENSOR_ATTN_V,
LLM_TENSOR_ATTN_QKV,
LLM_TENSOR_ATTN_OUT,
LLM_TENSOR_ATTN_NORM,
LLM_TENSOR_ATTN_NORM_2,
LLM_TENSOR_ATTN_ROT_EMBD,
LLM_TENSOR_FFN_GATE,
LLM_TENSOR_FFN_DOWN,
LLM_TENSOR_FFN_UP,
LLM_TENSOR_FFN_NORM,
LLM_TENSOR_ATTN_Q_NORM,
LLM_TENSOR_ATTN_K_NORM,
LLM_TENSOR_MLP_PRED_FC1,
LLM_TENSOR_MLP_PRED_FC2,
LLM_TENSOR_FFN_DOWN_T,
};
static std::map<llm_arch, std::map<llm_tensor, std::string>> LLM_TENSOR_NAMES = {
{
LLM_ARCH_LLAMA,
{
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
{ LLM_TENSOR_OUTPUT, "output" },
{ LLM_TENSOR_ROPE_FREQS, "rope_freqs" },
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
{ LLM_TENSOR_ATTN_Q, "blk.%d.attn_q" },
{ LLM_TENSOR_ATTN_K, "blk.%d.attn_k" },
{ LLM_TENSOR_ATTN_V, "blk.%d.attn_v" },
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
{ LLM_TENSOR_ATTN_ROT_EMBD, "blk.%d.attn_rot_embd" },
{ LLM_TENSOR_FFN_NORM, "blk.%d.ffn_norm" },
{ LLM_TENSOR_FFN_GATE, "blk.%d.ffn_gate" },
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
{ LLM_TENSOR_FFN_DOWN_T, "blk.%d.ffn_down_t" },
{ LLM_TENSOR_MLP_PRED_FC1, "blk.%d.fc1" },
{ LLM_TENSOR_MLP_PRED_FC2, "blk.%d.fc2" },
},
},
{
LLM_ARCH_BAICHUAN,
{
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
{ LLM_TENSOR_OUTPUT, "output" },
{ LLM_TENSOR_ROPE_FREQS, "rope_freqs" },
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
{ LLM_TENSOR_ATTN_Q, "blk.%d.attn_q" },
{ LLM_TENSOR_ATTN_K, "blk.%d.attn_k" },
{ LLM_TENSOR_ATTN_V, "blk.%d.attn_v" },
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
{ LLM_TENSOR_ATTN_ROT_EMBD, "blk.%d.attn_rot_embd" },
{ LLM_TENSOR_FFN_NORM, "blk.%d.ffn_norm" },
{ LLM_TENSOR_FFN_GATE, "blk.%d.ffn_gate" },
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
},
},
{
LLM_ARCH_FALCON,
{
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
{ LLM_TENSOR_OUTPUT, "output" },
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
{ LLM_TENSOR_ATTN_NORM_2, "blk.%d.attn_norm_2" },
{ LLM_TENSOR_ATTN_QKV, "blk.%d.attn_qkv" },
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
{ LLM_TENSOR_FFN_DOWN_T, "blk.%d.ffn_down_t" },
{ LLM_TENSOR_MLP_PRED_FC1, "blk.%d.fc1" },
{ LLM_TENSOR_MLP_PRED_FC2, "blk.%d.fc2" },
},
},
{
LLM_ARCH_GPT2,
{
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
},
},
{
LLM_ARCH_GPTJ,
{
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
},
},
{
LLM_ARCH_GPTNEOX,
{
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
{ LLM_TENSOR_OUTPUT, "output" },
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
{ LLM_TENSOR_ATTN_QKV, "blk.%d.attn_qkv" },
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
{ LLM_TENSOR_FFN_NORM, "blk.%d.ffn_norm" },
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
},
},
{
LLM_ARCH_PERSIMMON,
{
{ LLM_TENSOR_TOKEN_EMBD, "token_embd"},
{ LLM_TENSOR_OUTPUT_NORM, "output_norm"},
{ LLM_TENSOR_OUTPUT, "output"},
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm"},
{ LLM_TENSOR_ATTN_QKV, "blk.%d.attn_qkv"},
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output"},
{ LLM_TENSOR_ATTN_Q_NORM, "blk.%d.attn_q_norm"},
{ LLM_TENSOR_ATTN_K_NORM, "blk.%d.attn_k_norm"},
{ LLM_TENSOR_FFN_NORM, "blk.%d.ffn_norm"},
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down"},
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up"},
{ LLM_TENSOR_ATTN_ROT_EMBD, "blk.%d.attn_rot_embd"},
},
},
{
LLM_ARCH_MPT,
{
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
{ LLM_TENSOR_OUTPUT, "output" },
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
{ LLM_TENSOR_FFN_NORM, "blk.%d.ffn_norm" },
{ LLM_TENSOR_ATTN_QKV, "blk.%d.attn_qkv" },
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
},
},
{
LLM_ARCH_STARCODER,
{
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
{ LLM_TENSOR_POS_EMBD, "position_embd" },
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
{ LLM_TENSOR_OUTPUT, "output" },
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
{ LLM_TENSOR_ATTN_QKV, "blk.%d.attn_qkv" },
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
{ LLM_TENSOR_FFN_NORM, "blk.%d.ffn_norm" },
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
},
},
{