Skip to content

Commit 38e3148

Browse files
Windows test
1 parent 4ab7bb7 commit 38e3148

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ jobs:
190190
if: ${{ matrix.build != 'avx512' || env.HAS_AVX512F == '1' }} # Test AVX-512 only when possible
191191
run: |
192192
cd build
193-
ctest -C Release --verbose
193+
ctest -C Release --verbose --output-on-failure
194194
195195
- name: Get commit hash
196196
id: commit

tests/test-sampling.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#include "llama.h"
2-
#include <assert.h>
3-
#include <math.h>
2+
#include <cassert>
3+
#include <cmath>
44
#include <numeric>
55
#include <cassert>
66
#include <iostream>
77
#include <vector>
88
#include <algorithm>
99

10-
#undef assert
11-
#define assert(__expr) do { if (!(__expr)) { printf("%s:%d (%s) %s\n", __FILE__, __LINE__, __func__, #__expr); exit(1); } } while(0)
1210

1311
void dump(const llama_token_data_array * candidates) {
1412
for (size_t i = 0; i < candidates->size; i++) {
@@ -22,19 +20,28 @@ void dump(const llama_token_data_array * candidates) {
2220
void test_top_k(const std::vector<float> & probs,
2321
const std::vector<float> & expected_probs,
2422
int k) {
23+
printf("%s:%d (%s)\n", __FILE__, __LINE__, __func__);
24+
fflush(stdout);
2525
size_t n_vocab = probs.size();
2626
std::vector<llama_token_data> candidates;
2727
candidates.reserve(n_vocab);
2828
for (llama_token token_id = 0; token_id < (llama_token)n_vocab; token_id++) {
29-
float logit = log(probs[token_id]);
29+
printf("%s:%d (%s) token_id: %d\n", __FILE__, __LINE__, __func__, token_id);
30+
fflush(stdout);
31+
float logit = std::log(probs[token_id]);
3032
candidates.emplace_back(llama_token_data{token_id, logit, 0.0f});
3133
}
34+
printf("%s:%d (%s)\n", __FILE__, __LINE__, __func__);
35+
fflush(stdout);
3236

3337
llama_token_data_array candidates_p = { candidates.data(), candidates.size(), false };
38+
printf("%s:%d (%s)\n", __FILE__, __LINE__, __func__);
39+
fflush(stdout);
3440
llama_sample_softmax(nullptr, &candidates_p);
35-
// DUMP(&candidates_p);
41+
DUMP(&candidates_p);
3642
llama_sample_top_k(nullptr, &candidates_p, k);
37-
// DUMP(&candidates_p);
43+
DUMP(&candidates_p);
44+
fflush(stdout);
3845

3946
assert(candidates_p.size == expected_probs.size());
4047
for (size_t i = 0; i < candidates_p.size; i++) {
@@ -57,9 +64,9 @@ void test_top_p(const std::vector<float> & probs,
5764

5865
llama_token_data_array candidates_p = { candidates.data(), candidates.size(), false };
5966
llama_sample_softmax(nullptr, &candidates_p);
60-
// DUMP(&candidates_p);
67+
DUMP(&candidates_p);
6168
llama_sample_top_p(nullptr, &candidates_p, p);
62-
// DUMP(&candidates_p);
69+
DUMP(&candidates_p);
6370

6471
assert(candidates_p.size == expected_probs.size());
6572
for (size_t i = 0; i < candidates_p.size; i++) {
@@ -80,9 +87,9 @@ void test_tfs(const std::vector<float> & probs,
8087
}
8188

8289
llama_token_data_array candidates_p = { candidates.data(), candidates.size(), false };
83-
// DUMP(&candidates_p);
90+
DUMP(&candidates_p);
8491
llama_sample_tail_free(nullptr, &candidates_p, z);
85-
// DUMP(&candidates_p);
92+
DUMP(&candidates_p);
8693

8794
assert(candidates_p.size == expected_probs.size());
8895
for (size_t i = 0; i < candidates_p.size; i++) {
@@ -103,9 +110,9 @@ void test_typical(const std::vector<float> & probs,
103110
}
104111

105112
llama_token_data_array candidates_p = { candidates.data(), candidates.size(), false };
106-
// DUMP(&candidates_p);
113+
DUMP(&candidates_p);
107114
llama_sample_typical(nullptr, &candidates_p, p);
108-
// DUMP(&candidates_p);
115+
DUMP(&candidates_p);
109116

110117
assert(candidates_p.size == expected_probs.size());
111118
for (size_t i = 0; i < candidates_p.size; i++) {
@@ -172,6 +179,8 @@ void test_frequency_presence_penalty(
172179
}
173180

174181
int main(void) {
182+
printf("main\n");
183+
fflush(stdout);
175184
test_top_k({0.1, 0.2, 0.3, 0.4}, {0.4}, 1);
176185
test_top_k({0.1, 0.2, 0.3, 0.4}, {0.4, 0.3, 0.2}, 3);
177186

0 commit comments

Comments
 (0)