Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
brittlewis12 committed Nov 17, 2023
1 parent dd0e829 commit c6bdce2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Sources/llmfarm_core_cpp/ggml/ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -13537,7 +13537,7 @@ static void ggml_compute_forward_rope_f16(
dst_data[n_dims] = GGML_FP32_TO_FP16(x2*cos_block_theta - x3*sin_block_theta);
dst_data[n_dims/2*3] = GGML_FP32_TO_FP16(x2*sin_block_theta + x3*cos_block_theta);
}
} if (!is_neox) {
} else if (!is_neox) {
for (int64_t i0 = 0; i0 < ne0; i0 += 2) {
const float cos_theta = cosf(theta);
const float sin_theta = sinf(theta);
Expand Down Expand Up @@ -19170,6 +19170,7 @@ void ggml_graph_export(const struct ggml_cgraph * cgraph, const char * fname) {

if (idx == -1) {
fprintf(stderr, "%s: failed to find tensor, arg = %d, node = %d\n", __func__, j, i);
fclose(fout);
return;
}

Expand Down
18 changes: 9 additions & 9 deletions Sources/llmfarm_core_cpp/ggml/train.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1376,11 +1376,11 @@ void train_opt_callback(void * vdata, int accum_step, float * sched, bool * canc
struct ggml_opt_context * opt = train->opt;
int n_batch = params->n_batch;
int n_ctx = params->n_ctx;

bool swift_callback_res = false;

// swift_callback_res = data->swiftcallback("Begin");

if (accum_step == 0) {
// time measurement
int64_t now = ggml_time_ms();
Expand All @@ -1392,9 +1392,9 @@ void train_opt_callback(void * vdata, int accum_step, float * sched, bool * canc
const double gain = 0.7;
data->millis_per_iter = data->millis_per_iter*(1.0-gain) + dt*gain;
}
}
}
double remaining_millis = 0.0;

if (data->millis_per_iter > 0.0) {
const int n_iter = params->adam_n_iter;
const int done_iter = opt->iter - data->first_iter;
Expand Down Expand Up @@ -1431,11 +1431,11 @@ void train_opt_callback(void * vdata, int accum_step, float * sched, bool * canc

int impr_plot = -(int)(1 + (opt->loss_before - opt->loss_after) * 10.0f + 0.5f);
if (impr_plot > 0) impr_plot = 0;
if (std::isnan(opt->loss_before) || std::isnan(opt->loss_before)) impr_plot = 0;
if (std::isnan(opt->loss_before) || std::isnan(opt->loss_after)) impr_plot = 0;
printf("%s: iter=%6d sample=%zu/%zu sched=%f loss=%f",
__func__, opt->iter, std::min(1+train->shuffle_next_sample, train->shuffle_sample_count), train->shuffle_sample_count,
*sched, opt->loss_after);

char descr[500]; \
sprintf(descr, "%s: iter=%6d sample=%zu/%zu sched=%f loss=%f",
__func__, opt->iter, std::min(1+train->shuffle_next_sample, train->shuffle_sample_count), train->shuffle_sample_count,
Expand All @@ -1444,8 +1444,8 @@ void train_opt_callback(void * vdata, int accum_step, float * sched, bool * canc
if (swift_callback_res == true){
*cancel = true;
}



if (data->millis_per_iter > 0) {
printf(" dt=");
Expand Down
2 changes: 1 addition & 1 deletion Sources/llmfarm_core_cpp/grammar-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ namespace grammar_parser {
void print_grammar(FILE * file, const parse_state & state) {
try {
std::map<uint32_t, std::string> symbol_id_names;
for (auto kv : state.symbol_ids) {
for (const auto & kv : state.symbol_ids) {
symbol_id_names[kv.second] = kv.first;
}
for (size_t i = 0, end = state.rules.size(); i < end; i++) {
Expand Down
7 changes: 3 additions & 4 deletions Sources/llmfarm_core_cpp/llama/llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6587,7 +6587,6 @@ struct llm_tokenizer_bpe {
llm_symbol sym;
size_t char_len = std::min(word.size() - offset, (size_t) ::utf8_len(word[offset]));
sym.text = word.c_str() + offset;
sym.n = 1;
sym.n = char_len;
offset += sym.n;
sym.prev = index - 1;
Expand Down Expand Up @@ -7317,7 +7316,7 @@ static std::vector<llama_grammar_candidate> llama_grammar_reject_candidates_for_
std::vector<llama_grammar_candidate> rejects;

if (stack.empty()) {
for (auto tok : candidates) {
for (auto const & tok : candidates) {
if (*tok.code_points != 0 || tok.partial_utf8.n_remain != 0) {
rejects.push_back(tok);
}
Expand All @@ -7328,7 +7327,7 @@ static std::vector<llama_grammar_candidate> llama_grammar_reject_candidates_for_
const llama_grammar_element * stack_pos = stack.back();

std::vector<llama_grammar_candidate> next_candidates;
for (auto tok : candidates) {
for (auto const & tok : candidates) {
if (*tok.code_points == 0) {
// reached end of full codepoints in token, reject iff it ended in a partial sequence
// that cannot satisfy this position in grammar
Expand All @@ -7354,7 +7353,7 @@ static std::vector<llama_grammar_candidate> llama_grammar_reject_candidates_for_
llama_grammar_advance_stack(rules, stack_after, next_stacks);

auto next_rejects = llama_grammar_reject_candidates(rules, next_stacks, next_candidates);
for (auto tok : next_rejects) {
for (auto const & tok : next_rejects) {
rejects.push_back({ tok.index, tok.code_points - 1, tok.partial_utf8 });
}

Expand Down

0 comments on commit c6bdce2

Please sign in to comment.