mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
split: the golden dot test draws its q8_1 scale and sum in a fixed order (same inputs under g++ and clang)
The split tools built each q8_1 block's ds with two random draws as the two arguments of one call:
b.ds = make_half2(__float2half((float) (rng() % 1000) / 500.0f), __float2half((float) ((int) (rng() % 200) - 100)));
C++ leaves the order of those arguments unspecified: g++ (the host compiler under nvcc) drew s first, clang (HIP) d first, so a HIP
build of split_qdot_golden saw other inputs than the ones qdot_golden.txt was written from (all 176 groups "inputs differ"). Every other
input byte, the struct sizes and host __float2half (checked against a round-to-nearest-even reference over all 2^32 floats) were equal
in both builds. Now s is drawn first, then d, into named locals - g++'s order, so qdot_golden.txt and the CUDA inputs are unchanged:
- src/split/tools/qdot_golden.cuh:83 (make_inputs, the generator of the golden file and of the check)
- src/split/tools/qdot_test.cu:100 (the oracle test's own copy of the draws)
- src/split/tools/iqdot_test.cu:63 (the same draws)
Test code only; no engine source changes.
Checks:
- RTX PRO 5000 (sm_120): split_qdot_test --write-golden output byte-identical to the committed qdot_golden.txt; 0 of 704,512 dots
differ from ggml; --regen-golden equal; split_qdot_golden 0 of 176 groups differ.
- RTX A4000 (sm_86): the same four results.
- AMD Radeon AI PRO R9700 (gfx1201, HIP build of split_qdot_golden): 0 of 176 groups differ from the unchanged file's cuda lines, so the
HIP dots equal the CUDA dots bit for bit and the file needs no hip line; with one Q8_0 dot's arithmetic changed
(d8_0*d8_1*sumi -> d8_0*(d8_1*sumi)) the check fails (rc 1, Q8_0 groups differ, Q4_0 / Q5_1 still equal).
- Not run: the Windows MSVC build of these files (owed).
This commit is contained in:
1 parent
9495b503ba
commit
9e19948ff9
3 files changed
+13
-3
No files matched your search
@@ -60,7 +60,10 @@ bool run(const char* name, int nblocks, unsigned seed) {
|
||||
std::vector<block_q8_1> y((size_t) nblocks * 8);
|
||||
for (auto& b : y) {
|
||||
for (int i = 0; i < 32; ++i) b.qs[i] = (int8_t) (int) (rng() % 255 - 127);
|
||||
b.ds = make_half2(__float2half((float) (rng() % 1000) / 500.0f), __float2half((float) ((int) (rng() % 200) - 100)));
|
||||
// s drawn first, then d (as qdot_golden.cuh make_inputs: a fixed order on every compiler)
|
||||
const float s = (float) ((int) (rng() % 200) - 100);
|
||||
const float d = (float) (rng() % 1000) / 500.0f;
|
||||
b.ds = make_half2(__float2half(d), __float2half(s));
|
||||
}
|
||||
char* dw;
|
||||
block_q8_1* dy;
|
||||
|
||||
@@ -80,7 +80,11 @@ inline Inputs make_inputs(int B, const std::vector<int>& h16, int nblocks, int q
|
||||
in.y = std::vector<block_q8_1>((size_t) nblocks * (qk / QK8_1)); // (constructed at its size: block_q8_1 has no copy constructor, so no resize)
|
||||
for (auto& b : in.y) {
|
||||
for (int i = 0; i < 32; ++i) b.qs[i] = (int8_t) (int) (rng() % 255 - 127);
|
||||
b.ds = make_half2(__float2half((float) (rng() % 1000) / 500.0f), __float2half((float) ((int) (rng() % 200) - 100)));
|
||||
// s drawn first, then d, in named locals: as two arguments of one call their order was unspecified (g++ under nvcc drew s first,
|
||||
// clang under HIP d first); this is g++'s order, so qdot_golden.txt is unchanged
|
||||
const float s = (float) ((int) (rng() % 200) - 100);
|
||||
const float d = (float) (rng() % 1000) / 500.0f;
|
||||
b.ds = make_half2(__float2half(d), __float2half(s));
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,10 @@ bool run(const char* name, int B, std::vector<int> h16, int nblocks, unsigned se
|
||||
std::vector<block_q8_1> y((size_t) nblocks * (qk / QK8_1));
|
||||
for (auto& b : y) {
|
||||
for (int i = 0; i < 32; ++i) b.qs[i] = (int8_t) (int) (rng() % 255 - 127);
|
||||
b.ds = make_half2(__float2half((float) (rng() % 1000) / 500.0f), __float2half((float) ((int) (rng() % 200) - 100)));
|
||||
// s drawn first, then d (qdot_golden.cuh make_inputs: the same draws, a fixed order on every compiler)
|
||||
const float s = (float) ((int) (rng() % 200) - 100);
|
||||
const float d = (float) (rng() % 1000) / 500.0f;
|
||||
b.ds = make_half2(__float2half(d), __float2half(s));
|
||||
}
|
||||
char* dw;
|
||||
block_q8_1* dy;
|
||||
|
||||
Reference in new issue
Block a user