AGENT SKILL

training-and-compression

This skill teaches a Researcher to train, compose, inspect, and troubleshoot Faiss compressed and binary indexes while preserving codec, dimension, and backend constraints.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
training-and-compression
license
MIT
metadata
{ "disco-role": "operating" }
description
This skill teaches a Researcher to train, compose, inspect, and troubleshoot Faiss compressed and binary indexes while preserving codec, dimension, and backend constraints.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

Training and compression

Use this branch when the request involves training or adding compressed codes, PQ/SQ/IVF-PQ, residual or additive quantization, RaBitQ, OPQ and other transforms, PQ fast scan, standalone codecs, reconstruction, code size, or binary/Hamming indexes. The CPU baseline is the verified Faiss 1.15.0 package (Python >=3.10, NumPy float32 arrays, OPTIMIZE DD AVX2). Treat every CUDA, cuVS, ROCm, Metal, or SVS claim as conditional until the runtime probe in the accelerated sibling succeeds.

Route first

This branch owns the codec lifecycle and the compressed representation. It does not choose a general index family, own custom IDs/selectors, or certify optional accelerators.

Operating procedure

  1. Normalize the input as a contiguous float32 matrix of shape (n, d) for float indexes, or a contiguous uint8 matrix of shape (n, d // 8) for binary indexes. Binary dimension must be a multiple of eight; do not pass unpacked boolean/float bits to an IndexBinary.

  2. Select a factory or explicit class only after checking the constraints and code-size formulas in api-reference.md. Keep metric and transform dimensions consistent through the whole chain.

  3. Keep a representative, finite training sample separate from the database. Call train(training_vectors) before add(database_vectors) whenever is_trained is false. Training data needs enough examples for the coarse centroids and every codec; a small smoke may warn, but production training should not ignore those warnings.

  4. Add only vectors with the input dimension expected by the outer index. For an IVF codec, Faiss trains the coarse quantizer and encoder as part of the outer lifecycle; do not manually add to an untrained IVF-PQ/SQ index.

  5. Search with a deliberately chosen nprobe (IVF) and k; then measure against an exact baseline before trading bits, subquantizers, or probes. Compression changes recall and reconstructed values even when the API succeeds.

  6. If a caller needs bytes, use sa_encode/sa_decode with uint8 arrays of exactly sa_code_size() columns. reconstruct and decoded values are approximations for lossy PQ/SQ/RQ/AQ/RaBitQ codecs; they are not the original vectors. RaBitQ's sa_decode is suitable for its IP-oriented codec representation but is explicitly not a reliable L2 reconstruction oracle; use its search path for L2.

  7. For a recall/latency compromise, first improve the candidate set (for example IVF nprobe), then add a refinement stage owned by the composition sibling. Refinement requires a compatible reconstructable/exact storage choice and must not be used to hide an untrained or dimension-invalid base index.

  8. Run the bundled no-network check when validating a small configuration:

    python /path/to/training-and-compression/scripts/smoke_codecs.py --help
    python /path/to/training-and-compression/scripts/smoke_codecs.py
    

    It uses deterministic tiny data and returns nonzero for invalid factory, dimension, metric, or binary input. It is a smoke, not a benchmark.

Fast scan and optional features

PQ/AQ fast scan is a storage/layout specialization, not a replacement for training or recall evaluation. The verified family is 4-bit PQ/AQ with a block size divisible by 32 (default 32); it repacks codes into blocks and may pad the final block. SIMD dispatch can select a different implementation or a scalar fallback. Do not infer that a fast-scan factory is available merely because the host has a GPU or because an unrelated SIMD level is present.

Residual, additive, product-residual, LSQ, and RaBitQ families expose more parameters than the compact examples here. Use the API and workflow tables, then run a tiny CPU trial before adopting one. GPU codec behavior belongs to the accelerated sibling and is unverified by this CPU branch.

Recovery routing

For invalid IVF.../PQ strings, wrong d % M, too few training points, unsupported fast-scan blocks, bad byte shapes, or reconstruction surprises, start with troubleshooting.md. Preserve the original failing configuration and error; repair one constraint at a time. For a high-level factory replacement route to the index-selection sibling, for staged refinement route to composition, and for recall/memory evidence route to persistence-and-evaluation.

Bundled references

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351