Skip to content

Commit afa2ea5

Browse files
authored
whisper : set bench data for each iteration (#3812)
* whisper : set bench data for each iteration This commit updates whisper_bench_ggml_mul_mat_str to intialize the tensors data for each iteration. The motivation for this is that is currently possible for a previous run's results, F32 values, to leak into the next run. When it is time for the F16 iteration then F32 results can cause NaN values to appear in the tensor values causing the F16 iteration to fail. Refs:https://github.com/ggml-org/whisper.cpp/actions/runs/25901678402/job/76152894644?pr=3735 * ci : set GGML_NATIVE=OFF if x86_64 This commit sets GGML_NATIVE=OFF for x86_64 architectures. The motivation for this is to try to get CI to pass and the theory is that the libggml-cpu.so library in the ccache might have been built by a runner that supports a different instruction set. When another runner that does not support that instruction set tries to use it, it will fail with a segmentation fault. I'm not sure about this yet but going to try this out and if it does not work I'll ssh into the runner to debug further.
1 parent 47b9eb3 commit afa2ea5

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

ci/run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ fi
5050

5151
CMAKE_EXTRA="-DWHISPER_FATAL_WARNINGS=ON"
5252

53+
if [[ "$(uname -m)" == "x86_64" ]]; then
54+
CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_NATIVE=OFF"
55+
fi
56+
5357
if [ ! -z ${GG_BUILD_METAL} ]; then
5458
CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_METAL=ON"
5559
fi

src/whisper.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8258,9 +8258,6 @@ WHISPER_API const char * whisper_bench_ggml_mul_mat_str(int n_threads) {
82588258
// when F16 is used, there is an extra work buffer of size N*N*sizeof(float)
82598259
std::vector<uint8_t> buf(3llu*N_max*N_max*sizeof(float) + 3*ggml_tensor_overhead() + ggml_graph_overhead());
82608260

8261-
// put a bunch of random data in the buffer
8262-
for (size_t i = 0; i < buf.size(); i++) buf[i] = i;
8263-
82648261
for (int j = 0; j < (int) sizes.size(); j++) {
82658262
int n_q4_0 = 0;
82668263
int n_q4_1 = 0;
@@ -8304,6 +8301,15 @@ WHISPER_API const char * whisper_bench_ggml_mul_mat_str(int n_threads) {
83048301
struct ggml_tensor * a = ggml_new_tensor_2d(ctx0, wtype, N, N);
83058302
struct ggml_tensor * b = ggml_new_tensor_2d(ctx0, GGML_TYPE_F32, N, N);
83068303

8304+
// set tensor data after allocation so previous iteration results don't corrupt it.
8305+
{
8306+
uint8_t * a_data = (uint8_t *) a->data;
8307+
for (size_t ii = 0; ii < ggml_nbytes(a); ii++) a_data[ii] = ii & 0x3F;
8308+
8309+
uint8_t * b_data = (uint8_t *) b->data;
8310+
for (size_t ii = 0; ii < ggml_nbytes(b); ii++) b_data[ii] = ii & 0x3F;
8311+
}
8312+
83078313
struct ggml_tensor * c = ggml_mul_mat(ctx0, a, b);
83088314

83098315
struct ggml_cgraph * gf = ggml_new_graph(ctx0);

0 commit comments

Comments
 (0)