19One plan, every fan-out — the model stage writes the same bytes at any width
Verbs:generate_embeddings under [inference] partitions = 1, 2, 4 · describe_table (artifact, definition_hash) · Background: a parallel plan is deterministic when the unit of work is fixed before the work is distributed (Kleppmann 2017) · Checked: measurement (every verdict an equality).
A model stage attached to a query engine as a user-defined function sees whatever batches the engine hands it. How rows are grouped then depends on the partition count and on how the exchanges above it re-batch, so a padded forward over a different grouping produces different bytes. In jammi, the model stage is a plan operator (InferenceExec), so it can fix the grouping before any rows are distributed:
Rows are costed once. Each row’s cost is its length along the axis a forward pads (its token count for text). The numbered input orders rows by cost, then key.
Chunks are cut once. The ordered rows are cut into forward chunks under the chunk budget (batch_size rows, batch_tokens padded tokens), and each row carries its chunk id.
The exchange hashes on the chunk id. A fan-out of N partitions distributes whole chunks, never dividing one. The InferenceFanOut rule keeps that exchange at the node’s own declared width through DataFusion’s own distribution enforcement.
So every partition count forwards identical chunks and writes identical bytes. This chapter measures that: the same embedding plan over the same 24-row corpus, run at partitions 1, 2 and 4, each in a fresh catalog.
19.1 The corpus and the three runs
The rows are one to fourteen words long — the lengths are what the chunk cut orders on, so they are deliberately uneven. batch_size = 4 makes every fan-out forward several chunks.
import tempfilefrom pathlib import Pathimport jammiimport pyarrow as paimport pyarrow.parquet as pqfrom jammi_cookbook import fixturesfrom jammi_cookbook.claims import claimMODEL = fixtures.model("tiny_bert")PARTITIONS = (1, 2, 4)BATCH_SIZE =4docs = pa.table({"_row_id": [f"d{i:02d}"for i inrange(24)],"text": ["graph","signal processing on graphs","a spectral filter applied to node features over the normalized laplacian","message passing","random walks with restart as a personalized ranking","edge weights","attention over neighbours weights each message by a learned compatibility score","pooling","a laplacian eigenmap embeds nodes by the smallest nontrivial eigenvectors","k nearest neighbours","propagation smooths a signal along the edges of the graph","label spreading","a node embedding","the adjacency matrix and its powers count walks between node pairs","diffusion","graph convolution as a first order polynomial of the laplacian","readout","a heterogeneous graph carries typed nodes and typed edges","clustering coefficient","spectral clustering partitions the graph by the fiedler vector of its laplacian","homophily","over smoothing makes deep propagation collapse node representations together","subgraph sampling","the incidence matrix relates edges to their endpoints", ],})def embed_at(partitions: int) ->dict:"""Embed the corpus in a fresh catalog fanned over `partitions`, and read back what the table recorded about itself."""with tempfile.TemporaryDirectory() as tmp: corpus = Path(tmp) /"docs.parquet" pq.write_table(docs, corpus) config = Path(tmp) /"jammi.toml" config.write_text(f"[inference]\npartitions = {partitions}\nbatch_size = {BATCH_SIZE}\n" )with jammi.connect(f"file://{tmp}/catalog", config=str(config)) as db: db.add_source("docs", url=str(corpus), format="parquet") table = db.generate_embeddings( source="docs", model=MODEL, columns=["text"], key="_row_id" ) recorded = db.describe_table(table)return {"partitions": partitions,"artifact": recorded["artifact"],"definition_hash": recorded["definition_hash"], }runs = [embed_at(n) for n in PARTITIONS]for run in runs:print(f"partitions={run['partitions']} artifact={run['artifact']}")
2026-10-03T07:42:13.914643Z WARN jammi_kernels::admission: fused-kernel domain check failed; falling back to the eager composition op="attention_block_fused" predicate="head_dim_is_attention_block_fixed_head_dim"
describe_table returns a table’s recorded materialization: its artifact digest covers the table’s Parquet bytes, so equal digests mean equal bytes; its definition hash is the recorded identity of what produced the table. The definition is the same across runs because the partition count changes how the work is spread, not what is computed.
reference = runs[0]for run in runs[1:]: claim(f"{run['partitions']} partitions write the same bytes as one", run["artifact"] == reference["artifact"])claim("every fan-out is one definition", len({r["definition_hash"] for r in runs}) ==1)
✓ 2 partitions write the same bytes as one
✓ 4 partitions write the same bytes as one
✓ every fan-out is one definition
19.3 Why this matters beyond one table
Reuse is safe at any width. A table materialized at one fan-out is the cached answer for the same definition at another. The definition hash doesn’t carry the partition count, and the bytes it names don’t depend on it.
Verification is width-independent.verify_materialization recomputes an artifact digest; a verifier running a different fan-out than the producer still gets a match.
The mechanism lives in crates/jammi-datafusion/src/inference/ (numbered.rs numbers and cuts; exec.rs holds InferenceExec and InferenceFanOut). The guide’s Built on DataFusion page maps it among the engine’s other extensions of DataFusion.
Kleppmann, Martin. 2017. Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems. O’Reilly Media.