Skip to main content

HomOps Reference

Repeat

Tile a short vector to fill every slot before encryption. Client side only.

RpClient
RunsClient only
Changes shapeYes - (k,) becomes (n_slots,)
Changes scaleNo
Levels spent0
RotatesNo
KeysNone

What it does

Repeat takes a 1D vector shorter than the slot count and tiles it, end to end, until every slot is filled. A query of length 64 with 4096 slots becomes 64 values repeated 64 times.
It is a client-only preprocessing step, placed in client_pre right before encryption. Its standard partner is HomExpand: repeat fills the slots on the client, expand then builds the k-wide axis on the server. Search and similarity pipelines open with exactly this pair. When the query is encrypted in a sub-ring (smaller than the search ring), HomRingSwitch must be the first server operator; expand follows the lift.
If the input already fills all slots, it passes through unchanged.
Without Repeat, a short input is filled out with zeros instead of repeated.

Signature

Repeat(dim=0)
Choose dim to select the axis tiled into the packing layout. No set_data.

Parameters

ParameterTypeDefaultDescription
dimint0Axis of the input vector (or selected input axis) to tile until it fills the packing layout.

Requirements

  • 1D input. The vector must be one-dimensional; reshape first if needed.
  • Even division. The slot count must be a multiple of the input length, so the tiling comes out exact.
  • Client placement. client_pre, before encryption; the server never runs it.

Shape effect - yes

Rule: (k,) becomes (n_slots,), the input tiled n_slots / k times.
Slot countInput lengthOutput
409664(4096,) - 64 values repeated 64 times
819264(8192,) - repeated 128 times
512512(512,) - already full, unchanged
pt_shape: (64,)user query
client_preRepeat
pt_shape: (4096,)every slot filled
encrypt → server takes it from hereHomExpand(k=64, ...)

Scale effect - no

Repeat runs on cleartext before encryption; the scale is set at encrypt time, after it.

Level budget

Zero. Nothing encrypted happens here.

Keys

None.

Example

The opening of the exact-search pipeline: repeat the query on the client, expand it on the server:
pipeline.pyPYTHON
from lattica_build.client_ops import Repeat
from lattica_build.operators import HomExpand, HomConstMul
from lattica_build.base_classes.hom_pipeline import HomomorphicPipeline
from lattica_build.operators.composite.sequential import SequentialHomOp

pipeline = HomomorphicPipeline(
    client_pre=[Repeat()],
    hom=SequentialHomOp(
        HomExpand(k=64, k_axis=1, stage_sizes=[4, 4, 4], stages_per_level=3),
        HomConstMul(dims=db.shape, with_modswitch=True),
        # ... reductions follow
    ),
    input_shape=(N_SLOTS,),
)

See also

  • HomRingSwitch - first server operator when the query is encrypted in a sub-ring
  • HomExpand - the server-side replication that usually follows
  • HomReshape - general client-side layout changes
  • Ciphertext state - slots and how data is packed into them