char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
a7cc83bba
char/aliceai-t5-moe
1#include "ggml-alloc.h" 2#include "ggml-backend.h" 3#include "ggml-impl.h" 4#include "ggml-rpc.h" 5#include "ggml.h" 6 7int main (int argc ,char ** argv ) { 8GGML_ASSERT (argc == 3 ); 9ggml_backend_load_all (); 10 11const char * endpoint_a = argv [1 ]; 12const char * endpoint_b = argv [2 ]; 13 14ggml_backend_t backend_a = ggml_backend_rpc_init (endpoint_a ,0 ); 15ggml_backend_t backend_b = ggml_backend_rpc_init (endpoint_b ,0 ); 16GGML_ASSERT (backend_a != nullptr ); 17GGML_ASSERT (backend_b != nullptr ); 18 19ggml_init_params params = { 20/* .mem_size = */ ggml_tensor_overhead ()+ ggml_graph_overhead_custom (1 , false), 21/* .mem_buffer = */ nullptr , 22/* .no_alloc = */ true, 23 }; 24ggml_context * ctx = ggml_init (params ); 25GGML_ASSERT (ctx != nullptr ); 26 27ggml_tensor * tensor = ggml_new_tensor_1d (ctx ,GGML_TYPE_F32 ,1 ); 28ggml_backend_buffer_t buffer = ggml_backend_alloc_ctx_tensors (ctx ,backend_a ); 29GGML_ASSERT (buffer != nullptr ); 30 31// A remote pointer allocated by server A is not meaningful to server B. 32ggml_cgraph * graph = ggml_new_graph_custom (ctx ,1 , false); 33graph -> nodes [0 ]= tensor ; 34graph -> n_nodes = 1 ; 35 36GGML_ASSERT (ggml_backend_graph_compute (backend_b ,graph )== GGML_STATUS_SUCCESS ); 37// Wait for server B to finish the graph before the script checks its log. 38size_t free_mem ; 39size_t total_mem ; 40ggml_backend_rpc_get_device_memory (endpoint_b ,0 ,& free_mem ,& total_mem ); 41GGML_ASSERT (total_mem > 0 ); 42ggml_backend_buffer_free (buffer ); 43ggml_free (ctx ); 44ggml_backend_free (backend_b ); 45ggml_backend_free (backend_a ); 46return 0 ; 47}