diff --git a/Makefile b/Makefile index facaaf8..f68b9c0 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ PYTHON ?= python3 # Optional Linux FastText facade; retain the original binary/library targets. fasttext-native: mkdir -p build - $(CC) -std=c11 -O2 -fPIC -c native/meft_rows.c -o build/meft_rows_fasttext.o + $(CC) -std=c11 -O3 -fPIC -c native/meft_rows.c -o build/meft_rows_fasttext.o $(CXX) $(CXXFLAGS) -O2 -DMEFT_NATIVE_FASTTEXT -Isrc -Inative $(INCLUDES) $(addprefix src/,$(OBJS:.o=.cc)) native/fasttext_bundle.cc src/main.cc build/meft_rows_fasttext.o $(LIBS) -lz -o build/fasttext-native # Optional original-algorithm bridge; bundled archives require Linux x86-64. @@ -36,8 +36,8 @@ NATIVE_EXT ?= so NATIVE_CODEC_FLAGS ?= native: mkdir -p build - $(CC) -std=c11 -O2 -Wall -Wextra -Werror -fPIC $(NATIVE_SHARED) native/meft_rows.c -lz $(NATIVE_CODEC_FLAGS) -o build/libmeft_rows.$(NATIVE_EXT) - $(CC) -std=c11 -O2 -Wall -Wextra -Werror -Inative examples/native_gather.c native/meft_rows.c -lz $(NATIVE_CODEC_FLAGS) -o build/native_gather + $(CC) -std=c11 -O3 -Wall -Wextra -Werror -fPIC $(NATIVE_SHARED) native/meft_rows.c -lz $(NATIVE_CODEC_FLAGS) -o build/libmeft_rows.$(NATIVE_EXT) + $(CC) -std=c11 -O3 -Wall -Wextra -Werror -Inative examples/native_gather.c native/meft_rows.c -lz $(NATIVE_CODEC_FLAGS) -o build/native_gather opt: CXXFLAGS += -O1 -funroll-loops opt: fasttext $(LIBNAME).a index cut_ngram print_ngrams bench_ftindex diff --git a/docs/guides/native_ngram_memory.md b/docs/guides/native_ngram_memory.md index 05af07c..7bd16ad 100644 --- a/docs/guides/native_ngram_memory.md +++ b/docs/guides/native_ngram_memory.md @@ -94,6 +94,15 @@ tables retain grouped reads. `NativeRows.last_xor_bytes` reports previous-row XOR reconstruction separately from complete stream decompression; full-block cache fills always reconstruct every row. +`NativeRows.embedding_bag_array(ids, offsets, dtype="float32", mode="mean")` +provides NumPy-only ragged pooling. Offsets include the terminal ID count; +FP64 accumulation returns FP32 features. Default FP32 vectorized pooling is +1.71–1.80× faster per document and 2.98–3.12× at batch 32 on the measured raw +tables ([results and ablations](../../evidence/native_bag_vectorization_20261116/README.md)). +For lower temporary memory, open with `raw_bag_fusion=True`; on all-raw tables +this avoids the row matrix, with a throughput tradeoff. Compressed reads retain +bounded staging. `last_bag_staging_bytes` reports row-matrix capacity, not RSS. + ## Native layout and construction `MEFTNAT1` is a little-endian binary file: a versioned header, an optional diff --git a/evidence/README.md b/evidence/README.md index d0fe363..6a0dbb4 100644 --- a/evidence/README.md +++ b/evidence/README.md @@ -53,6 +53,7 @@ here: links in locked READMEs still point to them, and they forward to | [Large FP16/INT8 capacity](quantized_capacity_evidence_20261031/README.md) | FP16 native saves 52.29% vs raw FP32; INT8 native expands vs raw INT8 | | [Host query profile on AG News](host_query_profile_20261112/README.md) | Time is block decompression. On the twelve original tables, dedup without compression saves 85.0–85.8% (vs 85.7–86.6% with Zstd) and the GPU host path runs 1.09–1.23× raw with identical logits; on uniform-init tables raw is best. `ngram-store plan` predicts these layout sizes exactly and reports how the duplicates are distributed | | [Direct native gathers](native_direct_gather_20261115/README.md) | All-raw tables bypass query sorting: 1.57–1.65× faster paired CPU gathers on existing AG News/DBpedia seed-3 tables, with unchanged original code bytes. Conditional XOR prefix reconstruction reduces work, but the eight saved Qwen controls show about 1.00× speed | +| [Vectorized NumPy/native bags](native_bag_vectorization_20261116/README.md) | Default FP32 pooling is 1.71–1.80× faster for individual documents and 2.98–3.12× for batches of 32 on the existing raw AG News/DBpedia tables. Source features match byte-for-byte. Optional raw fusion removes a 2 MiB row matrix but is slower than staged vectorization; Zstd remains decode-bound | | [Token-level n-grams do not transfer](token_ngram_duplicates_20261115/README.md) | WikiText-103 with the Qwen3 tokenizer, 124M tokens, 512-token windows: order 4 repeats 88.35%, but 85% of keys occur in one window and collapse there. Among keys seen in several windows deduplication saves 27.2%, and that falls to 10.5% at a count threshold of 3. Zero initialization only; no training involved | | [Native query/cache controls](native_query_evidence_20261030/README.md) · [decoded-block cache](native_cache_20261022.md) ([data](native_cache_evidence_20261022/)) | Cache sizing and hit/miss behaviour | | [XOR blocks](native_xor_compression_20261020.md) ([data](native_xor_evidence_20261020/)) · [streaming export](streaming_export_20261021.md) ([data](export_evidence_20261021/)) · [first native pilots](native_ngram_evidence_20261018/) | Codec and export-path development | diff --git a/evidence/native_bag_vectorization_20261116/README.md b/evidence/native_bag_vectorization_20261116/README.md new file mode 100644 index 0000000..5aaa53e --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/README.md @@ -0,0 +1,121 @@ +# Vectorized native embedding bags, with optional zero-row-staging fusion + +The engine now exposes `NativeRows.embedding_bag_array`: a NumPy-only ragged +sum/mean API. FP32 has a dedicated dimension loop that GCC vectorizes without +changing original-row accumulation order, FP64 products/sums or final FP32 +conversion. FP16/BF16 retain the existing decoder. Weighted native bags share +the optimization; their existing sum-only semantics remain unchanged. + +The default retains bounded row staging because it is faster. All-raw tables +can opt into direct mmap accumulation with `raw_bag_fusion=True`, eliminating +the row matrix while retaining original-ID forwarding and chunk/block counters. +Compressed tables keep chunk staging. No table formats or stored vectors change. + +## Default performance on frozen trained tables + +Paired **public NumPy/C mean-pooling calls**, including input validation and C +reduction. Excludes tokenization, classifier head, GPU transfers and full models. + +| Table, seed 3 | Original rows | Documents/call | Baseline p50 (µs) | Default vectorized p50 (µs) | Paired geometric speed ratio | +| --- | ---: | ---: | ---: | ---: | ---: | +| AG News, uniform | 6,989,612 | 1 | 116.16 | 67.68 | 1.71× | +| AG News, uniform | 6,989,612 | 32 | 2428.91 | 826.23 | 2.98× | +| AG News, zero | 6,989,612 | 1 | 114.27 | 65.87 | 1.73× | +| AG News, zero | 6,989,612 | 32 | 2370.31 | 769.23 | 3.12× | +| DBpedia, uniform | 34,050,161 | 1 | 134.11 | 73.48 | 1.80× | +| DBpedia, uniform | 34,050,161 | 32 | 2956.92 | 972.76 | 3.05× | +| DBpedia, zero | 34,050,161 | 1 | 136.10 | 75.36 | 1.77× | +| DBpedia, zero | 34,050,161 | 32 | 2922.80 | 954.64 | 3.07× | + +Both arms read the same existing uncompressed/deduplicated table and each output +is compared byte-for-byte with independently computed source FP64 mean features, +rounded to FP32. All checked features match. Uniform-init byte dedup expands the +table; its inclusion tests the kernel and does not recommend dedup over raw. + +- Models/data: the registered AG News/DBpedia classifiers, zero and uniform + initialization, seed 3; no retraining. 256 official test documents per dataset, + seed 20261112, original IDs and full lengths. OOV zero removed as in the + registered `StagedClassifier` protocol. Batches preserve document boundaries. +- Measurement: 2 warmup passes, 10 timed passes, 3 alternating paired rounds; + independent handles, preallocated outputs, zero native cache, chunk limit + 4096. p50 columns are medians of round p50s. Five CPU jobs ran on distinct + pinned cores. Ratios are descriptive, not confidence intervals or application + accuracy/latency claims. +- AMD EPYC 7713, Linux 5.4, Python 3.11.15, NumPy 2.2.6, PyTorch 2.11.0, GCC + 11.4.0, `-O3` without unsafe floating-point or architecture-specific flags. + Wheel and Makefile native builds use the same optimization level. + [Compiler diagnostics](tests/vectorization.log) confirm 16-byte vectorization. +- Source commit `4f6fa5a7a7c9e2eb42d5043784d39738150de23b`. + Existing CPU resources; no GPU, training or paid API. Energy/monetary costs + unmeasured. [Build and library hashes](build.json), [commands](run-status.json). + +## Memory preference and ablations + +Fusion alone (`f51f486`) saved row staging but measured **0.95–1.00×** speed. +Dedicated FP32 vectorization plus fusion (`854fd04`) improved the raw-table +calls, but an additional [same-vector-kernel comparison](fusion-ablation.json) +found staged reduction faster on both AG News batch-32 controls. Therefore the +final default is staged/vectorized; fusion is an explicit memory preference. +The comparison reused parent input hashes, rechecked original trace hashes and +compared every output against freshly read source features. + +On the checked batch-32 raw calls, fusion reduces the allocated row matrix from +**2,097,152 bytes to zero**. This counter excludes query indexes, FP64 accumulator, +output, caches and total RSS. It is not a total-process memory guarantee. +`last_bag_staging_bytes` reports the actual row-matrix allocation capacity. A +failed optional raw counter-index allocation can fall back to staged reading. + +The AG News zero-init Zstd batch-32 control stays about **1.01×** with the final +kernel; decompression still dominates. Both arms still stage 2 MiB. That control +uses 1 warmup, 3 repeats and 2 rounds. All earlier slow/no-gain results remain in +[raw/](raw/); [summary.json](summary.json) indexes all 27 timing cells. + +## Use without PyTorch + +```python +import numpy as np +from ngram_store import NativeRows + +with NativeRows("memory.native/table.men") as memory: + pooled = memory.embedding_bag_array( + np.array([1, 42, 1], dtype=np.uint64), + np.array([0, 2, 3], dtype=np.uint64), + dtype="float32", mode="mean", chunk_rows=4096, + ) # two original-ID bags, FP64 accumulation -> FP32 output + +# Prefer zero row-matrix allocation on all-raw tables: +with NativeRows("memory.native/table.men", raw_bag_fusion=True) as memory: + pooled = memory.embedding_bag_array([1, 42, 1], [0, 2, 3]) + assert memory.last_bag_staging_bytes == 0 +``` + +Offsets include the terminal ID count. Empty bags return zero. `padding_id` +excludes that original row from sums and mean denominators. Optional `out` +requires a writable contiguous FP32 array of `(bags, dim)`. Dtype strings are +`float32`, `float16`, `bfloat16`; the caller owns the stored dtype contract. +Existing row/gather APIs and compiled-library default loading remain compatible. +Opt-in fusion requires rebuilding the C library. The C setter is +`meft_rows_set_raw_bag_fusion(store, 1)`. + +## Verification and reproduction + +[Tests](tests/): 381 local tests passed (149 optional skips), 45 local native +passed (5 optional skips), and 56 remote native/PyTorch bag tests passed without +skips. Local/remote ASan+UBSan passed, including raw fusion on mutated artifacts. +An additional 45-test local native run with `-O3` passed (5 optional skips), +and a fresh Python 3.12 package loaded outside the checkout passed NumPy bag +and mode-switch checks without importing Torch. +Coverage includes all three dtypes, weights, padding, empty bags, forwarding, +odd dimensions, chunk boundaries, compressed caches, output reuse and errors. + +The general entry point is +[`tools/benchmark_native_bags.py`](../../tools/benchmark_native_bags.py); +[scripts/](scripts/) retain the exact existing-workspace launches and ablation. +The first two phases computed full table/code hashes. The final default run +explicitly inherited those immutable-input hashes from the parent vector run, +rechecked trace/metadata hashes and every source feature, and records parent +report hashes plus current file stats. It does not describe inherited hashes as +new full-file verification. Omitting `--hashes-from` recomputes full input hashes. + +Timing records are gzip-compressed to keep the checkout small. Tables, weights, +query arrays and corpora remain in the experiment workspace. diff --git a/evidence/native_bag_vectorization_20261116/build.json b/evidence/native_bag_vectorization_20261116/build.json new file mode 100644 index 0000000..9c823d9 --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/build.json @@ -0,0 +1,54 @@ +{ + "commit": "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "compiler": "cc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0\nCopyright (C) 2021 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions. There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n", + "compile": "cc -std=c11 -O3 -fPIC -shared native/meft_rows.c -lz FLAGS -o LIBRARY", + "flags": "-I/llm-align/duyimin/ngram-sparse-xor-20261115/include -DMEFT_USE_LZ4 -DMEFT_USE_ZSTD -DMEFT_USE_LIBDEFLATE -l:liblz4.so.1 -l:libzstd.so.1 -l:libdeflate.so.0", + "baseline_extra": "-DMEFT_DISABLE_RAW_BAG -DMEFT_DISABLE_FP32_BAG_VECTOR", + "headers_manifest": "/llm-align/duyimin/ngram-sparse-xor-20261115/results/build.json", + "files": { + "/llm-align/duyimin/ngram-direct-bags-20261116/runtime/native/meft_rows.c": { + "bytes": 46680, + "sha256": "254ff1e0452a670cd68b5fff4ec2e460376e252595b79de2af9fc766e8ae23e0" + }, + "/llm-align/duyimin/ngram-direct-bags-20261116/runtime/native/meft_rows.h": { + "bytes": 9336, + "sha256": "42a4e76dc37b7afc16eee5cbef579203576e20e09e1e920e693887b1ef621d60" + }, + "/llm-align/duyimin/ngram-direct-bags-20261116/runtime/tools/native_row_store.py": { + "bytes": 29450, + "sha256": "bd4db7acedadfdf7301246e036b5463350ef1bf1fa0462b8c545f5d91de52e49" + }, + "/llm-align/duyimin/ngram-direct-bags-20261116/runtime/tools/benchmark_native_bags.py": { + "bytes": 8358, + "sha256": "7331bca667d43b6234f83a28ee65963f9775d1bc6dd4cc262054803910ea121a" + }, + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/candidate-vector.so": { + "bytes": 38712, + "sha256": "b12cf651f8d1f10511890b1153da378ae61663be9ae85313557ada8b3d2d2fc7" + }, + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/staged-vector.so": { + "bytes": 38624, + "sha256": "d1089329d120a0aaf8fb5d4a93dbe77555c3f061372dbaf13c3fc1bdb1ac848a" + }, + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/candidate.so": { + "bytes": 38712, + "sha256": "b71226b8354c790a66ab174a6facb3d65a1402c28c4c85bcfeb110fb6c8eaca3" + }, + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/baseline-final.so": { + "bytes": 38680, + "sha256": "608950f28393173a759cb26db59e8ffd039aa8d0c97f2fea0bd1648be09f0e59" + }, + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/baseline.so": { + "bytes": 38624, + "sha256": "6f714590455aa49910d49f9f32930c70c4324c7dbb76576c0ea91e6b36985195" + }, + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/candidate-final.so": { + "bytes": 38768, + "sha256": "7fabbd7281029cbdb41b3c161005e4b2c982a0cd94e21e532ccef105471465e7" + }, + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/baseline-vector.so": { + "bytes": 38624, + "sha256": "6f714590455aa49910d49f9f32930c70c4324c7dbb76576c0ea91e6b36985195" + } + } +} \ No newline at end of file diff --git a/evidence/native_bag_vectorization_20261116/fusion-ablation.json b/evidence/native_bag_vectorization_20261116/fusion-ablation.json new file mode 100644 index 0000000..e5774f1 --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/fusion-ablation.json @@ -0,0 +1,1044 @@ +[ + { + "model": "ag_news-exact-zero-s3-lr10", + "direct_vs_staged_vector_speed_ratio": 0.9239940038437908, + "p50_us": { + "direct": 638.9645, + "staged_vector": 585.985 + }, + "samples_us": { + "direct": [ + 667.462, + 669.767, + 697.706, + 702.246, + 685.483, + 701.827, + 618.219, + 736.402, + 754.073, + 576.032, + 815.469, + 602.085, + 786.622, + 603.692, + 634.844, + 624.436, + 635.402, + 607.672, + 680.733, + 660.407, + 666.275, + 641.409, + 561.015, + 666.275, + 706.158, + 564.298, + 749.673, + 596.078, + 728.299, + 590.002, + 601.247, + 640.501, + 634.983, + 607.184, + 679.267, + 658.731, + 666.973, + 638.126, + 549.63, + 656.845, + 685.413, + 584.064, + 746.809, + 589.303, + 730.185, + 589.512, + 600.199, + 621.083, + 627.37, + 604.739, + 675.565, + 668.37, + 667.183, + 646.298, + 551.096, + 654.121, + 681.99, + 586.159, + 747.647, + 589.163, + 723.549, + 589.862, + 600.967, + 605.228, + 628.138, + 602.503, + 679.965, + 675.355, + 667.462, + 636.31, + 550.886, + 660.687, + 684.854, + 569.117, + 742.268, + 589.931, + 719.429, + 593.913, + 599.431, + 603.692, + 631.072, + 605.438, + 680.384, + 674.657, + 666.205, + 639.803, + 550.049, + 657.264, + 709.79, + 567.58, + 745.761, + 609.07, + 719.987, + 603.971, + 587.766, + 631.141, + 642.597, + 579.385, + 685.064, + 640.99, + 677.87, + 630.233, + 565.973, + 650.768, + 669.139, + 650.558, + 740.313, + 604.529, + 712.235, + 602.993, + 588.115, + 654.959, + 645.251, + 588.744, + 692.188, + 642.875, + 680.453, + 625.274, + 560.456, + 645.809, + 671.792, + 596.707, + 738.357, + 603.761, + 710.208, + 600.408, + 582.807, + 628.696, + 644.063, + 586.649, + 692.258, + 660.477, + 679.126, + 626.531, + 560.944, + 644.901, + 666.205, + 580.782, + 731.093, + 601.806, + 710.837, + 602.085, + 585.251, + 616.403, + 641.688, + 590.56, + 693.515, + 668.3, + 689.255, + 642.946, + 570.444, + 669.558, + 682.48, + 571.282, + 745.551, + 589.861, + 724.668, + 593.004, + 602.225, + 604.46, + 633.306, + 606.346, + 680.035, + 654.541, + 664.109, + 633.447, + 555.706, + 655.518, + 685.762, + 566.882, + 741.151, + 590.42, + 721.315, + 593.633, + 610.746, + 621.572, + 633.795, + 618.569, + 680.174, + 677.73, + 672.701, + 642.108, + 561.084, + 661.735, + 679.266, + 576.87, + 749.603, + 592.445, + 725.366, + 588.814, + 599.71, + 630.792, + 632.399, + 605.438, + 679.336, + 650.908, + 660.338, + 637.847, + 546.067, + 656.007, + 677.869, + 580.712, + 745.901, + 588.185, + 721.594, + 585.321, + 592.865, + 600.618, + 632.049, + 598.243, + 676.751, + 652.165, + 664.528, + 635.682, + 545.788, + 673.608, + 678.219, + 581.48, + 742.617, + 585.182, + 721.803, + 587.905, + 589.442, + 597.126, + 635.892, + 604.39, + 686.391, + 655.309, + 662.643, + 636.52, + 562.831, + 660.128, + 685.972, + 609.908, + 748.346, + 611.654, + 721.314, + 587.417, + 595.589, + 626.113 + ], + "staged_vector": [ + 664.319, + 521.69, + 714.679, + 571.003, + 711.536, + 564.646, + 578.127, + 577.778, + 605.367, + 582.877, + 650.349, + 622.131, + 672.142, + 626.462, + 516.033, + 617.172, + 649.023, + 516.312, + 672.77, + 555.008, + 668.929, + 552.842, + 578.267, + 562.202, + 591.608, + 549.909, + 637.916, + 584.483, + 643.505, + 592.097, + 508.839, + 595.379, + 635.961, + 514.287, + 675.704, + 550.747, + 665.716, + 554.03, + 556.963, + 561.014, + 590.56, + 548.722, + 635.752, + 585.95, + 648.882, + 591.329, + 509.816, + 600.338, + 633.586, + 514.356, + 674.936, + 555.706, + 667.742, + 553.471, + 564.227, + 560.875, + 587.137, + 543.832, + 638.126, + 583.855, + 648.393, + 593.773, + 508.349, + 593.983, + 638.545, + 512.68, + 675.146, + 556.126, + 671.094, + 555.078, + 570.653, + 560.526, + 589.792, + 549.42, + 640.221, + 585.321, + 667.951, + 614.448, + 508.629, + 617.172, + 669.488, + 533.076, + 703.084, + 577.778, + 692.886, + 573.727, + 556.334, + 582.877, + 616.264, + 564.926, + 663.411, + 603.97, + 686.74, + 593.005, + 519.316, + 585.252, + 616.543, + 518.198, + 656.636, + 557.173, + 657.963, + 559.478, + 564.088, + 570.094, + 599.64, + 536.009, + 646.019, + 577.289, + 661.036, + 584.204, + 515.055, + 592.656, + 630.443, + 521.69, + 664.599, + 562.691, + 661.455, + 560.805, + 547.184, + 571.212, + 600.827, + 538.384, + 650.349, + 577.149, + 659.43, + 581.27, + 515.823, + 587.207, + 622.062, + 521.76, + 664.179, + 565.834, + 659.5, + 559.548, + 551.236, + 568.419, + 600.129, + 540.201, + 644.413, + 573.447, + 672.072, + 588.045, + 520.363, + 587.836, + 631.351, + 521.83, + 664.807, + 583.855, + 670.046, + 567.581, + 573.517, + 577.08, + 598.802, + 548.023, + 635.751, + 582.178, + 663.97, + 601.805, + 513.379, + 602.085, + 634.773, + 516.033, + 676.682, + 555.776, + 668.3, + 554.728, + 577.289, + 558.5, + 590.91, + 549.35, + 638.895, + 581.969, + 768.601, + 613.61, + 512.401, + 602.574, + 648.185, + 519.036, + 683.387, + 566.532, + 673.679, + 556.474, + 579.524, + 561.922, + 588.116, + 548.442, + 637.847, + 593.005, + 647.695, + 592.376, + 511.912, + 597.056, + 633.097, + 514.217, + 668.37, + 548.163, + 666.414, + 552.702, + 559.617, + 559.059, + 590.42, + 546.486, + 634.983, + 579.384, + 644.133, + 586.299, + 507.092, + 595.101, + 666.694, + 513.169, + 670.675, + 550.328, + 662.363, + 550.467, + 554.659, + 557.662, + 589.303, + 543.902, + 634.913, + 580.293, + 645.67, + 583.505, + 507.511, + 593.563, + 660.757, + 515.754, + 673.888, + 549.0, + 664.249, + 556.195, + 540.759, + 564.926, + 587.347, + 576.801, + 636.799, + 586.02, + 654.33, + 612.212, + 515.265, + 597.964 + ] + }, + "staging_bytes": { + "direct": 0, + "staged_vector": 2076672 + }, + "source_features_byte_match": true, + "parent_report_sha256": "f2c1e7d52b43d04c3e64115f4416c025b12e1df9eb63ae1ab7d9ec193d85f03b", + "parent_input_hashes": { + "table": "c9c3955d47ba6a02d49515e812a025bee52b0cbdc524c240368b501a4f0f3e6e", + "codes": "752b22d0e7c9b15260ca8065bd5bb71c8dcf23ca833455ff9db734311c4b7816", + "traces": "b4d952bc154b14ef3f4fa96065540e85101c7f416ae76a5bcc98bb1b6316a184", + "trace_metadata": "2633f3bc45cbe13fafc82aa0b976aa107b05684b37b83aeb3ac5e0589e7da3ca", + "baseline_library": "6f714590455aa49910d49f9f32930c70c4324c7dbb76576c0ea91e6b36985195", + "candidate_library": "b12cf651f8d1f10511890b1153da378ae61663be9ae85313557ada8b3d2d2fc7", + "benchmark_source": "7331bca667d43b6234f83a28ee65963f9775d1bc6dd4cc262054803910ea121a" + }, + "provenance": "Full table/code hashes inherited from the just-completed frozen-input parent run, not recomputed. Original trace hashes checked again; every result compared with freshly read source FP64-to-FP32 features.", + "libraries": { + "direct": "b12cf651f8d1f10511890b1153da378ae61663be9ae85313557ada8b3d2d2fc7", + "staged_vector": "d1089329d120a0aaf8fb5d4a93dbe77555c3f061372dbaf13c3fc1bdb1ac848a" + }, + "cpu_affinity": [ + 112 + ], + "batch_size": 32, + "repeat": 30, + "warmup": 2, + "commit": "854fd04a83405957dcc8e6eed576d796f9263195" + }, + { + "model": "ag_news-exact-uniform-s3-lr10", + "direct_vs_staged_vector_speed_ratio": 0.8660577390168258, + "p50_us": { + "direct": 735.0045, + "staged_vector": 634.0045 + }, + "samples_us": { + "direct": [ + 746.459, + 726.483, + 806.948, + 756.168, + 766.226, + 781.383, + 619.547, + 763.642, + 848.716, + 621.572, + 883.989, + 666.973, + 864.781, + 670.326, + 769.299, + 680.733, + 728.369, + 711.187, + 771.535, + 754.282, + 760.36, + 760.848, + 648.463, + 801.289, + 817.564, + 633.866, + 887.202, + 661.944, + 877.703, + 668.929, + 733.538, + 681.781, + 749.673, + 707.485, + 771.744, + 752.606, + 767.902, + 777.541, + 615.985, + 779.218, + 826.295, + 621.153, + 894.816, + 662.014, + 866.806, + 671.024, + 704.69, + 684.295, + 738.357, + 699.382, + 810.23, + 747.228, + 775.725, + 720.127, + 623.459, + 717.962, + 790.673, + 649.092, + 853.676, + 700.71, + 835.725, + 658.521, + 693.585, + 680.803, + 727.88, + 709.441, + 816.726, + 756.867, + 791.302, + 752.327, + 640.222, + 756.867, + 794.514, + 634.145, + 867.435, + 650.349, + 836.073, + 673.958, + 699.731, + 706.157, + 751.698, + 697.497, + 830.626, + 727.251, + 766.506, + 725.157, + 642.666, + 753.864, + 789.834, + 644.901, + 860.241, + 684.086, + 828.949, + 685.273, + 693.865, + 701.338, + 776.494, + 719.289, + 801.848, + 726.762, + 815.468, + 734.096, + 694.563, + 766.506, + 791.93, + 655.379, + 882.871, + 680.105, + 908.506, + 721.105, + 688.207, + 719.499, + 742.828, + 713.911, + 807.995, + 728.718, + 824.2, + 762.664, + 639.802, + 750.65, + 831.114, + 652.235, + 870.09, + 684.156, + 898.099, + 701.688, + 687.858, + 698.125, + 743.386, + 686.74, + 806.249, + 771.744, + 790.953, + 736.402, + 638.126, + 750.651, + 785.574, + 640.99, + 859.263, + 727.53, + 841.802, + 690.232, + 687.648, + 700.779, + 742.129, + 700.709, + 803.734, + 734.795, + 792.07, + 736.96, + 635.123, + 759.381, + 788.997, + 640.012, + 864.502, + 683.737, + 831.394, + 687.718, + 679.685, + 718.381, + 740.941, + 681.711, + 819.799, + 737.659, + 778.589, + 762.175, + 632.888, + 741.291, + 806.039, + 640.082, + 850.392, + 695.89, + 835.934, + 688.277, + 701.897, + 699.662, + 734.585, + 696.728, + 805.551, + 734.515, + 787.251, + 758.334, + 680.663, + 748.485, + 797.518, + 676.612, + 865.479, + 711.606, + 843.408, + 689.813, + 683.596, + 698.753, + 735.214, + 684.085, + 806.039, + 728.02, + 797.448, + 738.357, + 631.491, + 742.06, + 809.672, + 649.442, + 867.784, + 693.026, + 845.363, + 699.382, + 691.001, + 698.265, + 714.609, + 697.077, + 800.103, + 750.162, + 793.746, + 745.202, + 642.527, + 744.504, + 765.947, + 646.368, + 848.856, + 692.747, + 838.519, + 696.239, + 679.685, + 696.658, + 733.258, + 685.133, + 796.749, + 724.458, + 793.117, + 738.777, + 637.707, + 753.863, + 779.916, + 636.45, + 878.611, + 683.178, + 829.928, + 695.401, + 728.998, + 700.849 + ], + "staged_vector": [ + 720.267, + 547.254, + 746.46, + 585.741, + 738.287, + 593.843, + 594.053, + 591.118, + 639.733, + 597.825, + 684.505, + 657.683, + 675.844, + 646.368, + 554.03, + 656.705, + 700.011, + 543.483, + 750.65, + 598.104, + 746.46, + 586.02, + 593.004, + 593.704, + 632.329, + 636.031, + 675.215, + 635.821, + 675.145, + 649.581, + 580.781, + 689.045, + 712.234, + 542.226, + 761.966, + 576.8, + 734.096, + 585.95, + 599.571, + 624.156, + 631.77, + 603.202, + 696.309, + 636.59, + 669.837, + 660.547, + 536.638, + 647.765, + 722.712, + 565.415, + 733.677, + 597.964, + 715.098, + 595.799, + 579.175, + 596.707, + 637.916, + 617.591, + 737.24, + 620.944, + 669.348, + 658.731, + 580.991, + 641.548, + 709.65, + 584.204, + 752.606, + 579.036, + 747.577, + 617.311, + 580.852, + 610.886, + 649.372, + 573.238, + 699.033, + 613.889, + 673.469, + 662.572, + 565.276, + 645.67, + 727.741, + 559.408, + 733.677, + 594.053, + 711.187, + 613.47, + 582.668, + 615.565, + 680.942, + 587.975, + 710.139, + 640.013, + 689.464, + 631.98, + 559.129, + 635.192, + 697.426, + 591.189, + 728.858, + 609.488, + 721.035, + 616.264, + 592.865, + 608.301, + 652.095, + 581.48, + 704.69, + 623.318, + 700.291, + 632.817, + 590.421, + 649.721, + 725.295, + 554.658, + 742.827, + 591.399, + 745.901, + 619.198, + 578.476, + 620.524, + 648.254, + 578.476, + 748.625, + 621.433, + 690.791, + 686.181, + 581.48, + 628.557, + 723.689, + 556.544, + 727.042, + 605.717, + 724.039, + 620.734, + 581.41, + 607.952, + 664.249, + 583.226, + 697.566, + 624.156, + 693.655, + 627.439, + 561.992, + 636.589, + 672.212, + 557.801, + 724.947, + 594.262, + 749.882, + 606.136, + 579.314, + 610.536, + 650.839, + 584.274, + 703.574, + 626.252, + 726.763, + 636.45, + 561.084, + 636.73, + 676.612, + 557.382, + 728.789, + 602.923, + 720.896, + 616.753, + 583.156, + 609.698, + 653.423, + 580.152, + 699.383, + 657.124, + 696.798, + 631.212, + 557.243, + 635.193, + 674.586, + 558.57, + 731.093, + 627.579, + 735.284, + 609.279, + 576.311, + 655.797, + 670.605, + 584.902, + 734.516, + 627.44, + 699.034, + 635.681, + 555.497, + 651.047, + 674.237, + 558.43, + 759.521, + 598.383, + 722.711, + 613.68, + 580.363, + 645.739, + 656.426, + 591.119, + 732.001, + 629.884, + 702.246, + 653.981, + 560.176, + 637.707, + 716.006, + 565.065, + 735.982, + 595.17, + 733.817, + 610.956, + 593.284, + 610.257, + 640.221, + 592.655, + 700.71, + 618.429, + 699.732, + 632.049, + 565.904, + 637.498, + 668.999, + 593.843, + 736.541, + 599.501, + 739.126, + 611.165, + 578.547, + 609.489, + 645.669, + 580.781, + 708.742, + 621.921, + 699.872, + 651.327, + 560.736, + 635.751 + ] + }, + "staging_bytes": { + "direct": 0, + "staged_vector": 2076672 + }, + "source_features_byte_match": true, + "parent_report_sha256": "b7708bd39358466006b8d4ef3f4308f5861829925667183020d980b0a3ffa0cb", + "parent_input_hashes": { + "table": "c82db82285a1381c7b812c730eac49c0efb03e5171d61779dad7335a24ae0e99", + "codes": "2c1f3ec20b0dfdbaf2b21ba97a9250bed804c5d17f2c76731ac30db83faa41f5", + "traces": "b4d952bc154b14ef3f4fa96065540e85101c7f416ae76a5bcc98bb1b6316a184", + "trace_metadata": "2633f3bc45cbe13fafc82aa0b976aa107b05684b37b83aeb3ac5e0589e7da3ca", + "baseline_library": "6f714590455aa49910d49f9f32930c70c4324c7dbb76576c0ea91e6b36985195", + "candidate_library": "b12cf651f8d1f10511890b1153da378ae61663be9ae85313557ada8b3d2d2fc7", + "benchmark_source": "7331bca667d43b6234f83a28ee65963f9775d1bc6dd4cc262054803910ea121a" + }, + "provenance": "Full table/code hashes inherited from the just-completed frozen-input parent run, not recomputed. Original trace hashes checked again; every result compared with freshly read source FP64-to-FP32 features.", + "libraries": { + "direct": "b12cf651f8d1f10511890b1153da378ae61663be9ae85313557ada8b3d2d2fc7", + "staged_vector": "d1089329d120a0aaf8fb5d4a93dbe77555c3f061372dbaf13c3fc1bdb1ac848a" + }, + "cpu_affinity": [ + 112 + ], + "batch_size": 32, + "repeat": 30, + "warmup": 2, + "commit": "854fd04a83405957dcc8e6eed576d796f9263195" + } +] \ No newline at end of file diff --git a/evidence/native_bag_vectorization_20261116/raw/default/ag_news-exact-uniform-s3-lr10-raw.json.gz b/evidence/native_bag_vectorization_20261116/raw/default/ag_news-exact-uniform-s3-lr10-raw.json.gz new file mode 100644 index 0000000..6dc80fb Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/default/ag_news-exact-uniform-s3-lr10-raw.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/default/ag_news-exact-zero-s3-lr10-raw.json.gz b/evidence/native_bag_vectorization_20261116/raw/default/ag_news-exact-zero-s3-lr10-raw.json.gz new file mode 100644 index 0000000..663dce4 Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/default/ag_news-exact-zero-s3-lr10-raw.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/default/ag_news-exact-zero-s3-lr10-zstd.json.gz b/evidence/native_bag_vectorization_20261116/raw/default/ag_news-exact-zero-s3-lr10-zstd.json.gz new file mode 100644 index 0000000..03033b0 Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/default/ag_news-exact-zero-s3-lr10-zstd.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/default/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz b/evidence/native_bag_vectorization_20261116/raw/default/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz new file mode 100644 index 0000000..5dbb54d Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/default/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/default/dbpedia_14-exact-zero-s3-lr10-raw.json.gz b/evidence/native_bag_vectorization_20261116/raw/default/dbpedia_14-exact-zero-s3-lr10-raw.json.gz new file mode 100644 index 0000000..6667a5c Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/default/dbpedia_14-exact-zero-s3-lr10-raw.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/fused-vector/ag_news-exact-uniform-s3-lr10-raw.json.gz b/evidence/native_bag_vectorization_20261116/raw/fused-vector/ag_news-exact-uniform-s3-lr10-raw.json.gz new file mode 100644 index 0000000..7b27025 Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/fused-vector/ag_news-exact-uniform-s3-lr10-raw.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/fused-vector/ag_news-exact-zero-s3-lr10-raw.json.gz b/evidence/native_bag_vectorization_20261116/raw/fused-vector/ag_news-exact-zero-s3-lr10-raw.json.gz new file mode 100644 index 0000000..f62dbcf Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/fused-vector/ag_news-exact-zero-s3-lr10-raw.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/fused-vector/ag_news-exact-zero-s3-lr10-zstd.json.gz b/evidence/native_bag_vectorization_20261116/raw/fused-vector/ag_news-exact-zero-s3-lr10-zstd.json.gz new file mode 100644 index 0000000..cad9252 Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/fused-vector/ag_news-exact-zero-s3-lr10-zstd.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/fused-vector/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz b/evidence/native_bag_vectorization_20261116/raw/fused-vector/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz new file mode 100644 index 0000000..2a6fd03 Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/fused-vector/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/fused-vector/dbpedia_14-exact-zero-s3-lr10-raw.json.gz b/evidence/native_bag_vectorization_20261116/raw/fused-vector/dbpedia_14-exact-zero-s3-lr10-raw.json.gz new file mode 100644 index 0000000..e076916 Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/fused-vector/dbpedia_14-exact-zero-s3-lr10-raw.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/fusion-only/ag_news-exact-uniform-s3-lr10-raw.json.gz b/evidence/native_bag_vectorization_20261116/raw/fusion-only/ag_news-exact-uniform-s3-lr10-raw.json.gz new file mode 100644 index 0000000..c55624e Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/fusion-only/ag_news-exact-uniform-s3-lr10-raw.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/fusion-only/ag_news-exact-zero-s3-lr10-raw.json.gz b/evidence/native_bag_vectorization_20261116/raw/fusion-only/ag_news-exact-zero-s3-lr10-raw.json.gz new file mode 100644 index 0000000..6844e32 Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/fusion-only/ag_news-exact-zero-s3-lr10-raw.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/fusion-only/ag_news-exact-zero-s3-lr10-zstd.json.gz b/evidence/native_bag_vectorization_20261116/raw/fusion-only/ag_news-exact-zero-s3-lr10-zstd.json.gz new file mode 100644 index 0000000..e51c410 Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/fusion-only/ag_news-exact-zero-s3-lr10-zstd.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/fusion-only/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz b/evidence/native_bag_vectorization_20261116/raw/fusion-only/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz new file mode 100644 index 0000000..2d6c1f8 Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/fusion-only/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/raw/fusion-only/dbpedia_14-exact-zero-s3-lr10-raw.json.gz b/evidence/native_bag_vectorization_20261116/raw/fusion-only/dbpedia_14-exact-zero-s3-lr10-raw.json.gz new file mode 100644 index 0000000..5637617 Binary files /dev/null and b/evidence/native_bag_vectorization_20261116/raw/fusion-only/dbpedia_14-exact-zero-s3-lr10-raw.json.gz differ diff --git a/evidence/native_bag_vectorization_20261116/run-status.json b/evidence/native_bag_vectorization_20261116/run-status.json new file mode 100644 index 0000000..b273978 --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/run-status.json @@ -0,0 +1,145 @@ +[ + { + "label": "ag_news-exact-zero-s3-lr10-raw", + "returncode": 0, + "command": [ + "/llm-align/duyimin/ngram-counterfact-capacity-20261106/env/bin/python", + "-m", + "tools.benchmark_native_bags", + "--table", + "/llm-align/duyimin/ngram-host-profile-20261112/bundles/ag_news-exact-zero-s3-lr10/dedup-raw/rows.meft", + "--codes", + "/llm-align/duyimin/ngram-controlled-deployment-20261111/training-registered/ag_news-exact-zero-s3-lr10/rows.npy", + "--traces", + "/llm-align/duyimin/ngram-sparse-xor-20261115/traces/ag_news.npz", + "--baseline-library", + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/baseline-final.so", + "--library", + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/candidate-final.so", + "--output", + "/llm-align/duyimin/ngram-direct-bags-20261116/final-results/ag_news-exact-zero-s3-lr10-raw.json", + "--commit", + "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "--core", + "88", + "--hashes-from", + "/llm-align/duyimin/ngram-direct-bags-20261116/vector-results/ag_news-exact-zero-s3-lr10-raw.json" + ] + }, + { + "label": "ag_news-exact-uniform-s3-lr10-raw", + "returncode": 0, + "command": [ + "/llm-align/duyimin/ngram-counterfact-capacity-20261106/env/bin/python", + "-m", + "tools.benchmark_native_bags", + "--table", + "/llm-align/duyimin/ngram-host-profile-20261112/bundles/ag_news-exact-uniform-s3-lr10/dedup-raw/rows.meft", + "--codes", + "/llm-align/duyimin/ngram-controlled-deployment-20261111/training-registered/ag_news-exact-uniform-s3-lr10/rows.npy", + "--traces", + "/llm-align/duyimin/ngram-sparse-xor-20261115/traces/ag_news.npz", + "--baseline-library", + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/baseline-final.so", + "--library", + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/candidate-final.so", + "--output", + "/llm-align/duyimin/ngram-direct-bags-20261116/final-results/ag_news-exact-uniform-s3-lr10-raw.json", + "--commit", + "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "--core", + "90", + "--hashes-from", + "/llm-align/duyimin/ngram-direct-bags-20261116/vector-results/ag_news-exact-uniform-s3-lr10-raw.json" + ] + }, + { + "label": "dbpedia_14-exact-zero-s3-lr10-raw", + "returncode": 0, + "command": [ + "/llm-align/duyimin/ngram-counterfact-capacity-20261106/env/bin/python", + "-m", + "tools.benchmark_native_bags", + "--table", + "/llm-align/duyimin/ngram-host-profile-20261112/bundles/dbpedia_14-exact-zero-s3-lr10/dedup-raw/rows.meft", + "--codes", + "/llm-align/duyimin/ngram-controlled-deployment-20261111/training-registered/dbpedia_14-exact-zero-s3-lr10/rows.npy", + "--traces", + "/llm-align/duyimin/ngram-sparse-xor-20261115/traces/dbpedia_14.npz", + "--baseline-library", + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/baseline-final.so", + "--library", + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/candidate-final.so", + "--output", + "/llm-align/duyimin/ngram-direct-bags-20261116/final-results/dbpedia_14-exact-zero-s3-lr10-raw.json", + "--commit", + "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "--core", + "92", + "--hashes-from", + "/llm-align/duyimin/ngram-direct-bags-20261116/vector-results/dbpedia_14-exact-zero-s3-lr10-raw.json" + ] + }, + { + "label": "dbpedia_14-exact-uniform-s3-lr3-raw", + "returncode": 0, + "command": [ + "/llm-align/duyimin/ngram-counterfact-capacity-20261106/env/bin/python", + "-m", + "tools.benchmark_native_bags", + "--table", + "/llm-align/duyimin/ngram-host-profile-20261112/bundles/dbpedia_14-exact-uniform-s3-lr3/dedup-raw/rows.meft", + "--codes", + "/llm-align/duyimin/ngram-controlled-deployment-20261111/training-registered/dbpedia_14-exact-uniform-s3-lr3/rows.npy", + "--traces", + "/llm-align/duyimin/ngram-sparse-xor-20261115/traces/dbpedia_14.npz", + "--baseline-library", + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/baseline-final.so", + "--library", + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/candidate-final.so", + "--output", + "/llm-align/duyimin/ngram-direct-bags-20261116/final-results/dbpedia_14-exact-uniform-s3-lr3-raw.json", + "--commit", + "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "--core", + "94", + "--hashes-from", + "/llm-align/duyimin/ngram-direct-bags-20261116/vector-results/dbpedia_14-exact-uniform-s3-lr3-raw.json" + ] + }, + { + "label": "ag_news-exact-zero-s3-lr10-zstd", + "returncode": 0, + "command": [ + "/llm-align/duyimin/ngram-counterfact-capacity-20261106/env/bin/python", + "-m", + "tools.benchmark_native_bags", + "--table", + "/llm-align/duyimin/ngram-controlled-deployment-20261111/application-frontier/models/ag_news-exact-zero-s3-lr10/bundles/byte-dedup-zstd/rows.meft", + "--codes", + "/llm-align/duyimin/ngram-controlled-deployment-20261111/training-registered/ag_news-exact-zero-s3-lr10/rows.npy", + "--traces", + "/llm-align/duyimin/ngram-sparse-xor-20261115/traces/ag_news.npz", + "--baseline-library", + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/baseline-final.so", + "--library", + "/llm-align/duyimin/ngram-direct-bags-20261116/lib/candidate-final.so", + "--output", + "/llm-align/duyimin/ngram-direct-bags-20261116/final-results/ag_news-exact-zero-s3-lr10-zstd.json", + "--commit", + "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "--core", + "100", + "--batch-sizes", + "32", + "--repeat", + "3", + "--rounds", + "2", + "--warmup", + "1", + "--hashes-from", + "/llm-align/duyimin/ngram-direct-bags-20261116/vector-results/ag_news-exact-zero-s3-lr10-zstd.json" + ] + } +] \ No newline at end of file diff --git a/evidence/native_bag_vectorization_20261116/scripts/ablate_vector.py b/evidence/native_bag_vectorization_20261116/scripts/ablate_vector.py new file mode 100644 index 0000000..48f8414 --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/scripts/ablate_vector.py @@ -0,0 +1,36 @@ +import hashlib,json,math,os,statistics,sys,time +from pathlib import Path +import numpy as np +work=Path('/llm-align/duyimin/ngram-direct-bags-20261116');sys.path.insert(0,str(work/'vector-runtime')) +from tools.native_row_store import NativeRows +os.sched_setaffinity(0,{112}) +reports=[] +for model in ('ag_news-exact-zero-s3-lr10','ag_news-exact-uniform-s3-lr10'): + parent_path=work/'vector-results'/f'{model}-raw.json';parent=json.loads(parent_path.read_text()) + import shlex + cmd=shlex.split(parent['command']) + def arg(name):return Path(cmd[cmd.index('--'+name)+1]) + codes=np.load(arg('codes'),mmap_mode='r');path=arg('traces');meta=json.loads(path.with_suffix('.json').read_text());trace=np.load(path) + assert hashlib.sha256(path.read_bytes()).hexdigest()==parent['hashes']['traces'] + docs=[np.ascontiguousarray(trace['ids'+str(i)],dtype=np.uint64) for i in range(len(meta['requests']))] + for i,ids in enumerate(docs):assert hashlib.sha256(ids.tobytes()).hexdigest()==meta['requests'][i]['ids_sha256'] + queries=[] + for begin in range(0,len(docs),32): + parts=docs[begin:begin+32];ids=np.concatenate(parts);off=np.r_[0,np.cumsum([len(x) for x in parts],dtype=np.uint64)].astype(np.uint64) + expected=np.array([(codes[x].astype(np.float64).sum(0)/max(len(x),1)).astype(np.float32) for x in parts]) + queries.append((ids,off,expected)) + samples={n:[] for n in ('direct','staged_vector')};libraries={'direct':work/'lib/candidate-vector.so','staged_vector':work/'lib/staged-vector.so'} + with NativeRows(arg('table'),libraries['direct']) as direct,NativeRows(arg('table'),libraries['staged_vector']) as staged: + stores={'direct':direct,'staged_vector':staged};outputs={n:[np.empty_like(e) for _,_,e in queries] for n in stores} + for rep in range(-2,30): + for i,(ids,off,expected) in enumerate(queries): + order=('direct','staged_vector') if (rep+i)%2 else ('staged_vector','direct') + for n in order: + started=time.perf_counter_ns();stores[n].embedding_bag_array(ids,off,mode='mean',out=outputs[n][i]);elapsed=(time.perf_counter_ns()-started)/1000 + assert outputs[n][i].tobytes()==expected.tobytes() + if rep>=0:samples[n].append(elapsed) + staging={n:s.last_bag_staging_bytes for n,s in stores.items()} + ratio=math.exp(statistics.mean(math.log(a/b) for a,b in zip(samples['staged_vector'],samples['direct']))) + record={'model':model,'direct_vs_staged_vector_speed_ratio':ratio,'p50_us':{n:statistics.median(v) for n,v in samples.items()},'samples_us':samples,'staging_bytes':staging,'source_features_byte_match':True,'parent_report_sha256':hashlib.sha256(parent_path.read_bytes()).hexdigest(),'parent_input_hashes':parent['hashes'],'provenance':'Full table/code hashes inherited from the just-completed frozen-input parent run, not recomputed. Original trace hashes checked again; every result compared with freshly read source FP64-to-FP32 features.','libraries':{n:hashlib.sha256(p.read_bytes()).hexdigest() for n,p in libraries.items()},'cpu_affinity':[112],'batch_size':32,'repeat':30,'warmup':2,'commit':'854fd04a83405957dcc8e6eed576d796f9263195'} + reports.append(record);print(model,ratio,record['p50_us'],flush=True) +(work/'vector-results/fusion-ablation.json').write_text(json.dumps(reports,indent=2)) diff --git a/evidence/native_bag_vectorization_20261116/scripts/run_final.py b/evidence/native_bag_vectorization_20261116/scripts/run_final.py new file mode 100644 index 0000000..c51b08e --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/scripts/run_final.py @@ -0,0 +1,30 @@ +import concurrent.futures, hashlib, json, os, subprocess, sys +from pathlib import Path +work=Path('/llm-align/duyimin/ngram-direct-bags-20261116') +root=Path('/llm-align/duyimin/ngram-controlled-deployment-20261111') +previous=Path('/llm-align/duyimin/ngram-sparse-xor-20261115') +bundles=Path('/llm-align/duyimin/ngram-host-profile-20261112/bundles') +env=dict(os.environ,PYTHONPATH=str(work/'final-runtime'),OMP_NUM_THREADS='1',OPENBLAS_NUM_THREADS='1') +models=['ag_news-exact-zero-s3-lr10','ag_news-exact-uniform-s3-lr10','dbpedia_14-exact-zero-s3-lr10','dbpedia_14-exact-uniform-s3-lr3'] +jobs=[] +for model in models: + dataset=model.split('-')[0] + cmd=[sys.executable,'-m','tools.benchmark_native_bags','--table',str(bundles/model/'dedup-raw/rows.meft'),'--codes',str(root/'training-registered'/model/'rows.npy'),'--traces',str(previous/'traces'/f'{dataset}.npz'),'--baseline-library',str(work/'lib/baseline-final.so'),'--library',str(work/'lib/candidate-final.so'),'--output',str(work/'final-results'/f'{model}-raw.json'),'--commit','4f6fa5a7a7c9e2eb42d5043784d39738150de23b','--core',str(88+len(jobs)*2)] + jobs.append((model+'-raw',cmd)) +model=models[0] +cmd=[sys.executable,'-m','tools.benchmark_native_bags','--table',str(root/'application-frontier/models'/model/'bundles/byte-dedup-zstd/rows.meft'),'--codes',str(root/'training-registered'/model/'rows.npy'),'--traces',str(previous/'traces/ag_news.npz'),'--baseline-library',str(work/'lib/baseline-final.so'),'--library',str(work/'lib/candidate-final.so'),'--output',str(work/'final-results'/f'{model}-zstd.json'),'--commit','4f6fa5a7a7c9e2eb42d5043784d39738150de23b','--core','100','--batch-sizes','32','--repeat','3','--rounds','2','--warmup','1'] +jobs.append((model+'-zstd',cmd)) +for label, cmd in jobs: + parent=work/'vector-results'/Path(cmd[cmd.index('--output')+1]).name + cmd+=['--hashes-from',str(parent)] +def run(job): + label,cmd=job + with (work/'final-results'/f'{label}.log').open('w') as out: + p=subprocess.run(cmd,cwd=work/'final-runtime',env=env,stdout=out,stderr=subprocess.STDOUT) + print(label,p.returncode,flush=True) + return {'label':label,'returncode':p.returncode,'command':cmd} +with concurrent.futures.ThreadPoolExecutor(max_workers=5) as pool:results=list(pool.map(run,jobs)) +(work/'final-results/run-status.json').write_text(json.dumps(results,indent=2)) +files=[work/'runtime/native/meft_rows.c',work/'runtime/native/meft_rows.h',work/'runtime/tools/native_row_store.py',work/'runtime/tools/benchmark_native_bags.py',*work.glob('lib/*.so')] +manifest={'commit':'4f6fa5a7a7c9e2eb42d5043784d39738150de23b','compiler':subprocess.check_output(['cc','--version'],text=True),'compile':'cc -std=c11 -O3 -fPIC -shared native/meft_rows.c -lz FLAGS -o LIBRARY','flags':'-I'+str(previous/'include')+' -DMEFT_USE_LZ4 -DMEFT_USE_ZSTD -DMEFT_USE_LIBDEFLATE -l:liblz4.so.1 -l:libzstd.so.1 -l:libdeflate.so.0','baseline_extra':'-DMEFT_DISABLE_RAW_BAG -DMEFT_DISABLE_FP32_BAG_VECTOR','headers_manifest':str(previous/'results/build.json'),'files':{str(p):{'bytes':p.stat().st_size,'sha256':hashlib.sha256(p.read_bytes()).hexdigest()} for p in files}} +(work/'final-results/build.json').write_text(json.dumps(manifest,indent=2)) diff --git a/evidence/native_bag_vectorization_20261116/scripts/run_fusion_only.py b/evidence/native_bag_vectorization_20261116/scripts/run_fusion_only.py new file mode 100644 index 0000000..a98f69c --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/scripts/run_fusion_only.py @@ -0,0 +1,27 @@ +import concurrent.futures, hashlib, json, os, subprocess, sys +from pathlib import Path +work=Path('/llm-align/duyimin/ngram-direct-bags-20261116') +root=Path('/llm-align/duyimin/ngram-controlled-deployment-20261111') +previous=Path('/llm-align/duyimin/ngram-sparse-xor-20261115') +bundles=Path('/llm-align/duyimin/ngram-host-profile-20261112/bundles') +env=dict(os.environ,PYTHONPATH=str(work/'runtime'),OMP_NUM_THREADS='1',OPENBLAS_NUM_THREADS='1') +models=['ag_news-exact-zero-s3-lr10','ag_news-exact-uniform-s3-lr10','dbpedia_14-exact-zero-s3-lr10','dbpedia_14-exact-uniform-s3-lr3'] +jobs=[] +for model in models: + dataset=model.split('-')[0] + cmd=[sys.executable,'-m','tools.benchmark_native_bags','--table',str(bundles/model/'dedup-raw/rows.meft'),'--codes',str(root/'training-registered'/model/'rows.npy'),'--traces',str(previous/'traces'/f'{dataset}.npz'),'--baseline-library',str(work/'lib/baseline.so'),'--library',str(work/'lib/candidate.so'),'--output',str(work/'results'/f'{model}-raw.json'),'--commit','f51f48657d409712f281577ce1f2e27586b26514','--core',str(64+len(jobs)*2)] + jobs.append((model+'-raw',cmd)) +model=models[0] +cmd=[sys.executable,'-m','tools.benchmark_native_bags','--table',str(root/'application-frontier/models'/model/'bundles/byte-dedup-zstd/rows.meft'),'--codes',str(root/'training-registered'/model/'rows.npy'),'--traces',str(previous/'traces/ag_news.npz'),'--baseline-library',str(work/'lib/baseline.so'),'--library',str(work/'lib/candidate.so'),'--output',str(work/'results'/f'{model}-zstd.json'),'--commit','f51f48657d409712f281577ce1f2e27586b26514','--core','80','--batch-sizes','32','--repeat','3','--rounds','2','--warmup','1'] +jobs.append((model+'-zstd',cmd)) +def run(job): + label,cmd=job + with (work/'results'/f'{label}.log').open('w') as out: + p=subprocess.run(cmd,cwd=work/'runtime',env=env,stdout=out,stderr=subprocess.STDOUT) + print(label,p.returncode,flush=True) + return {'label':label,'returncode':p.returncode,'command':cmd} +with concurrent.futures.ThreadPoolExecutor(max_workers=5) as pool:results=list(pool.map(run,jobs)) +(work/'results/run-status.json').write_text(json.dumps(results,indent=2)) +files=[work/'runtime/native/meft_rows.c',work/'runtime/native/meft_rows.h',work/'runtime/tools/native_row_store.py',work/'runtime/tools/benchmark_native_bags.py',*work.glob('lib/*.so')] +manifest={'commit':'f51f48657d409712f281577ce1f2e27586b26514','compiler':subprocess.check_output(['cc','--version'],text=True),'compile':'cc -std=c11 -O3 -fPIC -shared native/meft_rows.c -lz FLAGS -o LIBRARY','flags':'-I'+str(previous/'include')+' -DMEFT_USE_LZ4 -DMEFT_USE_ZSTD -DMEFT_USE_LIBDEFLATE -l:liblz4.so.1 -l:libzstd.so.1 -l:libdeflate.so.0','baseline_extra':'-DMEFT_DISABLE_RAW_BAG','headers_manifest':str(previous/'results/build.json'),'files':{str(p):{'bytes':p.stat().st_size,'sha256':hashlib.sha256(p.read_bytes()).hexdigest()} for p in files}} +(work/'results/build.json').write_text(json.dumps(manifest,indent=2)) diff --git a/evidence/native_bag_vectorization_20261116/scripts/run_vector.py b/evidence/native_bag_vectorization_20261116/scripts/run_vector.py new file mode 100644 index 0000000..20e5499 --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/scripts/run_vector.py @@ -0,0 +1,27 @@ +import concurrent.futures, hashlib, json, os, subprocess, sys +from pathlib import Path +work=Path('/llm-align/duyimin/ngram-direct-bags-20261116') +root=Path('/llm-align/duyimin/ngram-controlled-deployment-20261111') +previous=Path('/llm-align/duyimin/ngram-sparse-xor-20261115') +bundles=Path('/llm-align/duyimin/ngram-host-profile-20261112/bundles') +env=dict(os.environ,PYTHONPATH=str(work/'vector-runtime'),OMP_NUM_THREADS='1',OPENBLAS_NUM_THREADS='1') +models=['ag_news-exact-zero-s3-lr10','ag_news-exact-uniform-s3-lr10','dbpedia_14-exact-zero-s3-lr10','dbpedia_14-exact-uniform-s3-lr3'] +jobs=[] +for model in models: + dataset=model.split('-')[0] + cmd=[sys.executable,'-m','tools.benchmark_native_bags','--table',str(bundles/model/'dedup-raw/rows.meft'),'--codes',str(root/'training-registered'/model/'rows.npy'),'--traces',str(previous/'traces'/f'{dataset}.npz'),'--baseline-library',str(work/'lib/baseline-vector.so'),'--library',str(work/'lib/candidate-vector.so'),'--output',str(work/'vector-results'/f'{model}-raw.json'),'--commit','854fd04a83405957dcc8e6eed576d796f9263195','--core',str(88+len(jobs)*2)] + jobs.append((model+'-raw',cmd)) +model=models[0] +cmd=[sys.executable,'-m','tools.benchmark_native_bags','--table',str(root/'application-frontier/models'/model/'bundles/byte-dedup-zstd/rows.meft'),'--codes',str(root/'training-registered'/model/'rows.npy'),'--traces',str(previous/'traces/ag_news.npz'),'--baseline-library',str(work/'lib/baseline-vector.so'),'--library',str(work/'lib/candidate-vector.so'),'--output',str(work/'vector-results'/f'{model}-zstd.json'),'--commit','854fd04a83405957dcc8e6eed576d796f9263195','--core','100','--batch-sizes','32','--repeat','3','--rounds','2','--warmup','1'] +jobs.append((model+'-zstd',cmd)) +def run(job): + label,cmd=job + with (work/'vector-results'/f'{label}.log').open('w') as out: + p=subprocess.run(cmd,cwd=work/'vector-runtime',env=env,stdout=out,stderr=subprocess.STDOUT) + print(label,p.returncode,flush=True) + return {'label':label,'returncode':p.returncode,'command':cmd} +with concurrent.futures.ThreadPoolExecutor(max_workers=5) as pool:results=list(pool.map(run,jobs)) +(work/'vector-results/run-status.json').write_text(json.dumps(results,indent=2)) +files=[work/'runtime/native/meft_rows.c',work/'runtime/native/meft_rows.h',work/'runtime/tools/native_row_store.py',work/'runtime/tools/benchmark_native_bags.py',*work.glob('lib/*.so')] +manifest={'commit':'854fd04a83405957dcc8e6eed576d796f9263195','compiler':subprocess.check_output(['cc','--version'],text=True),'compile':'cc -std=c11 -O3 -fPIC -shared native/meft_rows.c -lz FLAGS -o LIBRARY','flags':'-I'+str(previous/'include')+' -DMEFT_USE_LZ4 -DMEFT_USE_ZSTD -DMEFT_USE_LIBDEFLATE -l:liblz4.so.1 -l:libzstd.so.1 -l:libdeflate.so.0','baseline_extra':'-DMEFT_DISABLE_RAW_BAG -DMEFT_DISABLE_FP32_BAG_VECTOR','headers_manifest':str(previous/'results/build.json'),'files':{str(p):{'bytes':p.stat().st_size,'sha256':hashlib.sha256(p.read_bytes()).hexdigest()} for p in files}} +(work/'vector-results/build.json').write_text(json.dumps(manifest,indent=2)) diff --git a/evidence/native_bag_vectorization_20261116/summary.json b/evidence/native_bag_vectorization_20261116/summary.json new file mode 100644 index 0000000..d8cc65f --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/summary.json @@ -0,0 +1,515 @@ +[ + { + "phase": "fusion-only", + "model": "ag_news-exact-uniform-s3-lr10-raw", + "batch_size": 1, + "commit": "f51f48657d409712f281577ce1f2e27586b26514", + "rows": 6989612, + "speed_ratio": 0.9903202426954255, + "p50_us": { + "baseline": 113.432, + "candidate": 114.899 + }, + "maximum_row_staging_bytes": { + "baseline": 226816, + "candidate": 0 + }, + "raw": "raw/fusion-only/ag_news-exact-uniform-s3-lr10-raw.json.gz", + "raw_sha256": "2c117993e156bd3365032af1cac2d735cc589447e832225898470f356b1c95b0", + "source_features_byte_match": true + }, + { + "phase": "fusion-only", + "model": "ag_news-exact-uniform-s3-lr10-raw", + "batch_size": 32, + "commit": "f51f48657d409712f281577ce1f2e27586b26514", + "rows": 6989612, + "speed_ratio": 0.9972212312042107, + "p50_us": { + "baseline": 2319.9120000000003, + "candidate": 2343.1369999999997 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 0 + }, + "raw": "raw/fusion-only/ag_news-exact-uniform-s3-lr10-raw.json.gz", + "raw_sha256": "2c117993e156bd3365032af1cac2d735cc589447e832225898470f356b1c95b0", + "source_features_byte_match": true + }, + { + "phase": "fusion-only", + "model": "ag_news-exact-zero-s3-lr10-raw", + "batch_size": 1, + "commit": "f51f48657d409712f281577ce1f2e27586b26514", + "rows": 6989612, + "speed_ratio": 0.9924390498572474, + "p50_us": { + "baseline": 115.388, + "candidate": 116.331 + }, + "maximum_row_staging_bytes": { + "baseline": 226816, + "candidate": 0 + }, + "raw": "raw/fusion-only/ag_news-exact-zero-s3-lr10-raw.json.gz", + "raw_sha256": "77cd5784fd65c2e66886961277282c8887782d7dc3e74018cdeae625888a9102", + "source_features_byte_match": true + }, + { + "phase": "fusion-only", + "model": "ag_news-exact-zero-s3-lr10-raw", + "batch_size": 32, + "commit": "f51f48657d409712f281577ce1f2e27586b26514", + "rows": 6989612, + "speed_ratio": 0.996147534473024, + "p50_us": { + "baseline": 2320.7855, + "candidate": 2342.2285 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 0 + }, + "raw": "raw/fusion-only/ag_news-exact-zero-s3-lr10-raw.json.gz", + "raw_sha256": "77cd5784fd65c2e66886961277282c8887782d7dc3e74018cdeae625888a9102", + "source_features_byte_match": true + }, + { + "phase": "fusion-only", + "model": "dbpedia_14-exact-uniform-s3-lr3-raw", + "batch_size": 1, + "commit": "f51f48657d409712f281577ce1f2e27586b26514", + "rows": 34050161, + "speed_ratio": 0.9714987223197205, + "p50_us": { + "baseline": 134.03750000000002, + "candidate": 138.717 + }, + "maximum_row_staging_bytes": { + "baseline": 218112, + "candidate": 0 + }, + "raw": "raw/fusion-only/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz", + "raw_sha256": "8d4de9e6bfbf6689a3b0312f216acd9b01ca38a6c65a1d0fd7d2a2e7ecaa2f52", + "source_features_byte_match": true + }, + { + "phase": "fusion-only", + "model": "dbpedia_14-exact-uniform-s3-lr3-raw", + "batch_size": 32, + "commit": "f51f48657d409712f281577ce1f2e27586b26514", + "rows": 34050161, + "speed_ratio": 0.9529420121338094, + "p50_us": { + "baseline": 2858.2619999999997, + "candidate": 3026.4545 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 0 + }, + "raw": "raw/fusion-only/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz", + "raw_sha256": "8d4de9e6bfbf6689a3b0312f216acd9b01ca38a6c65a1d0fd7d2a2e7ecaa2f52", + "source_features_byte_match": true + }, + { + "phase": "fusion-only", + "model": "dbpedia_14-exact-zero-s3-lr10-raw", + "batch_size": 1, + "commit": "f51f48657d409712f281577ce1f2e27586b26514", + "rows": 34050161, + "speed_ratio": 0.9844186491428103, + "p50_us": { + "baseline": 132.221, + "candidate": 133.89749999999998 + }, + "maximum_row_staging_bytes": { + "baseline": 218112, + "candidate": 0 + }, + "raw": "raw/fusion-only/dbpedia_14-exact-zero-s3-lr10-raw.json.gz", + "raw_sha256": "a8f276a53e5ede629d93ed8233f8c7d62be293615bc73d7fd0a572bb2d93dac0", + "source_features_byte_match": true + }, + { + "phase": "fusion-only", + "model": "dbpedia_14-exact-zero-s3-lr10-raw", + "batch_size": 32, + "commit": "f51f48657d409712f281577ce1f2e27586b26514", + "rows": 34050161, + "speed_ratio": 0.9810070570937723, + "p50_us": { + "baseline": 2843.2439999999997, + "candidate": 2912.5330000000004 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 0 + }, + "raw": "raw/fusion-only/dbpedia_14-exact-zero-s3-lr10-raw.json.gz", + "raw_sha256": "a8f276a53e5ede629d93ed8233f8c7d62be293615bc73d7fd0a572bb2d93dac0", + "source_features_byte_match": true + }, + { + "phase": "fusion-only", + "model": "ag_news-exact-zero-s3-lr10-zstd", + "batch_size": 32, + "commit": "f51f48657d409712f281577ce1f2e27586b26514", + "rows": 6989612, + "speed_ratio": 0.997402876310672, + "p50_us": { + "baseline": 317931.4015, + "candidate": 319711.376 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 2097152 + }, + "raw": "raw/fusion-only/ag_news-exact-zero-s3-lr10-zstd.json.gz", + "raw_sha256": "6e7c413331df58dc73b42c24168ced157fc75719b46d904d8ade4ba635ed0309", + "source_features_byte_match": true + }, + { + "phase": "fused-vector", + "model": "ag_news-exact-uniform-s3-lr10-raw", + "batch_size": 1, + "commit": "854fd04a83405957dcc8e6eed576d796f9263195", + "rows": 6989612, + "speed_ratio": 1.5476794280081598, + "p50_us": { + "baseline": 116.5405, + "candidate": 74.91149999999999 + }, + "maximum_row_staging_bytes": { + "baseline": 226816, + "candidate": 0 + }, + "raw": "raw/fused-vector/ag_news-exact-uniform-s3-lr10-raw.json.gz", + "raw_sha256": "157526d990ce5e119adf418f09b3f9f7a48ad54abc35fa0f81d00197b10c4303", + "source_features_byte_match": true + }, + { + "phase": "fused-vector", + "model": "ag_news-exact-uniform-s3-lr10-raw", + "batch_size": 32, + "commit": "854fd04a83405957dcc8e6eed576d796f9263195", + "rows": 6989612, + "speed_ratio": 2.403033650946185, + "p50_us": { + "baseline": 2407.2915000000003, + "candidate": 1021.6935000000001 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 0 + }, + "raw": "raw/fused-vector/ag_news-exact-uniform-s3-lr10-raw.json.gz", + "raw_sha256": "157526d990ce5e119adf418f09b3f9f7a48ad54abc35fa0f81d00197b10c4303", + "source_features_byte_match": true + }, + { + "phase": "fused-vector", + "model": "ag_news-exact-zero-s3-lr10-raw", + "batch_size": 1, + "commit": "854fd04a83405957dcc8e6eed576d796f9263195", + "rows": 6989612, + "speed_ratio": 1.6229735998001338, + "p50_us": { + "baseline": 113.991, + "candidate": 69.498 + }, + "maximum_row_staging_bytes": { + "baseline": 226816, + "candidate": 0 + }, + "raw": "raw/fused-vector/ag_news-exact-zero-s3-lr10-raw.json.gz", + "raw_sha256": "75cce89e87de50b6224e3a0cd915e7a3463559c240a67850d9f042f9dd5af852", + "source_features_byte_match": true + }, + { + "phase": "fused-vector", + "model": "ag_news-exact-zero-s3-lr10-raw", + "batch_size": 32, + "commit": "854fd04a83405957dcc8e6eed576d796f9263195", + "rows": 6989612, + "speed_ratio": 2.595588108952457, + "p50_us": { + "baseline": 2371.6695, + "candidate": 936.2 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 0 + }, + "raw": "raw/fused-vector/ag_news-exact-zero-s3-lr10-raw.json.gz", + "raw_sha256": "75cce89e87de50b6224e3a0cd915e7a3463559c240a67850d9f042f9dd5af852", + "source_features_byte_match": true + }, + { + "phase": "fused-vector", + "model": "dbpedia_14-exact-uniform-s3-lr3-raw", + "batch_size": 1, + "commit": "854fd04a83405957dcc8e6eed576d796f9263195", + "rows": 34050161, + "speed_ratio": 1.667957588842427, + "p50_us": { + "baseline": 132.71, + "candidate": 78.40350000000001 + }, + "maximum_row_staging_bytes": { + "baseline": 218112, + "candidate": 0 + }, + "raw": "raw/fused-vector/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz", + "raw_sha256": "10bdd0fec88ac6336823477329ae47071403ea3cd8fbbb1ac55f0a323d020ee3", + "source_features_byte_match": true + }, + { + "phase": "fused-vector", + "model": "dbpedia_14-exact-uniform-s3-lr3-raw", + "batch_size": 32, + "commit": "854fd04a83405957dcc8e6eed576d796f9263195", + "rows": 34050161, + "speed_ratio": 2.4626794646209866, + "p50_us": { + "baseline": 2864.443, + "candidate": 1197.8490000000002 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 0 + }, + "raw": "raw/fused-vector/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz", + "raw_sha256": "10bdd0fec88ac6336823477329ae47071403ea3cd8fbbb1ac55f0a323d020ee3", + "source_features_byte_match": true + }, + { + "phase": "fused-vector", + "model": "dbpedia_14-exact-zero-s3-lr10-raw", + "batch_size": 1, + "commit": "854fd04a83405957dcc8e6eed576d796f9263195", + "rows": 34050161, + "speed_ratio": 1.6391283233512022, + "p50_us": { + "baseline": 135.644, + "candidate": 81.757 + }, + "maximum_row_staging_bytes": { + "baseline": 218112, + "candidate": 0 + }, + "raw": "raw/fused-vector/dbpedia_14-exact-zero-s3-lr10-raw.json.gz", + "raw_sha256": "bd2e0ca8a722b46d58779947f62c0284fc937724a63c77a8e7a854d0d126d76c", + "source_features_byte_match": true + }, + { + "phase": "fused-vector", + "model": "dbpedia_14-exact-zero-s3-lr10-raw", + "batch_size": 32, + "commit": "854fd04a83405957dcc8e6eed576d796f9263195", + "rows": 34050161, + "speed_ratio": 2.513256209162751, + "p50_us": { + "baseline": 2885.083, + "candidate": 1164.4965 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 0 + }, + "raw": "raw/fused-vector/dbpedia_14-exact-zero-s3-lr10-raw.json.gz", + "raw_sha256": "bd2e0ca8a722b46d58779947f62c0284fc937724a63c77a8e7a854d0d126d76c", + "source_features_byte_match": true + }, + { + "phase": "fused-vector", + "model": "ag_news-exact-zero-s3-lr10-zstd", + "batch_size": 32, + "commit": "854fd04a83405957dcc8e6eed576d796f9263195", + "rows": 6989612, + "speed_ratio": 1.0044342621885527, + "p50_us": { + "baseline": 318477.81799999997, + "candidate": 317373.757 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 2097152 + }, + "raw": "raw/fused-vector/ag_news-exact-zero-s3-lr10-zstd.json.gz", + "raw_sha256": "c95936729bf9bb1828533e4378cb0ccffa58aec69fcca87a5b6694ef7c96832a", + "source_features_byte_match": true + }, + { + "phase": "default", + "model": "ag_news-exact-uniform-s3-lr10-raw", + "batch_size": 1, + "commit": "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "rows": 6989612, + "speed_ratio": 1.7092759138114229, + "p50_us": { + "baseline": 116.1565, + "candidate": 67.682 + }, + "maximum_row_staging_bytes": { + "baseline": 226816, + "candidate": 226816 + }, + "raw": "raw/default/ag_news-exact-uniform-s3-lr10-raw.json.gz", + "raw_sha256": "ec5267263b87e66a12536209772b53a001f0af83a2fdc528b68eb3ca34461467", + "source_features_byte_match": true + }, + { + "phase": "default", + "model": "ag_news-exact-uniform-s3-lr10-raw", + "batch_size": 32, + "commit": "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "rows": 6989612, + "speed_ratio": 2.9769160174750913, + "p50_us": { + "baseline": 2428.9094999999998, + "candidate": 826.225 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 2097152 + }, + "raw": "raw/default/ag_news-exact-uniform-s3-lr10-raw.json.gz", + "raw_sha256": "ec5267263b87e66a12536209772b53a001f0af83a2fdc528b68eb3ca34461467", + "source_features_byte_match": true + }, + { + "phase": "default", + "model": "ag_news-exact-zero-s3-lr10-raw", + "batch_size": 1, + "commit": "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "rows": 6989612, + "speed_ratio": 1.7345798809867021, + "p50_us": { + "baseline": 114.27099999999999, + "candidate": 65.866 + }, + "maximum_row_staging_bytes": { + "baseline": 226816, + "candidate": 226816 + }, + "raw": "raw/default/ag_news-exact-zero-s3-lr10-raw.json.gz", + "raw_sha256": "ce5284d68b8862d515d1be23b495fb070ec670720f5e03c7f01eebbd3804fad2", + "source_features_byte_match": true + }, + { + "phase": "default", + "model": "ag_news-exact-zero-s3-lr10-raw", + "batch_size": 32, + "commit": "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "rows": 6989612, + "speed_ratio": 3.115652866493872, + "p50_us": { + "baseline": 2370.307, + "candidate": 769.2295 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 2097152 + }, + "raw": "raw/default/ag_news-exact-zero-s3-lr10-raw.json.gz", + "raw_sha256": "ce5284d68b8862d515d1be23b495fb070ec670720f5e03c7f01eebbd3804fad2", + "source_features_byte_match": true + }, + { + "phase": "default", + "model": "dbpedia_14-exact-uniform-s3-lr3-raw", + "batch_size": 1, + "commit": "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "rows": 34050161, + "speed_ratio": 1.797514922528617, + "p50_us": { + "baseline": 134.107, + "candidate": 73.48 + }, + "maximum_row_staging_bytes": { + "baseline": 218112, + "candidate": 218112 + }, + "raw": "raw/default/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz", + "raw_sha256": "ae9a7f83905a22e186fa0c53346998549f99908fdb5d6867ed96f9b37b65126e", + "source_features_byte_match": true + }, + { + "phase": "default", + "model": "dbpedia_14-exact-uniform-s3-lr3-raw", + "batch_size": 32, + "commit": "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "rows": 34050161, + "speed_ratio": 3.053077614236444, + "p50_us": { + "baseline": 2956.9215, + "candidate": 972.765 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 2097152 + }, + "raw": "raw/default/dbpedia_14-exact-uniform-s3-lr3-raw.json.gz", + "raw_sha256": "ae9a7f83905a22e186fa0c53346998549f99908fdb5d6867ed96f9b37b65126e", + "source_features_byte_match": true + }, + { + "phase": "default", + "model": "dbpedia_14-exact-zero-s3-lr10-raw", + "batch_size": 1, + "commit": "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "rows": 34050161, + "speed_ratio": 1.7738524555444326, + "p50_us": { + "baseline": 136.098, + "candidate": 75.365 + }, + "maximum_row_staging_bytes": { + "baseline": 218112, + "candidate": 218112 + }, + "raw": "raw/default/dbpedia_14-exact-zero-s3-lr10-raw.json.gz", + "raw_sha256": "341002cfc3863325f83aa2ca75b96ec1bfac253d08caf2bf0b0986b0d981a41b", + "source_features_byte_match": true + }, + { + "phase": "default", + "model": "dbpedia_14-exact-zero-s3-lr10-raw", + "batch_size": 32, + "commit": "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "rows": 34050161, + "speed_ratio": 3.070762229593011, + "p50_us": { + "baseline": 2922.8005, + "candidate": 954.6395 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 2097152 + }, + "raw": "raw/default/dbpedia_14-exact-zero-s3-lr10-raw.json.gz", + "raw_sha256": "341002cfc3863325f83aa2ca75b96ec1bfac253d08caf2bf0b0986b0d981a41b", + "source_features_byte_match": true + }, + { + "phase": "default", + "model": "ag_news-exact-zero-s3-lr10-zstd", + "batch_size": 32, + "commit": "4f6fa5a7a7c9e2eb42d5043784d39738150de23b", + "rows": 6989612, + "speed_ratio": 1.0063139974371131, + "p50_us": { + "baseline": 319505.1655, + "candidate": 318301.31 + }, + "maximum_row_staging_bytes": { + "baseline": 2097152, + "candidate": 2097152 + }, + "raw": "raw/default/ag_news-exact-zero-s3-lr10-zstd.json.gz", + "raw_sha256": "e6bf1b6a40b95176f773e4b405dfb22e16fcbf6670ef39440bb78483fa44ba1e", + "source_features_byte_match": true + } +] diff --git a/evidence/native_bag_vectorization_20261116/tests/local-native-o3-tests.log b/evidence/native_bag_vectorization_20261116/tests/local-native-o3-tests.log new file mode 100644 index 0000000..b2971ed --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/tests/local-native-o3-tests.log @@ -0,0 +1,50 @@ +test_atomic_replacement_keeps_old_mmap_readers_on_original_bytes (tests.test_native_rows.NativeRowsTest) ... ok +test_bag_calls_aggregate_codec_bytes_and_reset_on_rejected_input (tests.test_native_rows.NativeRowsTest) ... ok +test_byte_cap_keeps_original_ids_with_compaction_permutation_and_tail (tests.test_native_rows.NativeRowsTest) ... ok +test_cache_consumes_later_hits_before_earlier_misses_evict_them (tests.test_native_rows.NativeRowsTest) ... ok +test_cache_hash_growth_eviction_and_budget_reset_match_lru_model (tests.test_native_rows.NativeRowsTest) ... ok +test_cache_preserves_older_library_loading_when_disabled (tests.test_native_rows.NativeRowsTest) ... ok +test_cache_raw_bypass_and_failed_decode_are_not_cached (tests.test_native_rows.NativeRowsTest) ... ok +test_cache_reuses_exact_blocks_and_respects_lru_byte_budget (tests.test_native_rows.NativeRowsTest) ... ok +test_cache_uses_budget_beyond_64_entries_and_invalid_query_is_atomic (tests.test_native_rows.NativeRowsTest) ... ok +test_chunked_query_preserves_bytes_order_and_aggregates_all_counters (tests.test_native_rows.NativeRowsTest) ... ok +test_chunked_query_rejects_limits_capacities_and_late_invalid_ids (tests.test_native_rows.NativeRowsTest) ... ok +test_codec_bytes_count_whole_blocks_chunk_redecodes_cache_hits_and_raw (tests.test_native_rows.NativeRowsTest) ... ok +test_direct_raw_bags_match_staged_bytes_dtypes_weights_and_chunk_counters (tests.test_native_rows.NativeRowsTest) ... ok +test_direct_script_import_remains_compatible_with_legacy_demo_entrypoints (tests.test_native_rows.NativeRowsTest) ... ok +test_embedding_export_exposes_legacy_identity_format_option (tests.test_native_rows.NativeRowsTest) ... skipped 'optional PyTorch unavailable' +test_export_to_source_hardlink_does_not_modify_source (tests.test_native_rows.NativeRowsTest) ... ok +test_failed_flush_or_replace_preserves_target_and_cleans_temporary_file (tests.test_native_rows.NativeRowsTest) ... ok +test_failed_partial_write_never_publishes_a_partial_table (tests.test_native_rows.NativeRowsTest) ... ok +test_gather_array_matches_rows_and_rejects_bad_ids (tests.test_native_rows.NativeRowsTest) ... ok +test_implicit_header_rejects_inconsistent_counts_overflows_and_legacy_layout (tests.test_native_rows.NativeRowsTest) ... ok +test_implicit_identity_saves_exact_map_bytes_with_unchanged_codec_payloads (tests.test_native_rows.NativeRowsTest) ... ok +test_integer_grouping_matches_comparison_control_across_byte_boundaries (tests.test_native_rows.NativeRowsTest) ... ok +test_integer_xor_matches_reference_bytes_with_leading_and_trailing_zeros (tests.test_native_rows.NativeRowsTest) ... ok +test_native_coalesces_blocks_and_rejects_bad_file (tests.test_native_rows.NativeRowsTest) ... ok +test_native_preserves_arbitrary_bytes_ids_and_batches (tests.test_native_rows.NativeRowsTest) ... ok +test_native_torch_adapter_direct_output (tests.test_native_rows.NativeRowsTest) ... skipped 'optional PyTorch unavailable' +test_numpy_bag_interface_original_ids_empty_bags_output_and_validation (tests.test_native_rows.NativeRowsTest) ... ok +test_optional_fast_codecs_original_ids_odd_width_forwarding_cache_and_capabilities (tests.test_native_rows.NativeRowsTest) ... ok +test_ordinary_embedding_and_max_norm_boundary (tests.test_native_rows.NativeRowsTest) ... skipped 'optional PyTorch unavailable' +test_raw_direct_gather_preserves_forwarding_counters_and_error_output (tests.test_native_rows.NativeRowsTest) ... ok +test_row_cache_chunk_counters_and_failed_queries_preserve_output (tests.test_native_rows.NativeRowsTest) ... ok +test_row_cache_failed_decode_never_publishes_rows (tests.test_native_rows.NativeRowsTest) ... ok +test_row_cache_retains_sparse_queries_and_forwarded_aliases (tests.test_native_rows.NativeRowsTest) ... ok +test_row_packet_headers_and_queried_payloads_reject_malformed_offsets_and_masks (tests.test_native_rows.NativeRowsTest) ... ok +test_row_packets_preserve_original_ids_aliases_and_bounded_cache (tests.test_native_rows.NativeRowsTest) ... ok +test_row_packets_sparse_decode_work_and_uint32_offsets (tests.test_native_rows.NativeRowsTest) ... ok +test_small_causal_transformer_logits_match_with_untied_embedding (tests.test_native_rows.NativeRowsTest) ... skipped 'optional PyTorch unavailable' +test_small_queries_and_disabled_chunking_keep_older_library_compatibility (tests.test_native_rows.NativeRowsTest) ... ok +test_sparse_xor_prefix_keeps_full_stream_checks_and_cache_contents (tests.test_native_rows.NativeRowsTest) ... ok +test_sparse_xor_prefix_uses_forwarded_rows_and_aggregates_chunk_work (tests.test_native_rows.NativeRowsTest) ... ok +test_sparse_xor_work_accumulates_across_bags_without_changing_reductions (tests.test_native_rows.NativeRowsTest) ... ok +test_xor_codec_adapts_and_preserves_reordered_original_ids (tests.test_native_rows.NativeRowsTest) ... ok +test_xor_decoder_handles_unaligned_rows_and_word_tails (tests.test_native_rows.NativeRowsTest) ... ok +test_xor_empty_partial_blocks_and_invalid_permutations (tests.test_native_rows.NativeRowsTest) ... ok +test_xor_torch_reconstructs_nonfinite_bit_patterns (tests.test_native_rows.NativeRowsTest) ... skipped 'optional PyTorch unavailable' + +---------------------------------------------------------------------- +Ran 45 tests in 4.180s + +OK (skipped=5) diff --git a/evidence/native_bag_vectorization_20261116/tests/local-native-tests.log b/evidence/native_bag_vectorization_20261116/tests/local-native-tests.log new file mode 100644 index 0000000..bfb1e3c --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/tests/local-native-tests.log @@ -0,0 +1,50 @@ +test_atomic_replacement_keeps_old_mmap_readers_on_original_bytes (tests.test_native_rows.NativeRowsTest) ... ok +test_bag_calls_aggregate_codec_bytes_and_reset_on_rejected_input (tests.test_native_rows.NativeRowsTest) ... ok +test_byte_cap_keeps_original_ids_with_compaction_permutation_and_tail (tests.test_native_rows.NativeRowsTest) ... ok +test_cache_consumes_later_hits_before_earlier_misses_evict_them (tests.test_native_rows.NativeRowsTest) ... ok +test_cache_hash_growth_eviction_and_budget_reset_match_lru_model (tests.test_native_rows.NativeRowsTest) ... ok +test_cache_preserves_older_library_loading_when_disabled (tests.test_native_rows.NativeRowsTest) ... ok +test_cache_raw_bypass_and_failed_decode_are_not_cached (tests.test_native_rows.NativeRowsTest) ... ok +test_cache_reuses_exact_blocks_and_respects_lru_byte_budget (tests.test_native_rows.NativeRowsTest) ... ok +test_cache_uses_budget_beyond_64_entries_and_invalid_query_is_atomic (tests.test_native_rows.NativeRowsTest) ... ok +test_chunked_query_preserves_bytes_order_and_aggregates_all_counters (tests.test_native_rows.NativeRowsTest) ... ok +test_chunked_query_rejects_limits_capacities_and_late_invalid_ids (tests.test_native_rows.NativeRowsTest) ... ok +test_codec_bytes_count_whole_blocks_chunk_redecodes_cache_hits_and_raw (tests.test_native_rows.NativeRowsTest) ... ok +test_direct_raw_bags_match_staged_bytes_dtypes_weights_and_chunk_counters (tests.test_native_rows.NativeRowsTest) ... ok +test_direct_script_import_remains_compatible_with_legacy_demo_entrypoints (tests.test_native_rows.NativeRowsTest) ... ok +test_embedding_export_exposes_legacy_identity_format_option (tests.test_native_rows.NativeRowsTest) ... skipped 'optional PyTorch unavailable' +test_export_to_source_hardlink_does_not_modify_source (tests.test_native_rows.NativeRowsTest) ... ok +test_failed_flush_or_replace_preserves_target_and_cleans_temporary_file (tests.test_native_rows.NativeRowsTest) ... ok +test_failed_partial_write_never_publishes_a_partial_table (tests.test_native_rows.NativeRowsTest) ... ok +test_gather_array_matches_rows_and_rejects_bad_ids (tests.test_native_rows.NativeRowsTest) ... ok +test_implicit_header_rejects_inconsistent_counts_overflows_and_legacy_layout (tests.test_native_rows.NativeRowsTest) ... ok +test_implicit_identity_saves_exact_map_bytes_with_unchanged_codec_payloads (tests.test_native_rows.NativeRowsTest) ... ok +test_integer_grouping_matches_comparison_control_across_byte_boundaries (tests.test_native_rows.NativeRowsTest) ... ok +test_integer_xor_matches_reference_bytes_with_leading_and_trailing_zeros (tests.test_native_rows.NativeRowsTest) ... ok +test_native_coalesces_blocks_and_rejects_bad_file (tests.test_native_rows.NativeRowsTest) ... ok +test_native_preserves_arbitrary_bytes_ids_and_batches (tests.test_native_rows.NativeRowsTest) ... ok +test_native_torch_adapter_direct_output (tests.test_native_rows.NativeRowsTest) ... skipped 'optional PyTorch unavailable' +test_numpy_bag_interface_original_ids_empty_bags_output_and_validation (tests.test_native_rows.NativeRowsTest) ... ok +test_optional_fast_codecs_original_ids_odd_width_forwarding_cache_and_capabilities (tests.test_native_rows.NativeRowsTest) ... ok +test_ordinary_embedding_and_max_norm_boundary (tests.test_native_rows.NativeRowsTest) ... skipped 'optional PyTorch unavailable' +test_raw_direct_gather_preserves_forwarding_counters_and_error_output (tests.test_native_rows.NativeRowsTest) ... ok +test_row_cache_chunk_counters_and_failed_queries_preserve_output (tests.test_native_rows.NativeRowsTest) ... ok +test_row_cache_failed_decode_never_publishes_rows (tests.test_native_rows.NativeRowsTest) ... ok +test_row_cache_retains_sparse_queries_and_forwarded_aliases (tests.test_native_rows.NativeRowsTest) ... ok +test_row_packet_headers_and_queried_payloads_reject_malformed_offsets_and_masks (tests.test_native_rows.NativeRowsTest) ... ok +test_row_packets_preserve_original_ids_aliases_and_bounded_cache (tests.test_native_rows.NativeRowsTest) ... ok +test_row_packets_sparse_decode_work_and_uint32_offsets (tests.test_native_rows.NativeRowsTest) ... ok +test_small_causal_transformer_logits_match_with_untied_embedding (tests.test_native_rows.NativeRowsTest) ... skipped 'optional PyTorch unavailable' +test_small_queries_and_disabled_chunking_keep_older_library_compatibility (tests.test_native_rows.NativeRowsTest) ... ok +test_sparse_xor_prefix_keeps_full_stream_checks_and_cache_contents (tests.test_native_rows.NativeRowsTest) ... ok +test_sparse_xor_prefix_uses_forwarded_rows_and_aggregates_chunk_work (tests.test_native_rows.NativeRowsTest) ... ok +test_sparse_xor_work_accumulates_across_bags_without_changing_reductions (tests.test_native_rows.NativeRowsTest) ... ok +test_xor_codec_adapts_and_preserves_reordered_original_ids (tests.test_native_rows.NativeRowsTest) ... ok +test_xor_decoder_handles_unaligned_rows_and_word_tails (tests.test_native_rows.NativeRowsTest) ... ok +test_xor_empty_partial_blocks_and_invalid_permutations (tests.test_native_rows.NativeRowsTest) ... ok +test_xor_torch_reconstructs_nonfinite_bit_patterns (tests.test_native_rows.NativeRowsTest) ... skipped 'optional PyTorch unavailable' + +---------------------------------------------------------------------- +Ran 45 tests in 3.707s + +OK (skipped=5) diff --git a/evidence/native_bag_vectorization_20261116/tests/local-sanitizers.log b/evidence/native_bag_vectorization_20261116/tests/local-sanitizers.log new file mode 100644 index 0000000..6e2aeaf --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/tests/local-sanitizers.log @@ -0,0 +1 @@ +ASan/UBSan: versions 1/2/3/6/7, 384 mutated/truncated files, direct raw gathers and 300-block cache growth/eviction checked; optional LZ4/Zstd cases run when enabled. diff --git a/evidence/native_bag_vectorization_20261116/tests/local-unit-tests.log b/evidence/native_bag_vectorization_20261116/tests/local-unit-tests.log new file mode 100644 index 0000000..b6998eb --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/tests/local-unit-tests.log @@ -0,0 +1,64 @@ +.............sssssssss...ssssss...s..s....ssssss............sss...ssssss....s..retime-long 20 24 +.....{'llm_cpu_complete': 1, 'total': 12} +{'llm_cpu_complete': 2, 'total': 12} +{'llm_cpu_complete': 3, 'total': 12} +{'llm_cpu_complete': 4, 'total': 12} +{'llm_cpu_complete': 5, 'total': 12} +{'llm_cpu_complete': 6, 'total': 12} +{'llm_cpu_complete': 7, 'total': 12} +{'llm_cpu_complete': 8, 'total': 12} +{'llm_cpu_complete': 9, 'total': 12} +{'llm_cpu_complete': 10, 'total': 12} +{'llm_cpu_complete': 11, 'total': 12} +{'llm_cpu_complete': 12, 'total': 12} +..ssssssssssssssssssss.............s........ss...........................sssssssss.......ss...s........ssss.sssss.....sssssssssss....{'phase': 'retime-llm-gpu', 'complete': 1, 'expected': 12, 'current_failures': 0, 'gpu': 0} +{'phase': 'retime-llm-gpu', 'complete': 2, 'expected': 12, 'current_failures': 0, 'gpu': 1} +{'phase': 'retime-llm-gpu', 'complete': 3, 'expected': 12, 'current_failures': 0, 'gpu': 5} +{'phase': 'retime-llm-gpu', 'complete': 4, 'expected': 12, 'current_failures': 0, 'gpu': 3} +{'phase': 'retime-llm-gpu', 'complete': 5, 'expected': 12, 'current_failures': 0, 'gpu': 2} +{'phase': 'retime-llm-gpu', 'complete': 6, 'expected': 12, 'current_failures': 0, 'gpu': 4} +{'phase': 'retime-llm-gpu', 'complete': 7, 'expected': 12, 'current_failures': 0, 'gpu': 0} +{'phase': 'retime-llm-gpu', 'complete': 8, 'expected': 12, 'current_failures': 0, 'gpu': 1} +{'phase': 'retime-llm-gpu', 'complete': 9, 'expected': 12, 'current_failures': 0, 'gpu': 5} +{'phase': 'retime-llm-gpu', 'complete': 10, 'expected': 12, 'current_failures': 0, 'gpu': 3} +{'phase': 'retime-llm-gpu', 'complete': 11, 'expected': 12, 'current_failures': 0, 'gpu': 2} +{'phase': 'retime-llm-gpu', 'complete': 12, 'expected': 12, 'current_failures': 0, 'gpu': 4} +.....s..sss..................s..........s..s.......s.......s{"seed": 3, "backend": "source-mmap", "complete_model_bytes": 5851, "build_seconds": 0.001429459000000577} +{"seed": 3, "backend": "int8", "complete_model_bytes": 4744, "build_seconds": 0.001674749999999392} +{"seed": 3, "backend": "ngram-bounded", "complete_model_bytes": 10446, "build_seconds": 0.4201760829999994} +{"seed": 3, "backend": "ngram-int8", "complete_model_bytes": 5049, "build_seconds": 0.01190995799999861} +{"seed": 3, "backend": "precomputed-words", "complete_model_bytes": 3221, "build_seconds": 0.009124500000000424} +{"backend": "precomputed-hybrid-source", "complete_model_bytes": 5714} +{"backend": "precomputed-hybrid-int8", "complete_model_bytes": 4985} +{"backend": "precomputed-hybrid-ngram-int8", "complete_model_bytes": 5275} +.s{"counts": {"original_rows": 3004, "selected_category_rows": 3003, "empty_rows": 1, "ag_input_overlap_rows": 1, "duplicate_rows": 1, "conflicting_category_duplicate_rows": 1}, "phase_stats": {"validation": {"documents": 600, "tokens": 1200, "oov_tokens": 600, "oov_heavy_documents": 600, "attempted_oov_ngrams": 4200, "missing_oov_ngrams": 4199, "truncated_documents": 0, "class_1": 600, "unique_oov_types": 600, "date_min": "2016-12-31", "date_max": "2017-01-01"}, "test": {"documents": 2400, "tokens": 4800, "oov_tokens": 2400, "oov_heavy_documents": 2400, "attempted_oov_ngrams": 16800, "missing_oov_ngrams": 16797, "truncated_documents": 0, "class_1": 2400, "unique_oov_types": 2400, "date_min": "2016-12-31", "date_max": "2017-01-01"}}} +......s.......s.sssusage: worker [-h] --phase {retime-long,retime-llm-cpu} --job JOB --output + OUTPUT --plan PLAN [--upstream UPSTREAM] --lane LANE --cohort + {parallel-shared-host,serial-reference} [--cache CACHE] + [--cached {0,1}] [--index {datrie,hash}] [--requests REQUESTS] + {worker} +worker: error: Fresh output and empty CUDA_VISIBLE_DEVICES required +.{'phase': 'retime-long', 'complete': 20, 'expected': 24} +{'phase': 'retime-long', 'serial_references': 1, 'expected': 16} +{'phase': 'retime-long', 'complete': 20, 'expected': 24} +{'phase': 'retime-long', 'serial_references': 1, 'expected': 16} +{'phase': 'retime-long', 'complete': 20, 'expected': 24} +..................ssss.ssssssssss.{"seed": 3, "backend": "source-resident", "complete_model_bytes": 2011, "build_seconds": 0.001547249999999778} +{"seed": 3, "backend": "source-mmap", "complete_model_bytes": 2008, "build_seconds": 0.0016006659999998618} +{"seed": 3, "backend": "linear-fused", "complete_model_bytes": 2008, "build_seconds": 0.00566637499999878} +{"seed": 3, "backend": "fp16", "complete_model_bytes": 2881, "build_seconds": 0.00167575000000042} +{"seed": 3, "backend": "int8", "complete_model_bytes": 2946, "build_seconds": 0.0017377500000002044} +{"seed": 3, "backend": "ngram-bounded", "complete_model_bytes": 7989, "build_seconds": 0.03143962499999908} +{"seed": 3, "backend": "ngram-int8", "complete_model_bytes": 3604, "build_seconds": 0.0060881669999997} +{"seed": 3, "backend": "precomputed-words", "complete_model_bytes": 1670, "build_seconds": 0.008051500000000544} +....{"seed": 7, "backend": "source-mmap", "complete_model_bytes": 2014, "build_seconds": 0.0019167500000012438} +{"seed": 7, "backend": "ngram-bounded", "complete_model_bytes": 7996, "build_seconds": 0.033959458} +{"seed": 7, "backend": "ngram-int8", "complete_model_bytes": 3612, "build_seconds": 0.008004584000000037} +.s.ssssssssssssssssssssssss..{"retimed": 1, "expected": 40, "failures": 0} +{"retimed": 21, "expected": 40, "failures": 0} +{"retimed": 21, "expected": 40, "failures": 0} +........sssssss +---------------------------------------------------------------------- +Ran 381 tests in 14.853s + +OK (skipped=149) diff --git a/evidence/native_bag_vectorization_20261116/tests/package-smoke.txt b/evidence/native_bag_vectorization_20261116/tests/package-smoke.txt new file mode 100644 index 0000000..1ee3e31 --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/tests/package-smoke.txt @@ -0,0 +1 @@ +Python 3.12.14 / setuptools 84.2.1 / NumPy 2.3.5: fresh build_py package outside checkout loaded the O3 native library. NumPy original-ID bag outputs and staged/fused allocation counters passed; Torch was not imported. This is a package correctness smoke test, not a trained-table performance measurement. diff --git a/evidence/native_bag_vectorization_20261116/tests/remote-sanitizers.log b/evidence/native_bag_vectorization_20261116/tests/remote-sanitizers.log new file mode 100644 index 0000000..6e2aeaf --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/tests/remote-sanitizers.log @@ -0,0 +1 @@ +ASan/UBSan: versions 1/2/3/6/7, 384 mutated/truncated files, direct raw gathers and 300-block cache growth/eviction checked; optional LZ4/Zstd cases run when enabled. diff --git a/evidence/native_bag_vectorization_20261116/tests/remote-tests.log b/evidence/native_bag_vectorization_20261116/tests/remote-tests.log new file mode 100644 index 0000000..741b6da --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/tests/remote-tests.log @@ -0,0 +1,61 @@ +test_atomic_replacement_keeps_old_mmap_readers_on_original_bytes (tests.test_native_rows.NativeRowsTest.test_atomic_replacement_keeps_old_mmap_readers_on_original_bytes) ... ok +test_bag_calls_aggregate_codec_bytes_and_reset_on_rejected_input (tests.test_native_rows.NativeRowsTest.test_bag_calls_aggregate_codec_bytes_and_reset_on_rejected_input) ... ok +test_byte_cap_keeps_original_ids_with_compaction_permutation_and_tail (tests.test_native_rows.NativeRowsTest.test_byte_cap_keeps_original_ids_with_compaction_permutation_and_tail) ... ok +test_cache_consumes_later_hits_before_earlier_misses_evict_them (tests.test_native_rows.NativeRowsTest.test_cache_consumes_later_hits_before_earlier_misses_evict_them) ... ok +test_cache_hash_growth_eviction_and_budget_reset_match_lru_model (tests.test_native_rows.NativeRowsTest.test_cache_hash_growth_eviction_and_budget_reset_match_lru_model) ... ok +test_cache_preserves_older_library_loading_when_disabled (tests.test_native_rows.NativeRowsTest.test_cache_preserves_older_library_loading_when_disabled) ... ok +test_cache_raw_bypass_and_failed_decode_are_not_cached (tests.test_native_rows.NativeRowsTest.test_cache_raw_bypass_and_failed_decode_are_not_cached) ... ok +test_cache_reuses_exact_blocks_and_respects_lru_byte_budget (tests.test_native_rows.NativeRowsTest.test_cache_reuses_exact_blocks_and_respects_lru_byte_budget) ... ok +test_cache_uses_budget_beyond_64_entries_and_invalid_query_is_atomic (tests.test_native_rows.NativeRowsTest.test_cache_uses_budget_beyond_64_entries_and_invalid_query_is_atomic) ... ok +test_chunked_query_preserves_bytes_order_and_aggregates_all_counters (tests.test_native_rows.NativeRowsTest.test_chunked_query_preserves_bytes_order_and_aggregates_all_counters) ... ok +test_chunked_query_rejects_limits_capacities_and_late_invalid_ids (tests.test_native_rows.NativeRowsTest.test_chunked_query_rejects_limits_capacities_and_late_invalid_ids) ... ok +test_codec_bytes_count_whole_blocks_chunk_redecodes_cache_hits_and_raw (tests.test_native_rows.NativeRowsTest.test_codec_bytes_count_whole_blocks_chunk_redecodes_cache_hits_and_raw) ... ok +test_direct_raw_bags_match_staged_bytes_dtypes_weights_and_chunk_counters (tests.test_native_rows.NativeRowsTest.test_direct_raw_bags_match_staged_bytes_dtypes_weights_and_chunk_counters) ... ok +test_direct_script_import_remains_compatible_with_legacy_demo_entrypoints (tests.test_native_rows.NativeRowsTest.test_direct_script_import_remains_compatible_with_legacy_demo_entrypoints) ... ok +test_embedding_export_exposes_legacy_identity_format_option (tests.test_native_rows.NativeRowsTest.test_embedding_export_exposes_legacy_identity_format_option) ... ok +test_export_to_source_hardlink_does_not_modify_source (tests.test_native_rows.NativeRowsTest.test_export_to_source_hardlink_does_not_modify_source) ... ok +test_failed_flush_or_replace_preserves_target_and_cleans_temporary_file (tests.test_native_rows.NativeRowsTest.test_failed_flush_or_replace_preserves_target_and_cleans_temporary_file) ... ok +test_failed_partial_write_never_publishes_a_partial_table (tests.test_native_rows.NativeRowsTest.test_failed_partial_write_never_publishes_a_partial_table) ... ok +test_gather_array_matches_rows_and_rejects_bad_ids (tests.test_native_rows.NativeRowsTest.test_gather_array_matches_rows_and_rejects_bad_ids) ... ok +test_implicit_header_rejects_inconsistent_counts_overflows_and_legacy_layout (tests.test_native_rows.NativeRowsTest.test_implicit_header_rejects_inconsistent_counts_overflows_and_legacy_layout) ... ok +test_implicit_identity_saves_exact_map_bytes_with_unchanged_codec_payloads (tests.test_native_rows.NativeRowsTest.test_implicit_identity_saves_exact_map_bytes_with_unchanged_codec_payloads) ... ok +test_integer_grouping_matches_comparison_control_across_byte_boundaries (tests.test_native_rows.NativeRowsTest.test_integer_grouping_matches_comparison_control_across_byte_boundaries) ... ok +test_integer_xor_matches_reference_bytes_with_leading_and_trailing_zeros (tests.test_native_rows.NativeRowsTest.test_integer_xor_matches_reference_bytes_with_leading_and_trailing_zeros) ... ok +test_native_coalesces_blocks_and_rejects_bad_file (tests.test_native_rows.NativeRowsTest.test_native_coalesces_blocks_and_rejects_bad_file) ... ok +test_native_preserves_arbitrary_bytes_ids_and_batches (tests.test_native_rows.NativeRowsTest.test_native_preserves_arbitrary_bytes_ids_and_batches) ... ok +test_native_torch_adapter_direct_output (tests.test_native_rows.NativeRowsTest.test_native_torch_adapter_direct_output) ... ok +test_numpy_bag_interface_original_ids_empty_bags_output_and_validation (tests.test_native_rows.NativeRowsTest.test_numpy_bag_interface_original_ids_empty_bags_output_and_validation) ... ok +test_optional_fast_codecs_original_ids_odd_width_forwarding_cache_and_capabilities (tests.test_native_rows.NativeRowsTest.test_optional_fast_codecs_original_ids_odd_width_forwarding_cache_and_capabilities) ... ok +test_ordinary_embedding_and_max_norm_boundary (tests.test_native_rows.NativeRowsTest.test_ordinary_embedding_and_max_norm_boundary) ... ok +test_raw_direct_gather_preserves_forwarding_counters_and_error_output (tests.test_native_rows.NativeRowsTest.test_raw_direct_gather_preserves_forwarding_counters_and_error_output) ... ok +test_row_cache_chunk_counters_and_failed_queries_preserve_output (tests.test_native_rows.NativeRowsTest.test_row_cache_chunk_counters_and_failed_queries_preserve_output) ... ok +test_row_cache_failed_decode_never_publishes_rows (tests.test_native_rows.NativeRowsTest.test_row_cache_failed_decode_never_publishes_rows) ... ok +test_row_cache_retains_sparse_queries_and_forwarded_aliases (tests.test_native_rows.NativeRowsTest.test_row_cache_retains_sparse_queries_and_forwarded_aliases) ... ok +test_row_packet_headers_and_queried_payloads_reject_malformed_offsets_and_masks (tests.test_native_rows.NativeRowsTest.test_row_packet_headers_and_queried_payloads_reject_malformed_offsets_and_masks) ... ok +test_row_packets_preserve_original_ids_aliases_and_bounded_cache (tests.test_native_rows.NativeRowsTest.test_row_packets_preserve_original_ids_aliases_and_bounded_cache) ... ok +test_row_packets_sparse_decode_work_and_uint32_offsets (tests.test_native_rows.NativeRowsTest.test_row_packets_sparse_decode_work_and_uint32_offsets) ... ok +test_small_causal_transformer_logits_match_with_untied_embedding (tests.test_native_rows.NativeRowsTest.test_small_causal_transformer_logits_match_with_untied_embedding) ... ok +test_small_queries_and_disabled_chunking_keep_older_library_compatibility (tests.test_native_rows.NativeRowsTest.test_small_queries_and_disabled_chunking_keep_older_library_compatibility) ... ok +test_sparse_xor_prefix_keeps_full_stream_checks_and_cache_contents (tests.test_native_rows.NativeRowsTest.test_sparse_xor_prefix_keeps_full_stream_checks_and_cache_contents) ... ok +test_sparse_xor_prefix_uses_forwarded_rows_and_aggregates_chunk_work (tests.test_native_rows.NativeRowsTest.test_sparse_xor_prefix_uses_forwarded_rows_and_aggregates_chunk_work) ... ok +test_sparse_xor_work_accumulates_across_bags_without_changing_reductions (tests.test_native_rows.NativeRowsTest.test_sparse_xor_work_accumulates_across_bags_without_changing_reductions) ... ok +test_xor_codec_adapts_and_preserves_reordered_original_ids (tests.test_native_rows.NativeRowsTest.test_xor_codec_adapts_and_preserves_reordered_original_ids) ... ok +test_xor_decoder_handles_unaligned_rows_and_word_tails (tests.test_native_rows.NativeRowsTest.test_xor_decoder_handles_unaligned_rows_and_word_tails) ... ok +test_xor_empty_partial_blocks_and_invalid_permutations (tests.test_native_rows.NativeRowsTest.test_xor_empty_partial_blocks_and_invalid_permutations) ... ok +test_xor_torch_reconstructs_nonfinite_bit_patterns (tests.test_native_rows.NativeRowsTest.test_xor_torch_reconstructs_nonfinite_bit_patterns) ... ok +test_dense_compaction_and_budget_fallback_preserve_sorted_original_ids (tests.test_mapped_embedding_bag.MappedBagTest.test_dense_compaction_and_budget_fallback_preserve_sorted_original_ids) ... ok +test_fixed_noncontiguous_and_empty_bags (tests.test_mapped_embedding_bag.MappedBagTest.test_fixed_noncontiguous_and_empty_bags) ... ok +test_half_subnormals_nonfinite_values_and_owned_output (tests.test_mapped_embedding_bag.MappedBagTest.test_half_subnormals_nonfinite_values_and_owned_output) ... ok +test_native_abi_rejects_bad_capacity_offsets_dtype_and_ids (tests.test_mapped_embedding_bag.MappedBagTest.test_native_abi_rejects_bad_capacity_offsets_dtype_and_ids) ... ok +test_three_dtypes_ragged_padding_and_chunk_sizes_against_double_oracle (tests.test_mapped_embedding_bag.MappedBagTest.test_three_dtypes_ragged_padding_and_chunk_sizes_against_double_oracle) ... ok +test_trained_causal_model_uses_bag_path_without_new_parameters (tests.test_mapped_embedding_bag.MappedBagTest.test_trained_causal_model_uses_bag_path_without_new_parameters) ... ok +test_unique_queries_preserve_dense_bag_results_and_original_ids (tests.test_mapped_embedding_bag.MappedBagTest.test_unique_queries_preserve_dense_bag_results_and_original_ids) ... ok +test_weighted_inputs_reject_wrong_shape_dtype_training_and_mean (tests.test_mapped_embedding_bag.MappedBagTest.test_weighted_inputs_reject_wrong_shape_dtype_training_and_mean) ... ok +test_weighted_native_abi_checks_weight_capacity_and_null_pointer (tests.test_mapped_embedding_bag.MappedBagTest.test_weighted_native_abi_checks_weight_capacity_and_null_pointer) ... ok +test_weighted_noncontiguous_fixed_bags_and_nonfinite_scalars (tests.test_mapped_embedding_bag.MappedBagTest.test_weighted_noncontiguous_fixed_bags_and_nonfinite_scalars) ... ok +test_weighted_sum_preserves_each_occurrence_with_bounded_chunking (tests.test_mapped_embedding_bag.MappedBagTest.test_weighted_sum_preserves_each_occurrence_with_bounded_chunking) ... ok + +---------------------------------------------------------------------- +Ran 56 tests in 7.475s + +OK diff --git a/evidence/native_bag_vectorization_20261116/tests/vectorization.log b/evidence/native_bag_vectorization_20261116/tests/vectorization.log new file mode 100644 index 0000000..aa5444b --- /dev/null +++ b/evidence/native_bag_vectorization_20261116/tests/vectorization.log @@ -0,0 +1,22 @@ +native/meft_rows.c:103:11: optimized: basic block part vectorized using 16 byte vectors +native/meft_rows.c:392:23: optimized: basic block part vectorized using 16 byte vectors +native/meft_rows.c:407:19: optimized: basic block part vectorized using 16 byte vectors +native/meft_rows.c:459:27: optimized: basic block part vectorized using 16 byte vectors +native/meft_rows.c:617:30: optimized: loop vectorized using 16 byte vectors +native/meft_rows.c:617:30: optimized: loop versioned for vectorization because of possible aliasing +native/meft_rows.c:617:30: optimized: loop vectorized using 8 byte vectors +native/meft_rows.c:610:38: optimized: loop vectorized using 16 byte vectors +native/meft_rows.c:610:38: optimized: loop versioned for vectorization because of possible aliasing +native/meft_rows.c:468:20: optimized: basic block part vectorized using 16 byte vectors +native/meft_rows.c:583:38: optimized: basic block part vectorized using 16 byte vectors +native/meft_rows.c:807:30: optimized: loop vectorized using 16 byte vectors +native/meft_rows.c:790:38: optimized: loop vectorized using 16 byte vectors +native/meft_rows.c:790:38: optimized: loop vectorized using 16 byte vectors +native/meft_rows.c:771:38: optimized: loop vectorized using 16 byte vectors +native/meft_rows.c:699:20: optimized: basic block part vectorized using 16 byte vectors +native/meft_rows.c:812:20: optimized: basic block part vectorized using 16 byte vectors +native/meft_rows.c:640:20: optimized: basic block part vectorized using 16 byte vectors +native/meft_rows.c:660:20: optimized: basic block part vectorized using 16 byte vectors +native/meft_rows.c:660:70: optimized: basic block part vectorized using 16 byte vectors +native/meft_rows.c:931:24: optimized: basic block part vectorized using 16 byte vectors +native/meft_rows.c:968:25: optimized: basic block part vectorized using 16 byte vectors diff --git a/native/check_native.c b/native/check_native.c index e0e56fd..9826b9f 100644 --- a/native/check_native.c +++ b/native/check_native.c @@ -71,6 +71,7 @@ int main(int argc, char **argv) { uint64_t offsets[3] = {0, 2, 3}, bad_offsets[3] = {0, 3, 2}; (void)meft_rows_set_cache_bytes(s, 65536); unsigned char weights[12] = {0}; /* Enough LE FP32/FP16/BF16 scalar bytes. */ + (void)meft_rows_set_raw_bag_fusion(s, 1); for (int dtype = 1; dtype <= 3; ++dtype) { (void)meft_rows_embedding_bag(s, ids, 3, offsets, 2, dtype, 1, UINT64_MAX, 2, (float *)out, (size_t)width, error, sizeof(error)); diff --git a/native/meft_rows.c b/native/meft_rows.c index 19fe54a..09f55b6 100644 --- a/native/meft_rows.c +++ b/native/meft_rows.c @@ -58,8 +58,8 @@ struct meft_rows { ZSTD_DCtx *zstd_decoder; #endif uint64_t last_blocks, last_decodes, last_hits, last_row_hits; - uint64_t last_compressed_bytes, last_decoded_bytes, last_xor_bytes; - int cache_rows, implicit_identity, all_raw; + uint64_t last_compressed_bytes, last_decoded_bytes, last_xor_bytes, last_bag_staging_bytes; + int cache_rows, implicit_identity, all_raw, raw_bag_fusion; size_t cache_budget, cache_used, cache_count; size_t cache_buckets; uint64_t cache_query; @@ -249,6 +249,12 @@ uint64_t meft_rows_last_decompressions(const meft_rows *s) { return s ? s->last_ uint64_t meft_rows_last_compressed_bytes(const meft_rows *s) { return s ? s->last_compressed_bytes : 0; } uint64_t meft_rows_last_decoded_bytes(const meft_rows *s) { return s ? s->last_decoded_bytes : 0; } uint64_t meft_rows_last_xor_bytes(const meft_rows *s) { return s ? s->last_xor_bytes : 0; } +uint64_t meft_rows_last_bag_staging_bytes(const meft_rows *s) { return s ? s->last_bag_staging_bytes : 0; } +int meft_rows_set_raw_bag_fusion(meft_rows *s, int enabled) { + if (!s || (enabled != 0 && enabled != 1)) return -1; + s->raw_bag_fusion = enabled; + return 0; +} uint64_t meft_rows_last_cache_hits(const meft_rows *s) { return s ? s->last_hits : 0; } uint64_t meft_rows_last_row_cache_hits(const meft_rows *s) { return s ? s->last_row_hits : 0; } uint64_t meft_rows_cache_bytes(const meft_rows *s) { return s ? s->cache_used : 0; } @@ -315,9 +321,11 @@ static int gather_raw(meft_rows *s, size_t count, void *out) { s->raw_seen[bucket] = r->block; ++s->last_blocks; } } else if (!i || r->block != s->requests[i - 1].block) ++s->last_blocks; - uint64_t row = r->block * s->block_rows + r->within; - memcpy((unsigned char *)out + r->position * s->width, - payload + row * s->width, (size_t)s->width); + if (out) { + uint64_t row = r->block * s->block_rows + r->within; + memcpy((unsigned char *)out + r->position * s->width, + payload + row * s->width, (size_t)s->width); + } } return 0; } @@ -436,30 +444,36 @@ static int group_requests(meft_rows *s, size_t count) { qsort(s->requests, count, sizeof(*s->requests), order); return 0; } -int meft_rows_gather(meft_rows *s, const uint64_t *ids, size_t count, - void *out, size_t outbytes, char *err, size_t cap) { - if (!s) return fail(err, cap, "null store"); - s->last_blocks = s->last_decodes = s->last_hits = s->last_row_hits = 0; - s->last_compressed_bytes = s->last_decoded_bytes = s->last_xor_bytes = 0; - if (count > SIZE_MAX / s->width || count * s->width > outbytes || - count > SIZE_MAX / sizeof(struct request) || (count && (!ids || !out))) - return fail(err, cap, "invalid output capacity or query size"); - if (!count) return 0; +static int prepare_requests(meft_rows *s, const uint64_t *ids, size_t count, char *err, size_t cap) { + if (count > SIZE_MAX / sizeof(struct request)) return fail(err, cap, "query size overflow"); if (s->request_capacity < count) { void *next = realloc(s->requests, count * sizeof(*s->requests)); if (!next) return fail(err, cap, "allocation failed"); s->requests = next; s->request_capacity = count; } struct request *requests = s->requests; - const char *reason = NULL; for (size_t i = 0; i < count; ++i) { - if (ids[i] >= s->nrows) { reason = "row ID out of bounds"; goto done; } + if (ids[i] >= s->nrows) return fail(err, cap, "row ID out of bounds"); uint64_t row = s->implicit_identity ? ids[i] : le64(s->data + HEADER + ids[i] * 8); - if (row >= s->unique) { reason = "invalid forwarding ID"; goto done; } + if (row >= s->unique) return fail(err, cap, "invalid forwarding ID"); requests[i].block = row / s->block_rows; requests[i].within = row % s->block_rows; requests[i].position = i; } + return 0; +} +int meft_rows_gather(meft_rows *s, const uint64_t *ids, size_t count, + void *out, size_t outbytes, char *err, size_t cap) { + if (!s) return fail(err, cap, "null store"); + s->last_blocks = s->last_decodes = s->last_hits = s->last_row_hits = 0; + s->last_compressed_bytes = s->last_decoded_bytes = s->last_xor_bytes = s->last_bag_staging_bytes = 0; + if (count > SIZE_MAX / s->width || count * s->width > outbytes || + count > SIZE_MAX / sizeof(struct request) || (count && (!ids || !out))) + return fail(err, cap, "invalid output capacity or query size"); + if (!count) return 0; + if (prepare_requests(s, ids, count, err, cap)) return -1; + struct request *requests = s->requests; + const char *reason = NULL; #ifndef MEFT_DISABLE_RAW_GATHER if (s->all_raw && !gather_raw(s, count, out)) return 0; #endif @@ -624,7 +638,7 @@ int meft_rows_gather_chunked(meft_rows *s, const uint64_t *ids, size_t count, char *err, size_t cap) { if (!s) return fail(err, cap, "null store"); s->last_blocks = s->last_decodes = s->last_hits = s->last_row_hits = 0; - s->last_compressed_bytes = s->last_decoded_bytes = s->last_xor_bytes = 0; + s->last_compressed_bytes = s->last_decoded_bytes = s->last_xor_bytes = s->last_bag_staging_bytes = 0; if (!max_query_rows || count > SIZE_MAX / s->width || count * s->width > outbytes || count > SIZE_MAX / sizeof(uint64_t) || (count && (!ids || !out))) @@ -683,7 +697,7 @@ static int embedding_bag(meft_rows *s, const uint64_t *ids, size_t count, int weighted, const unsigned char *weights, size_t weights_bytes) { if (!s) return fail(err, cap, "null store"); s->last_blocks = s->last_decodes = s->last_hits = s->last_row_hits = 0; - s->last_compressed_bytes = s->last_decoded_bytes = s->last_xor_bytes = 0; + s->last_compressed_bytes = s->last_decoded_bytes = s->last_xor_bytes = s->last_bag_staging_bytes = 0; size_t element = dtype == 1 ? 4 : 2; if (sizeof(float) != 4 || FLT_RADIX != 2 || FLT_MANT_DIG != 24 || dtype < 1 || dtype > 3 || (mean != 0 && mean != 1) || !chunk_rows || @@ -711,9 +725,14 @@ static int embedding_bag(meft_rows *s, const uint64_t *ids, size_t count, size_t staged = count < chunk_rows ? count : chunk_rows; if (staged > SIZE_MAX / s->width) return fail(err, cap, "bag staging capacity overflow"); - unsigned char *rows = staged ? malloc(staged * (size_t)s->width) : NULL; + int direct = 0; +#if !defined(MEFT_DISABLE_RAW_GATHER) && !defined(MEFT_DISABLE_RAW_BAG) + direct = s->all_raw && s->raw_bag_fusion; +#endif + size_t staging_bytes = direct ? 0 : staged * (size_t)s->width; + unsigned char *rows = staging_bytes ? malloc(staging_bytes) : NULL; double *sum = calloc(dim, sizeof(*sum)); - if ((staged && !rows) || !sum) { + if ((staging_bytes && !rows) || !sum) { free(rows); free(sum); return fail(err, cap, "allocation failed"); } @@ -721,12 +740,27 @@ static int embedding_bag(meft_rows *s, const uint64_t *ids, size_t count, uint64_t compressed_bytes = 0, decoded_bytes = 0, xor_bytes = 0; int status = 0; size_t bag = 0, observed = 0; + const unsigned char *payload = s->data + s->desc_start + s->nblocks * DESC; /* Coalesce blocks across bag boundaries, then consume restored ID order. * Only the active bag's FP64 accumulator and chunk-sized rows are retained. * Chunk boundaries never round partial sums or reset a partially read bag. */ for (size_t start = 0; start < count;) { size_t n = count - start < staged ? count - start : staged; - status = meft_rows_gather(s, ids + start, n, rows, n * (size_t)s->width, err, cap); +#if !defined(MEFT_DISABLE_RAW_GATHER) && !defined(MEFT_DISABLE_RAW_BAG) + if (direct) { + s->last_blocks = 0; + status = prepare_requests(s, ids + start, n, err, cap); + if (!status && gather_raw(s, n, NULL)) { + /* Optional counter-index allocation can fall back to staging. */ + staging_bytes = staged * (size_t)s->width; + rows = malloc(staging_bytes); + if (!rows) status = fail(err, cap, "allocation failed"); + else direct = 0; + } + } +#endif + if (!direct && !status) + status = meft_rows_gather(s, ids + start, n, rows, n * (size_t)s->width, err, cap); blocks += s->last_blocks; decodes += s->last_decodes; hits += s->last_hits; row_hits += s->last_row_hits; compressed_bytes += s->last_compressed_bytes; decoded_bytes += s->last_decoded_bytes; xor_bytes += s->last_xor_bytes; @@ -740,8 +774,29 @@ static int embedding_bag(meft_rows *s, const uint64_t *ids, size_t count, } if (ids[start + i] == padding_id) continue; ++observed; - const unsigned char *row = rows + i * (size_t)s->width; + const unsigned char *row; + if (direct) { + struct request *r = s->requests + i; + row = payload + (r->block * s->block_rows + r->within) * s->width; + } else row = rows + i * (size_t)s->width; double scale = weighted ? row_float(weights + (start + i) * element, dtype) : 1.0; +#ifndef MEFT_DISABLE_FP32_BAG_VECTOR + if (dtype == 1) { + /* Expose independent dimensions to the compiler; the generic + * half/BF16 decoder otherwise remains a call per scalar. + * Byte assembly + memcpy preserve LE bits and unaligned rows. + * Vectorizing dimensions never changes the row accumulation + * order, FP64 products/sums or final FP32 conversion. */ + for (size_t j = 0; j < dim; ++j) { + const unsigned char *p = row + j * 4; + uint32_t bits = (uint32_t)p[0] | (uint32_t)p[1] << 8 | + (uint32_t)p[2] << 16 | (uint32_t)p[3] << 24; + float value; + memcpy(&value, &bits, sizeof(value)); + sum[j] += (double)value * scale; + } + } else +#endif for (size_t j = 0; j < dim; ++j) sum[j] += (double)row_float(row + j * element, dtype) * scale; } @@ -757,6 +812,7 @@ static int embedding_bag(meft_rows *s, const uint64_t *ids, size_t count, s->last_blocks = blocks; s->last_decodes = decodes; s->last_hits = hits; s->last_row_hits = row_hits; s->last_compressed_bytes = compressed_bytes; s->last_decoded_bytes = decoded_bytes; s->last_xor_bytes = xor_bytes; + s->last_bag_staging_bytes = status ? 0 : staging_bytes; free(rows); free(sum); return status; } diff --git a/native/meft_rows.h b/native/meft_rows.h index c25e771..a883586 100644 --- a/native/meft_rows.h +++ b/native/meft_rows.h @@ -65,7 +65,9 @@ int meft_rows_gather_chunked(meft_rows *store, const uint64_t *ids, size_t count * 3=LE bfloat16. Output is bags * (width / element_bytes) native float32. * padding_id=UINT64_MAX disables padding; otherwise that row is excluded from * both sum and mean denominator. Empty bags return zero. max_chunk_rows>0 - * bounds staged rows. Reductions accumulate in float64 in original ID order; + * bounds query scratch and staged rows. Opt-in all-raw fusion accumulates + * directly from mmap without a row matrix; default/compressed reads stage. + * Reductions accumulate in float64 in original ID order; * stored bytes stay exact, but sums are not bit-identical to float32 reduction. * Same single-worker/no-overlapping-inputs/partial-error-output contract as gather. */ @@ -123,6 +125,16 @@ uint64_t meft_rows_last_decoded_bytes(const meft_rows *store); * aggregate across chunk/bag calls; last_decoded_bytes still reports the full * stream output and does not claim reduced compressed I/O or decompression. */ uint64_t meft_rows_last_xor_bytes(const meft_rows *store); +/* Temporary row-matrix allocation capacity in the last embedding-bag call. + * All-raw fused bags use zero; compressed bags retain chunk-bounded staging. + * Excludes query indexes, FP64 accumulator, output, caches and total RSS. + * Ordinary gathers and rejected calls reset this counter to zero. */ +uint64_t meft_rows_last_bag_staging_bytes(const meft_rows *store); +/* Prefer zero row-matrix allocation for all-raw bags (1), or chunk-staged + * vectorized reduction (0, default). Compressed tables always stage chunks. + * Single-worker preference; changes neither bytes nor accumulation order. + * Returns -1 for null store/invalid boolean. */ +int meft_rows_set_raw_bag_fusion(meft_rows *store, int enabled); uint64_t meft_rows_last_cache_hits(const meft_rows *store); /* Distinct cached forwarded rows hit per gather, summed across chunk/bag calls. * Block hits remain separate and are zero in row mode (and vice versa). */ diff --git a/setup.py b/setup.py index b4bfe1e..7896375 100644 --- a/setup.py +++ b/setup.py @@ -74,7 +74,7 @@ def run(self): darwin = sys.platform == "darwin" filename = "libmeft_rows.dylib" if darwin else "libmeft_rows.so" compiler = shlex.split(os.environ.get("CC", "cc")) - command = [*compiler, "-std=c11", "-O2", "-Wall", "-Wextra", "-Werror", "-fPIC", + command = [*compiler, "-std=c11", "-O3", "-Wall", "-Wextra", "-Werror", "-fPIC", "-dynamiclib" if darwin else "-shared", str(Path(__file__).parent / "native" / "meft_rows.c"), "-lz", "-o", str(directory / filename)] # Explicit opt-in keeps portable wheels independent of libdeflate. diff --git a/tests/test_native_rows.py b/tests/test_native_rows.py index 3e1ee69..deac8e4 100644 --- a/tests/test_native_rows.py +++ b/tests/test_native_rows.py @@ -21,6 +21,76 @@ def descriptor_start(data): class NativeRowsTest(unittest.TestCase): + def test_direct_raw_bags_match_staged_bytes_dtypes_weights_and_chunk_counters(self): + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp); control = root / 'staged.so' + subprocess.run(['cc', '-std=c11', '-O2', '-fPIC', '-shared', '-DMEFT_DISABLE_RAW_BAG', '-DMEFT_DISABLE_FP32_BAG_VECTOR', + str(ROOT / 'native/meft_rows.c'), '-lz', '-o', str(control)], check=True) + ids = (ctypes.c_uint64 * 8)(36, 0, 36, 3, 0, 14, 1, 3) + offsets = (ctypes.c_uint64 * 6)(0, 0, 3, 3, 6, 8) + for dtype, element in ((1, 4), (2, 2), (3, 2)): + def encode(value): + if dtype == 1: return struct.pack('= len(codes)))): + raise ValueError('invalid original IDs') + if hashlib.sha256(ids.tobytes()).hexdigest() != record['ids_sha256']: + raise ValueError('original query changed') + docs.append(np.ascontiguousarray(ids, dtype=np.uint64)) + values = codes[ids].astype(np.float64).sum(axis=0) + if args.mode == 'mean': + values /= max(len(ids), 1) + features.append(values.astype(np.float32)) + if not docs: + raise ValueError('nonempty trace required') + inputs = [('table', args.table), ('codes', args.codes), ('traces', args.traces), + ('trace_metadata', args.traces.with_suffix('.json'))] + hashes = {} + if args.hashes_from: + parent = json.loads(args.hashes_from.read_text()) + parent_cmd = shlex.split(parent['command']) + for name, path in inputs: + if name != 'trace_metadata' and path.resolve() != Path(parent_cmd[parent_cmd.index('--' + name) + 1]).resolve(): + raise ValueError('inherited hashes must name the same frozen inputs') + hashes[name] = parent['hashes'][name] + if hashes['traces'] != digest(args.traces) or hashes['trace_metadata'] != digest(args.traces.with_suffix('.json')): + raise ValueError('inherited trace provenance changed') + else: + hashes = {name: digest(path) for name, path in inputs} + hashes.update({name: digest(path) for name, path in [('baseline_library', args.baseline_library), + ('candidate_library', args.library), ('benchmark_source', Path(__file__))]}) + report = {'commit': args.commit, 'command': shlex.join([sys.executable, *sys.argv]), + 'python': sys.version, 'numpy': np.__version__, 'os': platform.platform(), + 'cpu_affinity': sorted(os.sched_getaffinity(0)), 'loadavg': list(os.getloadavg()), + 'cpu': next(line.split(':', 1)[1].strip() for line in Path('/proc/cpuinfo').read_text().splitlines() + if line.startswith('model name')), 'device': 'cpu', 'gpu': 'unused', + 'scope': 'Paired public NumPy bag calls including validation and C reduction; warm file cache, zero native cache. Excludes tokenization, classifier head and model inference. Ratios are descriptive, not confidence intervals.', + 'cost': 'Existing CPU resources; no GPU, training or paid API. Monetary/energy cost unmeasured.', + 'trace_domain': metadata['domain'], 'rows': len(codes), 'dim': codes.shape[1], + 'row_bytes': codes.shape[1] * 4, 'chunk_rows': args.chunk_rows, 'mode': args.mode, + 'repeat': args.repeat, 'rounds': args.rounds, 'warmup': args.warmup, + 'requests': len(docs), 'rows_per_document': [len(ids) for ids in docs], + 'raw_bag_fusion': args.raw_bag_fusion, 'hashes': hashes, 'results': []} + if args.hashes_from: + report['input_hash_provenance'] = {'parent_report': str(args.hashes_from), 'parent_sha256': digest(args.hashes_from), + 'scope': 'Full table/code hashes inherited from frozen parent, not recomputed; trace hashes and every source feature output verified again.', + 'current_file_stats': {name: {'bytes': p.stat().st_size, 'mtime_ns': p.stat().st_mtime_ns, 'inode': p.stat().st_ino} for name, p in inputs}} + try: + report['torch'] = importlib.metadata.version('torch') + except importlib.metadata.PackageNotFoundError: + report['torch'] = 'unused, not installed' + for batch in args.batch_sizes: + requests = [] + for begin in range(0, len(docs), batch): + selected = docs[begin:begin + batch] + ids = np.concatenate(selected) + offsets = np.r_[0, np.cumsum([len(x) for x in selected], dtype=np.uint64)].astype(np.uint64) + expected = np.ascontiguousarray(features[begin:begin + batch]) + requests.append((ids, offsets, expected)) + case = {'batch_size': batch, 'round_results': []} + for round_id in range(args.rounds): + with NativeRows(args.table, args.baseline_library, raw_bag_fusion=args.raw_bag_fusion) as baseline, NativeRows(args.table, args.library, raw_bag_fusion=args.raw_bag_fusion) as candidate: + stores = {'baseline': baseline, 'candidate': candidate} + if any(s.header != {'n_rows': len(codes), 'row_bytes': codes.shape[1] * 4} for s in stores.values()): + raise ValueError('table/source shape mismatch') + report['decoders'] = {name: store.decoder_name for name, store in stores.items()} + output = {name: [np.empty_like(expected) for _, _, expected in requests] for name in stores} + samples = {name: [] for name in stores} + stage = {name: 0 for name in stores} + work = {name: [0] * 6 for name in stores} + for repeat in range(-args.warmup, args.repeat): + for i, (ids, offsets, expected) in enumerate(requests): + counts = {} + order = ('baseline', 'candidate') if (round_id + repeat + i) % 2 else ('candidate', 'baseline') + for name in order: + store = stores[name]; out = output[name][i] + started = time.perf_counter_ns() + store.embedding_bag_array(ids, offsets, mode=args.mode, chunk_rows=args.chunk_rows, out=out) + elapsed = (time.perf_counter_ns() - started) / 1000. + if out.tobytes() != expected.tobytes(): + raise ValueError('FP32 feature bytes differ from source FP64 reference: ' + name) + counts[name] = [store.last_block_reads, store.last_decompressions, + store.last_cache_hits, store.last_row_cache_hits, store.last_decoded_bytes, store.last_xor_bytes] + if repeat >= 0: + samples[name].append(elapsed) + stage[name] = max(stage[name], store.last_bag_staging_bytes) + work[name] = [a + b for a, b in zip(work[name], counts[name])] + if counts['baseline'] != counts['candidate']: + raise ValueError('logical read/decode work changed') + ratio = math.exp(statistics.mean(math.log(a / b) for a, b in zip(samples['baseline'], samples['candidate']))) + case['round_results'].append({'round': round_id, 'samples_us': samples, + 'p50_us': {name: statistics.median(values) for name, values in samples.items()}, + 'p95_us': {name: sorted(values)[math.ceil(.95 * len(values)) - 1] for name, values in samples.items()}, + 'paired_geometric_speed_ratio': ratio, 'maximum_row_staging_bytes': stage, + 'work_fields': ['blocks','decodes','cache_hits','row_cache_hits','decoded_bytes','xor_bytes'], + 'work': work, 'source_fp64_to_fp32_features_byte_match': True}) + case['geometric_speed_ratio'] = math.exp(statistics.mean(math.log(r['paired_geometric_speed_ratio']) for r in case['round_results'])) + report['results'].append(case) + report['status'] = 'passed' + args.output.parent.mkdir(parents=True, exist_ok=True) + args.output.write_text(json.dumps(report, indent=2, allow_nan=False) + '\n') + print(json.dumps({'output': str(args.output), 'status': 'passed', + 'speed_ratios': {r['batch_size']: r['geometric_speed_ratio'] for r in report['results']}}), flush=True) + + +if __name__ == '__main__': + main() diff --git a/tools/native_row_store.py b/tools/native_row_store.py index 53ca230..901febb 100644 --- a/tools/native_row_store.py +++ b/tools/native_row_store.py @@ -221,7 +221,7 @@ def flush(): class NativeRows: """Single-worker C handle. Library path is explicit or MEFT_ROWS_LIBRARY.""" - def __init__(self, path, library=None, cache_bytes=0, *, cache_policy="blocks"): + def __init__(self, path, library=None, cache_bytes=0, *, cache_policy="blocks", raw_bag_fusion=False): if cache_policy not in ("blocks", "rows"): raise ValueError("cache policy must be blocks or rows") library = library or os.environ.get("MEFT_ROWS_LIBRARY") @@ -238,6 +238,8 @@ def __init__(self, path, library=None, cache_bytes=0, *, cache_policy="blocks"): raise ValueError("set MEFT_ROWS_LIBRARY or pass a compiled library path") if type(cache_bytes) is not int or not 0 <= cache_bytes <= ctypes.c_size_t(-1).value: raise ValueError("cache bytes must fit a nonnegative size_t") + if type(raw_bag_fusion) is not bool: + raise ValueError("raw bag fusion must be boolean") self.lib = ctypes.CDLL(str(Path(library).resolve())) self.lib.meft_rows_open.argtypes = [ctypes.c_char_p, ctypes.c_void_p, ctypes.c_size_t] self.lib.meft_rows_open.restype = ctypes.c_void_p @@ -258,16 +260,35 @@ def __init__(self, path, library=None, cache_bytes=0, *, cache_policy="blocks"): "row_bytes": self.lib.meft_rows_width(self.handle)} # Keep zero-budget loading compatible with older compiled libraries. self.cache_policy = "blocks" - if cache_bytes or cache_policy != "blocks": + self.raw_bag_fusion = False + if cache_bytes or cache_policy != "blocks" or raw_bag_fusion: try: if cache_bytes: self.set_cache_bytes(cache_bytes) if cache_policy != "blocks": self.set_cache_policy(cache_policy) + if raw_bag_fusion: + self.set_raw_bag_fusion(True) except Exception: self.close() raise + def set_raw_bag_fusion(self, enabled): + """Trade raw row staging for direct mmap accumulation; default is staged.""" + if not self.handle: + raise ValueError("row store is closed") + if type(enabled) is not bool: + raise ValueError("raw bag fusion must be boolean") + try: + setter = self.lib.meft_rows_set_raw_bag_fusion + except AttributeError as error: + raise ValueError("raw bag fusion requires rebuilding the row library") from error + setter.argtypes = [ctypes.c_void_p, ctypes.c_int] + setter.restype = ctypes.c_int + if setter(self.handle, int(enabled)): + raise ValueError("cannot configure raw bag fusion") + self.raw_bag_fusion = enabled + def set_cache_bytes(self, budget): if not self.handle: raise ValueError("row store is closed") @@ -431,6 +452,55 @@ def rows(self, ids): self.gather_into(ctypes.addressof(query), len(ids), ctypes.addressof(output), len(output)) return output.raw + def embedding_bag_array(self, ids, offsets, *, dtype="float32", mode="sum", + padding_id=None, chunk_rows=4096, out=None): + """NumPy-only ragged sum/mean. Offsets include the terminal ID count. + + Rows are decoded as the explicitly supplied stored dtype. Accumulation + uses FP64 in original ID order and returns FP32, like the C bag ABI. + Raw fusion is opt-in; default/compressed tables stage bounded chunks. + """ + import numpy as np + if not self.handle: + raise ValueError("row store is closed") + if not isinstance(dtype, str) or dtype not in ("float32", "float16", "bfloat16") or mode not in ("sum", "mean"): + raise ValueError("supported stored dtype and sum/mean mode required") + if type(chunk_rows) is not int or not 0 < chunk_rows <= ctypes.c_size_t(-1).value: + raise ValueError("chunk rows must be a positive size_t") + query = np.asarray(ids, dtype=np.uint64) if isinstance(ids, (list, tuple)) and not ids else np.asarray(ids) + boundaries = np.asarray(offsets) + if boundaries.ndim == 1 and not len(boundaries): + raise ValueError("offsets must include an initial and terminal boundary") + if any(a.ndim != 1 or a.dtype.kind not in "iu" for a in (query, boundaries)): + raise TypeError("ids and offsets must be 1-D integer arrays") + if len(query) and (int(query.min()) < 0 or int(query.max()) >= self.header["n_rows"]): + raise IndexError("row ID out of bounds") + if (not len(boundaries) or int(boundaries[0]) != 0 or int(boundaries[-1]) != len(query) + or np.any(boundaries[1:] < boundaries[:-1])): + raise ValueError("offsets must be nondecreasing and span all IDs") + if padding_id is None: + padding_id = ctypes.c_uint64(-1).value + elif type(padding_id) is not int or not 0 <= padding_id < self.header["n_rows"]: + raise ValueError("padding ID must name an original row") + element = 4 if dtype == "float32" else 2 + width = self.header["row_bytes"] + if width % element: + raise ValueError("row width does not match stored dtype") + query = np.ascontiguousarray(query, dtype="