MCPcopy Create free account
hub / github.com/Niko1221/Strata / main

Function main

engine/tests/quant/quant_parity.cpp:637–790  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635} // namespace
636
637int main(int argc, char** argv) {
638 int rows = kGoldenRows;
639 const char* only = nullptr;
640 std::string golden_path = STRATA_QUANT_GOLDEN_FILE, write_golden;
641 bool regen_check = false;
642 for (int i = 1; i < argc; ++i) {
643 if (!std::strcmp(argv[i], "--rows") && i + 1 < argc) rows = std::atoi(argv[++i]);
644 else if (!std::strcmp(argv[i], "--type") && i + 1 < argc) only = argv[++i];
645 else if (!std::strcmp(argv[i], "--verbose")) g_verbose = true;
646 else if (!std::strcmp(argv[i], "--golden") && i + 1 < argc) golden_path = argv[++i];
647 else if (!std::strcmp(argv[i], "--dump-group") && i + 1 < argc) g_dump_key = argv[++i];
648 else if (!std::strcmp(argv[i], "--write-golden") && i + 1 < argc) write_golden = argv[++i];
649 else if (!std::strcmp(argv[i], "--regen-check")) regen_check = true;
650 else {
651 std::printf("quant_parity: unknown argument %s\n", argv[i]);
652 return 2;
653 }
654 }
655 if (!digest_selftest()) {
656 std::printf("quant_parity: FAIL: the golden digest (FNV-1a 64) does not give its test vectors\n");
657 return 1;
658 }
659 if (regen_check && !kRegenHere) {
660 std::printf("quant_parity --regen-check: SKIPPED: the golden lines are made by GCC 13.x (family gcc) and MSVC 19.4x (family msvc) on x86; this is %s\n",
661 compiler_name().c_str());
662 return 77;
663 }
664 ggml_cpu_init();
665 const sq::Arith ar = oracle_arith();
666 g_flavour = sq::arith_name(ar);
667 std::printf("quant_parity: oracle flavour %s (ggml avx=%d avx2=%d fma=%d f16c=%d avx512=%d), layer best isa %s, default contract %s, compiler %s\n",
668 sq::arith_name(ar), ggml_cpu_has_avx(), ggml_cpu_has_avx2(), ggml_cpu_has_fma(), ggml_cpu_has_f16c(), ggml_cpu_has_avx512(),
669 sq::isa_name(sq::best_isa()), sq::arith_name(sq::default_arith()), compiler_name().c_str());
670#if defined(__aarch64__)
671 // The Neon contract is ggml-cpu's arm64 flavour with the dot product extension (the shipped STRATA_PORTABLE build and the Mac's native build). A ggml-cpu without it
672 // (GCC's -mcpu=native on the Spark's mixed X925 + A725 cores resolves to plain armv8-a) runs other code, and one with SVE other branches of the Q4_0 / Q8_0 /
673 // K-quant dots: those flavours are not the contract. The first is skipped, the second is run for information and its differences do not fail the test.
674 if (!ggml_cpu_has_dotprod()) {
675 std::printf("quant_parity: SKIPPED, this ggml-cpu is built without the dot product extension (not the Neon contract)\n");
676 return 0;
677 }
678 if (ggml_cpu_has_sve()) {
679 g_info_only = true;
680 std::printf("quant_parity: this ggml-cpu is built with SVE (not the Neon contract): differences are reported, not failed\n");
681 }
682#endif
683 const bool have_golden = !golden_path.empty() && load_golden(golden_path, g_flavour) && !g_golden.empty();
684 g_golden_leg = have_golden && rows == kGoldenRows && write_golden.empty();
685 const char* strict_env = std::getenv("QUANT_PARITY_LIVE_STRICT");
686 g_live_strict = !g_golden_leg || (strict_env != nullptr && std::strcmp(strict_env, "0") != 0 && *strict_env != '\0');
687 if (regen_check && !have_golden) {
688 std::printf("quant_parity --regen-check: FAIL: no golden lines for flavour %s in %s\n", g_flavour.c_str(), golden_path.c_str());
689 return 1;
690 }
691 if (regen_check && rows != kGoldenRows) {
692 std::printf("quant_parity --regen-check: FAIL: the golden file holds --rows %d\n", kGoldenRows);
693 return 1;
694 }

Callers

nothing calls this directly

Calls 15

digest_selftestFunction · 0.85
compiler_nameFunction · 0.85
arith_nameFunction · 0.85
default_arithFunction · 0.85
test_fp16Function · 0.85
test_dequantFunction · 0.85
test_boundaryFunction · 0.85
test_actFunction · 0.85
test_dotFunction · 0.85
golden_lines_of_this_runFunction · 0.85
golden_forFunction · 0.85
oracle_arithFunction · 0.70

Tested by

no test coverage detected