mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
tools/vision: Pascal P100 (compute capability 6.0) takes our picture reader under auto, also with F16 reader files
Until now, under `auto` a cc 6.0 card used llama.cpp's reader for F16 reader files (Qwen3.6, Unsloth's Qwen3.8 F16 file) at 1,024 picture tokens or fewer, because ours is slower there. It now uses our reader, as it already did for BF16 files and above 1,024 tokens. This follows the owner's rule of 11-11: our own code is the default where its accuracy gates pass, even where it is somewhat slower. P100, Qwen3.6 F16 reader file, 18 pictures, against the x86 llama.cpp CPU references: - ours: rule 1 0.999865 / 0.999969 (min / mean), smallest single token 0.9962; - llama.cpp's GPU reader: 0.982913 / 0.994036, single tokens down to 0.19. - time: 1,064 / 263 / 194 ms against 916 / 224 / 160 ms at 1,024 / 350 / 260 tokens. llama.cpp's reader stays selectable through the Picture reader setting (STRATA_VISION_TOWER=mtmd) and stays the start fallback. Pascal 6.1 / 6.2 (GTX 10xx, Jetson TX2) are not measured. They keep llama.cpp's reader up to the default limit, as before. The unit test lines in test_gguf_geometry.cpp now match the new rule. The reason the reader gives on 6.1 / 6.2 says "not measured".
This commit is contained in:
1 parent
ba11522ea2
commit
865d3ed4d1
3 files changed
+13
-14
No files matched your search
@@ -38,9 +38,9 @@ static uint16_t f32_to_f16(float f) { // good enough for the values used here
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// --- 0. the GPU classes where `--tower auto` keeps mtmd (vit_gpu.h) ---
|
||||
for (int mt : {0, 300, 1024}) { // at or below the default limit: the speed rule (Pascal keeps mtmd, except cc 6.0 with BF16 matrices)
|
||||
CHECK(vit_gpu_slower_nvidia(6, 0, false, mt) && vit_gpu_slower_nvidia(6, 1, false, mt) && vit_gpu_slower_nvidia(6, 1, true, mt) && vit_gpu_slower_nvidia(6, 2, true, mt));
|
||||
CHECK(!vit_gpu_slower_nvidia(6, 0, true, mt));
|
||||
for (int mt : {0, 300, 1024}) { // at or below the default limit: Pascal 6.1 / 6.2 keep mtmd (not measured); cc 6.0 takes ours with F16 and BF16 files
|
||||
CHECK(vit_gpu_slower_nvidia(6, 1, false, mt) && vit_gpu_slower_nvidia(6, 1, true, mt) && vit_gpu_slower_nvidia(6, 2, false, mt) && vit_gpu_slower_nvidia(6, 2, true, mt));
|
||||
CHECK(!vit_gpu_slower_nvidia(6, 0, true, mt) && !vit_gpu_slower_nvidia(6, 0, false, mt));
|
||||
CHECK(!vit_gpu_slower_nvidia(5, 2, false, mt) && !vit_gpu_slower_nvidia(7, 0, false, mt) && !vit_gpu_slower_nvidia(8, 6, true, mt) && !vit_gpu_slower_nvidia(12, 0, false, mt));
|
||||
}
|
||||
for (int mt : {1025, 4096, 16384}) { // above it: ours on every CUDA class
|
||||
|
||||
@@ -652,8 +652,7 @@ bool VitGpu::prefer_mtmd(bool bf16_matrices, int max_tokens, std::string& why) {
|
||||
cudaDeviceProp p;
|
||||
if (cudaGetDeviceProperties(&p, 0) != cudaSuccess) { (void) cudaGetLastError(); return false; }
|
||||
if (vit_gpu_slower_nvidia(p.major, p.minor, bf16_matrices, max_tokens)) {
|
||||
why = "compute capability " + std::to_string(p.major) + "." + std::to_string(p.minor) + " (Pascal)" + (bf16_matrices ? "" : " with F16 matrices") +
|
||||
": the own GPU tower is slower than mtmd there";
|
||||
why = "compute capability " + std::to_string(p.major) + "." + std::to_string(p.minor) + " (Pascal): the own GPU tower is not measured there, mtmd stays";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -21,17 +21,18 @@ namespace strata_vit {
|
||||
struct VitGpuImpl;
|
||||
|
||||
// The GPU classes where this tower is known to be slower than mtmd's GPU reader (VitGpu::prefer_mtmd uses these; pure functions, so the tests need no GPU).
|
||||
// NVIDIA Pascal (compute capability 6.x): no tensor cores; mtmd's products of F16 matrices accumulate in F16 at twice the float32 rate, ours in float32 (an
|
||||
// F16-accumulating variant of ours was as fast but missed rule 1: 0.9972), so with F16 matrices (Qwen3.6) ours stays slower (P100: at best 1.10 of mtmd-GPU,
|
||||
// RESULTS-OWN-3V.md 16.1). With BF16 matrices (Qwen3.8) mtmd multiplies in float32 too, and ours (BF16 held as F16, the larger score chunk) passes the whole
|
||||
// gate on a P100 (cc 6.0: 0.31 to 0.99 of mtmd-GPU's time, 16.1). Other Pascal chips (6.1, 6.2: GTX 10xx, Jetson TX2) are not measured: mtmd stays there.
|
||||
// NVIDIA Pascal, compute capability 6.0 (P100): our tower is the default under auto for F16 and BF16 reader files alike (owner 11-11: our own code is the
|
||||
// default where its accuracy gates pass, even where it is somewhat slower). P100, 1,024-token picture: Qwen3.8 BF16 1,068 against mtmd-GPU's 1,073 ms; Qwen3.6
|
||||
// F16 1,064 against 916 ms (mtmd's F16 products sum in F16 at twice the float32 rate, ours in float32), while ours stays at rule 1 0.999865 against mtmd-CPU
|
||||
// where mtmd-GPU reads 0.982913 (RESULTS-OWN-3V.md 16.1, PART G). Other Pascal chips (6.1, 6.2: GTX 10xx, Jetson TX2) are not measured: F16 arithmetic runs
|
||||
// at a small fraction of the float32 rate there, so the comparison may differ, and mtmd stays there up to the default limit.
|
||||
// Above the default GPU limit of 1,024 image tokens the speed rule gives way to correctness: mtmd's GPU reader drifts from mtmd's CPU path as pictures
|
||||
// grow (global cosine 0.983 at 2,116 tokens, 0.81 to 0.83 at 16,384 on the A4000, RTX PRO 5000 and P100), ours stays at 0.9996 to 0.99998 (RESULTS-OWN-3V.md
|
||||
// 16.7), so a reader started with --max-tokens above 1,024 takes our tower on every CUDA class, however slow (P100 at 16,384 tokens: 196.6 s against 129.0 s).
|
||||
// max_tokens 0 (not given) counts as the default.
|
||||
constexpr int kVitGpuDefaultLimit = 1024;
|
||||
inline bool vit_gpu_slower_nvidia(int cc_major, int cc_minor, bool bf16_matrices, int max_tokens) {
|
||||
return max_tokens <= kVitGpuDefaultLimit && cc_major == 6 && !(cc_minor == 0 && bf16_matrices);
|
||||
inline bool vit_gpu_slower_nvidia(int cc_major, int cc_minor, bool /*bf16_matrices*/, int max_tokens) {
|
||||
return max_tokens <= kVitGpuDefaultLimit && cc_major == 6 && cc_minor != 0;
|
||||
}
|
||||
// AMD gfx1151 (Strix Halo, Radeon 8060S) takes our tower under `auto` (owner 11-11: "For Strix - use our reader, even if its a bit slower ... Our priority is to
|
||||
// get off ggml and llama.cpp"). It is slower there: the ROCm package's rocBLAS ships only its generic "fallback" Tensile kernels for gfx1151 (Windows, Strix:
|
||||
@@ -53,9 +54,8 @@ public:
|
||||
// True when this build has a GPU backend and a device to run it on; `why` says what is missing.
|
||||
static bool available(std::string& why);
|
||||
|
||||
// True on a GPU class where this tower is known to be slower than mtmd's GPU reader, so `--tower auto` keeps mtmd there (`--tower own` still runs
|
||||
// this tower): NVIDIA Pascal (compute capability 6.x: no tensor cores; mtmd's F16 products accumulate in F16 at twice the float32 rate, ours in float32;
|
||||
// measured on a P100, RESULTS-OWN-3V.md 12.1). `why` says which.
|
||||
// True on a GPU class where `--tower auto` keeps mtmd (`--tower own` still runs this tower): NVIDIA Pascal 6.1 / 6.2 up to the default limit (not
|
||||
// measured; see vit_gpu_slower_nvidia), Windows HIP cards other than gfx1151 (not measured). `why` says which.
|
||||
static bool prefer_mtmd(bool bf16_matrices, int max_tokens, std::string& why); // bf16_matrices: the mmproj's layer matrices are BF16; max_tokens: --max-tokens (0: not given)
|
||||
|
||||
// Uploads the weights to `device` and sizes the work buffers for pictures of up to `max_patches` patches (grown by encode when a picture
|
||||
|
||||
Reference in new issue
Block a user