| 96 | } |
| 97 | |
| 98 | int main(int argc, char ** argv) { |
| 99 | srand(1234); |
| 100 | |
| 101 | gpt_params params; |
| 102 | |
| 103 | if (gpt_params_parse(argc, argv, params) == false) { |
| 104 | return 1; |
| 105 | } |
| 106 | |
| 107 | // number of simultaneous "clients" to simulate |
| 108 | const int32_t n_clients = params.n_parallel; |
| 109 | |
| 110 | // requests to simulate |
| 111 | const int32_t n_seq = params.n_sequences; |
| 112 | |
| 113 | // insert new requests as soon as the previous one is done |
| 114 | const bool cont_batching = params.cont_batching; |
| 115 | |
| 116 | #ifndef LOG_DISABLE_LOGS |
| 117 | log_set_target(log_filename_generator("parallel", "log")); |
| 118 | LOG_TEE("Log start\n"); |
| 119 | log_dump_cmdline(argc, argv); |
| 120 | #endif // LOG_DISABLE_LOGS |
| 121 | |
| 122 | // init llama.cpp |
| 123 | llama_backend_init(params.numa); |
| 124 | |
| 125 | llama_model * model = NULL; |
| 126 | llama_context * ctx = NULL; |
| 127 | |
| 128 | // load the target model |
| 129 | params.logits_all = true; |
| 130 | std::tie(model, ctx) = llama_init_from_gpt_params(params); |
| 131 | |
| 132 | // load the prompts from an external file if there are any |
| 133 | if (params.prompt.empty()) { |
| 134 | printf("\n\033[32mNo new questions so proceed with build-in defaults.\033[0m\n"); |
| 135 | } else { |
| 136 | // Output each line of the input params.prompts vector and copy to k_prompts |
| 137 | int index = 0; |
| 138 | printf("\n\033[32mNow printing the external prompt file %s\033[0m\n\n", params.prompt_file.c_str()); |
| 139 | |
| 140 | std::vector<std::string> prompts = split_string(params.prompt, '\n'); |
| 141 | for (const auto& prompt : prompts) { |
| 142 | k_prompts.resize(index + 1); |
| 143 | k_prompts[index] = prompt; |
| 144 | index++; |
| 145 | printf("%3d prompt: %s\n", index, prompt.c_str()); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | fprintf(stderr, "\n\n"); |
| 150 | fflush(stderr); |
| 151 | |
| 152 | const int n_ctx = llama_n_ctx(ctx); |
| 153 | |
| 154 | std::vector<client> clients(n_clients); |
| 155 | for (size_t i = 0; i < clients.size(); ++i) { |
nothing calls this directly
no test coverage detected