Skip to content

Commit

Permalink
Add code comments and remove MPI example from set of default targets
Browse files Browse the repository at this point in the history
  • Loading branch information
AutonomicPerfectionist committed Sep 25, 2023
1 parent fa26188 commit 03225cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Define the default target now so that it is always the first target
BUILD_TARGETS = main quantize quantize-stats perplexity embedding vdot train-text-from-scratch convert-llama2c-to-ggml simple save-load-state server embd-input-test gguf llama-bench baby-llama beam-search speculative tests/test-c.o mpi
BUILD_TARGETS = main quantize quantize-stats perplexity embedding vdot train-text-from-scratch convert-llama2c-to-ggml simple save-load-state server embd-input-test gguf llama-bench baby-llama beam-search speculative tests/test-c.o

# Binaries only useful for tests
TEST_TARGETS = tests/test-llama-grammar tests/test-grammar-parser tests/test-double-float tests/test-grad0 tests/test-opt tests/test-quantize-fns tests/test-quantize-perf tests/test-sampling tests/test-tokenizer-0-llama tests/test-tokenizer-0-falcon tests/test-tokenizer-1-llama
Expand Down
16 changes: 10 additions & 6 deletions examples/mpi/mpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <sstream>
#include <string>
#include <vector>

// TODO add Windows support
#include <wordexp.h>

#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
Expand Down Expand Up @@ -116,10 +118,13 @@ int main(int argc, char ** argv) {
return 2;
}

// Manually add the path used to launch this program to the
// options
std::string rawOptions = argv[0];
rawOptions += ' ';
std::ifstream optionsFile(argv[1]);
if (optionsFile.is_open()) {
// Read in the options file, appending to the launch path
std::ostringstream buf;
buf << optionsFile.rdbuf();
rawOptions += buf.str();
Expand All @@ -130,22 +135,21 @@ int main(int argc, char ** argv) {
return 3;
}

// wordexp doesn't work right if there's a trailing newline, so strip it
rawOptions.erase(rawOptions.find_last_not_of(" \t\n\r\f\v") + 1);

printf("%s", rawOptions.c_str());

wordexp_t splitOptions;
wordexp(rawOptions.c_str(), &splitOptions, WRDE_NOCMD);
//char** loadedArgs = (char **) malloc(1 + sizeof(char*) * splitOptions.we_wordc);
//loadedArgs[0] = argv[0];
//memcpy(&loadedArgs[1], splitOptions.we_wordv, sizeof(char*) * splitOptions.we_wordc);
printf("Loaded argc: %d", splitOptions.we_wordc);
fprintf(stderr, "Loaded arguments: ");
for (int i = 0; i < splitOptions.we_wordc; i++) {

printf(" %s", splitOptions.we_wordv[i]);
fprintf(stderr, " %s", splitOptions.we_wordv[i]);
}
printf("\n");
fprintf(stderr, "\n");

// Now we can parse like normal, but using the loaded options instead of the passed argv
if (gpt_params_parse(splitOptions.we_wordc, splitOptions.we_wordv, params) == false) {
wordfree(&splitOptions);
return 1;
Expand Down

0 comments on commit 03225cd

Please sign in to comment.