Repository navigation
Step1 baseline and roadmap - #2
Merged
Merged
Conversation
- Pin Vx main 7e3cf6a3 and work around its prover crash on a float branch condition in normalize (vx-lang/Vx#3145). - Record the Step 1 CPU baseline with hashes and evidence. - Add the November 8 Vx usage review and issue drafts. - Roadmap: add Step 2, converting src/data_path.c to Vx with a single sampler, ahead of the Metal work; renumber later steps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Move option checks, buffer sizing, the SplitMix64/Floyd sampler, row reads and checks, and the run into src/kmeans.vx. src/data_path.c keeps the C API, allocation, the clock, and the messages. - Replace vxvector_kmeans_v1 with v2: drop batch_size, add sampler scratch, and use the data path's sampler, so both APIs train on the same rows. - Link the Vx object into the extension for the plan (untested in Docker). - Pin Vx main df51035d. Record Step 2 with evidence; cite vx-lang/Vx#3040 and #3145 for the remaining workarounds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Pin Vx main 423a10db, 66 commits after df51035d. - The new compiler emits the same kmeans.o byte for byte, so kernel results are unchanged. Unit tests, CPU correctness, the data path under ASan and UBSan, contracts, codegen, and the 46-clause audit all pass. - vx-lang/Vx#3040 and #3145 still reproduce, so their workarounds stay. The two prover warnings without a line number now have one. - Linux, PostgreSQL, and recall are still not rerun. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…QL and recall - Build the Linux kernel object, worker, extension, and image at Vx 423a10db. This is the first build of the extension since it links the Vx object. It links, and the plan runs in the backend. - Image, extension, cancellation, rollback, snapshot, and synthetic recall checks pass. Real-data recall passes all gates on 3,072 queries. The lowest Vx mean recall rose from 0.9328 to 0.9422, and the largest shortfall against internal training fell from 0.0109 to 0.0016. - Pass the base image's platform to docker build, so an amd64 base image builds on an arm64 host. - Close the Step 2 Linux item in the roadmap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add Apple GPU kernels in src/gpu_kmeans.vx for seeding, assignment, and centroid update, and the Lloyd loop that launches them. One block owns a center and one lane owns a dimension, so updates need no atomics. - Add vxvector_gpu_l2_v1 in src/gpu_l2.c. It allocates zero-copy GPU memory with vx_metal_alloc, and refuses to run when Metal is unavailable rather than falling back to the CPU copy of the kernels. - Define the GPU policy: the CPU's seeds, tie rule, sequential float32 sums, and empty-cluster rule, with float32 instead of float64 distances. - Check 11 inputs, including 8,192 SIFT-128 vectors. Each matches the CPU kernel and an independent NumPy reference bit for bit, with exactly 2 + 2 * iterations Metal launches and no copies. Five kernel mutations are caught. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Step 3 record: macOS can stop a long launch, and the Vx runtime then aborts. Record the measured launch times, and note that the kernels' dynamic shapes get no Vx capacity check (W1029). - Add seven Vx issue drafts with standalone reproductions, none filed. - Add machines/m2-pro-16g.vx for this Mac. It produces the same code as fleet/m4-uma.vx and checks only static shapes. - Roadmap: every user trains on the CPU today, the native macOS path is untested, and a low-priority TODO records that VectorChord 1.1.1 builds but does not load on macOS 27.2.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nment - Split assignment over ranges of rows and centers, carrying each row's nearest center and distance in GPU buffers, and split the update into zero, accumulate over row ranges, and finish. Each launch does at most launch_work multiply-adds, 2^26 by default, about 2 ms on an M2 Pro. - Compare eight centers per lane at a time, so each sample value is read once per group. Distances and sums add the same terms in the same order, so results match the CPU bit for bit. - Add launch_work to vxvector_gpu_l2_v1. Nothing called it yet. - Run every check case at the default budget and split into up to 26,017 launches. All 25 runs match the CPU and NumPy bit for bit. Add a tie case inside the groups of eight. All seven kernel mutations are caught. - Stress runs that crashed before (32,768 rows, k=256) and larger ones (up to 262,144 rows, k=1,024) all pass, with no kernel above 3 ms. - On SIFT-128, training is 24x to 28x faster than a single-threaded -O3 CPU build, with the same bits. The CPU project build is -O0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add backend selection in Vx (vxvector_select_backend_reason_v1). After planning and before reading rows, it picks the GPU only when the library loads, a Metal device is ready, the request is supported (L2, one restart, no spherical, no roots), it fits the kernel limits, and CPU and GPU buffers together fit the memory budget. Otherwise auto selects the CPU with a reason, and gpu mode fails before reading any row. - Route training through one call in vxvector_run_reason_v2: the CPU kernel, or a GPU trainer with the same arguments. A GPU failure after training starts is reported and not rerun on the CPU. - Load libvxvector_gpu with dlopen, so CPU-only installs need nothing new. Add a probe with the Metal device name and a trainer adapter. - Add worker protocol version 2 with the mode, backend, reason, GPU bytes, and device. Version 1 requests still train on the CPU, so the extension is unchanged until Step 6. - Test selection with a fake GPU library, and with the real one where present: GPU and CPU workers give the same bits, and a worker killed during GPU training leaves the GPU usable. 48 native tests pass, and the Linux image and PostgreSQL checks pass on the new sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Compile src/kmeans.vx with vxc -O3 in the native and Linux builds, and record opt_level in the build manifests. Vx's default is -O0. - The bits do not change: no float operation carries fast-math flags or a fused multiply-add, and check_kernel_codegen.py now checks that at -O3. 288 of 288 option combinations match -O0 bit for bit. - CPU training through the worker on SIFT-128 is 6.0x to 6.1x faster. - Use CLOCK_MONOTONIC_RAW on macOS. CLOCK_MONOTONIC counts in microseconds there, and a fast training phase measured 0 seconds. - The native suite, codegen, contracts, and GPU checks pass. The Linux image passes its PostgreSQL checks, and real-data recall matches the -O0 run in every Vx field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The GPU trains the leaves straight into their place after the roots. The data path then trains the roots on the CPU from those leaves, as vxvector_kmeans_v2 does after its own leaves: the same sample count, seed, and options. Roots train on leaf_count rows, too few for the GPU to help. - Selection no longer sends requests with roots to the CPU. - With the real GPU, a two-level tree gives the same nodes and parents, byte for byte, as the CPU worker. 49 native tests pass, and the audit still lists 46 trusted clauses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t 2) - Add an assignment kernel for the inner product and cosine distances. It adds each dot product and squared norm in float32 in dimension order, eight centers at a time, and keeps the CPU's rules: -dot, and cosine 0 for two zero vectors and 1 when one is zero. It takes sqrt(left) * sqrt(right), because left * right can overflow float32. - Take the square root through math.sqrt in an mlir! block: a writes_only() helper may not call f32::sqrt. Metal gets precise::sqrt. - Add vxvector_gpu_train_v1 with a metric argument, and drop the metric reason from backend selection. - The GPU check runs ten cases under both new metrics, at the default and a split launch budget. All 40 of those runs, and all 67 runs of the check, match the CPU and a NumPy reference bit for bit, including SIFT-128, zero vectors, and vectors whose norm product overflows float32. Five new kernel mutations are caught. - Through the worker, inner product and cosine, with and without roots, give the same bytes as the CPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…art 3) - Each restart runs on the GPU from the CPU kernel's shifted seeds. The data path keeps the first restart, then any with a strictly lower float64 objective, as train does. The objective adds the CPU's float64 distance from each sample to its GPU label, O(rows * dims), so it equals the CPU's objective wherever the labels are the float64 nearest centers. When an earlier restart wins, the GPU assigns the sample to it again. - Add vxvector_gpu_restart_v1 and vxvector_gpu_assign_v1, and pass them to vxvector_run_v2 in struct vxvector_gpu_trainer. Drop the restarts reason. - Cosine is not always bit for bit. Nearly parallel vectors give competing cosine distances about 1e-8 apart, below float32 resolution, and the runs then diverge. On blob inputs, 4 of 6 cosine runs diverged, by at most 1.6e-4 in objective. L2 and the inner product matched in all. - Declare the tolerance: bit for bit, or every GPU label is the float64 nearest center up to a near-tie and the float64 objective is within 1e-3 of the CPU's. A cosine near-tie case uses it. L2 and inner product cases stay exact. - Test restart selection with the fake GPU, and the assignments of the best restart through vxvector_run_v2 with the real one. All four restart mutations are caught. 51 native tests and 73 GPU check runs pass. The audit lists 56 trusted clauses, the 10 new ones at the C boundary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Normalize spherical centers on the CPU between GPU launches, in float64 with the CPU kernel's arithmetic, after seeding and after each update. Vx gets vxvector_gpu_normalize_rows as a function pointer and calls vx_metal_wait() first. 21 of 24 spherical GPU runs match the CPU bit for bit. The rest met float32 near-ties, within the declared tolerance. - Build the normalization with -ffp-contract=off, and fail the build if it contains a fused multiply-add. No test data can show the change. - Drop the spherical reason: every option now trains on the GPU. - Report the GPU's allocation, copy-in, training, and copy-out time, and its library version, in the worker's version 2 reply. - Test nonfinite rows and the exact i32 size limit with the GPU selected. - On 100,000 SIFT-128 rows, every option trains 24x to 28x faster than the -O3 CPU worker, with the same bytes or a near-tie within 1.1e-5. - 97 GPU check runs, 54 native tests, and the Linux PostgreSQL checks pass. Add the Step 5 record, and mark Step 5 in the roadmap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Draft 8 (bug, follow-up to vx-lang/Vx#3153): a call through a function pointer that gets GPU memory gets no wait. A standalone program copied 1,048,576 stale values of 1,048,576 in each of 5 trials. The same memcpy, declared extern, copied none, and the IR shows the difference. - Draft 9 (bug): emit-obj resolves extern symbols in a JIT session, so a library cannot call a C function that its program defines. vxc aborts with status 134, on the CPU path too. - Draft 10 (enhancement, comment on #2690): let the CPU write GPU memory in place on unified memory, so the normalization can move into Vx. - Say in src/gpu_kmeans.vx and the Step 5 record that VxVector's explicit vx_metal_wait() is required, not a precaution. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Remove the 115 evidence files from the repository and ignore docs/evidence/. The files stay on disk. - The dated records still link to them, so those links resolve only in a checkout that has the files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Replace the CPU-only introduction with a table of what works today: SQL trains on the CPU, the standalone worker trains every option on the Apple GPU, and PostgreSQL does not use the GPU yet (Step 6). - State the near-tie tolerance and the measured speed, with its limits. - Say that the repository is private and that the work is on step1-baseline-and-roadmap until it is merged, with the checkout line. - Add an untested section on installing into an existing PostgreSQL. It follows docker/Dockerfile.extension and names the macOS VectorChord blocker and the native worker's absolute library paths. - Update the test counts, the GPU development section, and the library API. Remove the links into docs/evidence, which is no longer tracked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.