diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-06-10 15:31:32 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-14 08:27:03 +0200 |
| commit | 5f73e5dc901f47cda6b2a26eea31cf9fc6178bc7 (patch) | |
| tree | 42538d32a09d9bdc560c0ff4f5a7d74fa140ca7a /tests/test_bf16_model.c | |
| parent | b1742da3868a3594b4e78be64e1412356d95dbd7 (diff) | |
| download | ffwd-5f73e5dc901f47cda6b2a26eea31cf9fc6178bc7.tar.gz ffwd-5f73e5dc901f47cda6b2a26eea31cf9fc6178bc7.zip | |
tests: threaded kernel paths, bf16 widen, shard payload accounting
Diffstat (limited to 'tests/test_bf16_model.c')
| -rw-r--r-- | tests/test_bf16_model.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_bf16_model.c b/tests/test_bf16_model.c index 75d3309..392f040 100644 --- a/tests/test_bf16_model.c +++ b/tests/test_bf16_model.c @@ -69,6 +69,30 @@ int main(void) { return 1; } + /* Sequences longer than 16 tokens take the widen-to-F32 weight path + * (linear_nobias_weight); parity must hold there too. */ + enum { LONG_N = 24 }; + int long_ids[LONG_N]; + for (int i = 0; i < LONG_N; i++) long_ids[i] = (i % 14) + 1; + if (pplx_model_embed_into(mf32, wf32, long_ids, LONG_N, a) != 0 || + pplx_model_embed_into(mbf16, wbf16, long_ids, LONG_N, b) != 0) { + fprintf(stderr, "long-sequence embedding failed\n"); + return 1; + } + float long_diff = 0.0f; + for (int i = 0; i < dim; i++) { + if (!isfinite(a[i]) || !isfinite(b[i])) { + fprintf(stderr, "non-finite long-sequence value\n"); + return 1; + } + float d = fabsf(a[i] - b[i]); + if (d > long_diff) long_diff = d; + } + if (long_diff > 2e-5f) { + fprintf(stderr, "bad widen-path parity: max_diff=%.9g\n", long_diff); + return 1; + } + printf("ok: bf16 model parity dim=%d max_abs_diff=%.9g norm=%.9g\n", dim, max_diff, norm); |
