Scaling up to multiple vectors
So far, one vector uses D coefficients, but a real production polynomial gives us N coefficients. We can just repeat our layout in adjacent blocks! Let's give corpus vector j the physical block that starts at Dj and ends at Dj+D−1. Doing our relative reversal inside that specific block means we store logical coordinate i at:
Now, let's pair it with query position i:
Beautiful. Every single vector gets its own distinct score tap, sitting right at the right edge of its block.
query 0+corpus 7−0 = 7=7
query 1+corpus 7−1 = 6=7
query 2+corpus 7−2 = 5=7
query 3+corpus 7−3 = 4=7
Play around with the lab above as an index debugger. Try changing j and i separately. Notice how increasing i moves the stored corpus position to the left, but leaves the target totally fixed. Meanwhile, increasing j shifts the entire block—and its target—to the right by D. Those are two very different logical motions, and it's important not to mix them up.
How many vectors can we actually fit?
Our polynomial has N total coefficient positions. If D divides N evenly, we can fit N/D complete blocks. That quotient is our packing density: the exact number of corpus vectors whose scores we can read out of one single product polynomial. In production, we typically use N=4096. So at D=128, one polynomial can carry 32 corpus vectors. But at D=4096, it only has room for one!
Worked example
Dealing with a partially filled artifact
What if your corpus has 35 vectors at D=128? The first polynomial holds 32, and the second holds the remaining 3. Those unused blocks in the second artifact must be explicitly zeroed out or ignored. Just because we have the capacity doesn't mean every block holds a real, valid corpus record.
Check your understanding
If we have N=4096 and D=512, how many vectors fit, and exactly where is vector j=3 scored?
Section summary
- Vector j lives in positions Dj through Dj+D−1.
- Its coordinate i is stored precisely at Dj+D−1−i.
- We read its score tap at tⱼ=Dj+D−1.
- One polynomial can hold N/D vectors.
Repository layer · second pass
How can one query score many vectors without their blocks interfering?
Give vector j a D-wide corpus block beginning at Dj. Store its coordinate i at Dj+D−1−i. The query still occupies positions 0 through D−1. Matching pair j,i then lands at Dj+D−1, the right edge of block j.
For N coefficients and D dividing N, N/D full blocks fit. The target list is arithmetic: D−1,2D−1,3D−1,…,N−1. Packing density and extraction locations should be generated from the same parameters to prevent drift.
Reasoning chain
- 1
Choose block width D.
- 2
Place block j at base Dj.
- 3
Reverse inside that block.
- 4
Derive target tⱼ=Dj+D−1.
- 5
Check tⱼ<N and D divides N.
- 6
Generate packing and extraction from one contract.
Worked trace
Four landing strips
- Let N=16,D=4.
- Four vectors fit at bases 0,4,8,12.
- Their score taps are 3,7,11,15.
- Every matching pair for vector 2 lands at 11.
Result. One polynomial product contains four independently addressable dot products.
Executable lens · Python
Make the hidden state visible
def targets(n, d):
if n % d: raise ValueError("D must divide N")
return [d*j + d - 1 for j in range(n//d)]
assert targets(16,4) == [3,7,11,15]Retype this example, predict each intermediate value, and then change one input that touches a boundary.
Misconception clinic
Tempting mistakes
- Using Dj as the score tap instead of the right edge.
- Packing a partial block without defining padding and extraction semantics.
Retrieval and transfer
Close the book first
- Compute taps for N=4096,D=768 and explain the remainder problem.
- Derive the packed position of vector 5 coordinate 9.
- Write validation for corpus vector length and batch capacity.