Skip to content
OpenPond
Join community
Ponder Training/Engram adapter

Engram adapter

Learn conditional n-gram memory over a frozen Qwen model.

SFT → Engram adapter uses the existing supervised Engram operation. It is not a LoRA option inside the ordinary SFT recipe. Select the exact base or saved parent module; manual continuation starts a fresh optimizer and does not enable a standard recurring policy.

Engram adds learned token-history memory inside a frozen language model. It can specialize recurring terminology without replacing the base checkpoint. The current OpenPond implementation is openpond_qwen_engram_paper_v1 on the pinned dense BF16 Qwen3-8B only. A selectable draft does not establish runtime or serving qualification. The bounded training check below establishes execution and retained learned state; it does not qualify live serving or answer quality.

Where the memory enters the model

At layers 1, 3, 7 and 15, the adapter changes the input to self-attention; the attention, MLP and output-head weights stay frozen. The expanded view is one such hook. The twelve shared tables serve all four layers, while each layer has its own projection and gates.

Each table has 90,007 buckets and width 256; the residual scale is 0.2. Tables, projections and gates total 326,861,824 learned FP32 parameters, so plan memory and artifact limits accordingly. A group contributes only when its history is complete and all four occupancy flags are present. Occupancy is recorded during training. Off returns the original attention input. Tokenization, positions and KV history belong to one request; reusing another request's history is invalid. This implementation has no DeepSeek-style compression map or convolution and makes no DeepSeek throughput claim.

The memory computation

For token position t, each history group g is hashed into four tables. The occupancy mask requires a complete history pattern and a previously seen bucket in every head:

bg,j,t=Hg,j(qg,t) mod M,M=90,007,χg,t=1[qg,t is complete]∏j=14Og,j[bg,j,t],ct=concat⁡g,j(χg,tEg,j[bg,j,t]).\begin{aligned} b_{g,j,t}&=H_{g,j}(q_{g,t})\bmod M, & M&=90{,}007,\\ \chi_{g,t}&=\mathbf{1}[q_{g,t}\text{ is complete}] \prod_{j=1}^{4}O_{g,j}[b_{g,j,t}],\\ c_t&=\operatorname{concat}_{g,j} \bigl(\chi_{g,t}E_{g,j}[b_{g,j,t}]\bigr). \end{aligned}

E contains the learned memory vectors; O contains saved occupancy flags, recorded before lookups during training. With three groups, four heads and 256 values per head, c_t has 3,072 values. At injection layer l, the projection and contextual gate produce a residual:

mℓ,t=Pℓct,zℓ,t=uℓ⊤ct+(hℓ,t⊙vℓ)⊤mℓ,td,hℓ,t′=hℓ,t+0.2 σ(zℓ,t)mℓ,t,d=4096.\begin{aligned} m_{\ell,t}&=P_\ell c_t,\\ z_{\ell,t}&=u_\ell^\top c_t+ \frac{(h_{\ell,t}\odot v_\ell)^\top m_{\ell,t}}{\sqrt d},\\ h'_{\ell,t}&=h_{\ell,t}+0.2\,\sigma(z_{\ell,t})m_{\ell,t}, & d&=4096. \end{aligned}

Here sigma is the sigmoid and the elementwise product conditions the gate on both memory and the current hidden state. Zero-initialized projections make the initial residual zero. Supervised training changes the memory, projections and gates while keeping the base parameters fixed:

ψ=(E,{Pℓ,uℓ,vℓ}ℓ),Θ=Θ0,Lsup(ψ)=−E(x,y∗)∼D[1∣y∗∣∑tlog⁡πΘ0,ψ(yt∗∣x,y<t∗)].\begin{aligned} \psi&=(E,\{P_\ell,u_\ell,v_\ell\}_\ell), &\Theta&=\Theta_0,\\ \mathcal{L}_{\mathrm{sup}}(\psi) &=-\mathbb{E}_{(x,y^*)\sim\mathcal{D}} \left[\frac{1}{|y^*|}\sum_t \log\pi_{\Theta_0,\psi}(y_t^*\mid x,y^*_{<t})\right]. \end{aligned}

The occupancy flags are retained state, not gradient-trained parameters. This is a conditional residual, not a constant low-rank weight matrix that can be merged into the base. The equations describe the mechanism; they do not imply held-out quality or qualified serving.

Measured four-step check

A short GSM8K check completed four optimizer steps on four reviewed examples and 68 target tokens, with a learning rate of 0.001 and a 1,024-token sequence limit. The trainer reported 84.206 seconds; cold download/startup took additional time. The learned module changed while the frozen base hashes stayed identical.

Actual Engram metrics show four optimizer steps, four examples, 68 target tokens and zero base optimizer and gradient parameters.

Mean training loss was 2.502762 and final loss was 1.285656. These are training summaries, not a baseline/candidate quality comparison. The producer reloaded the written learned state into a fresh CPU adapter and verified its state before publication. One saved Model version then reopened through the API and Web. The settled training debit was $0.883725 and the original GPU was deleted.

Independent GPU inference, held-out answer quality and memory On/Off serving remain unqualified. The product-terminology workflow below is illustrative.

Worked example: product terminology

Create a reviewed supervised Dataset with separate training and held-out tasks. One illustrative task is:

json
{ "input": { "question": "What is a Luma Dock used for?" }, "expectedOutput": { "text": "A Luma Dock charges Luma inspection sensors." } }

These are task fields, not a complete Dataset import. Approve one matching assistant demonstration containing the exact JSON answer, then seal the batch. Dataset instructions supply system context; the task input supplies the user payload. Grader scores and unreviewed answers cannot replace demonstrations.

  1. Open New Model, choose SFT and the Engram adapter, then Save.
  2. In Model, select the exact compatible base or supported saved Engram parent. In Dataset, select or create the Dataset and prepare its sealed supervised batch. Review attached checks in Graders.
  3. In Run settings, set steps, sequence bound and optional spending limit. Architecture is runtime-owned, not an arbitrary table editor.
  4. Save configuration retains the draft. Choose Train, inspect the preparation and explicitly approve Start to allocate training compute.

Reuse the saved draft through the SDK

Use an authenticated training client and a typed compileInput containing the saved draft's exact teamId, projectId, method: "engram_adapter", base-model query and form. Persist prepareOperationId before dispatch. This compiles and prepares the inputs for review; it does not start training.

typescript
import { canonicalComputeSpendCap } from "openpond-sdk/training"; const { form, ...scope } = compileInput; const compiled = await client.compileEngramExecution(compileInput); const { execution } = await client.prepareEngramExecution({ ...scope, operationId: prepareOperationId, name: form.name.trim(), sourceForm: form, request: compiled.request, maximumSpendUsd: canonicalComputeSpendCap(form.maximumSpendUsd), });

Inspect the preparation's exact inputs, price, spending limit and expiry before approving Start. A start command must retain this execution ID, revision, plan hash and approved price/spend; use the typed SDK or openpond training hosted-start-engram --help for that contract. Preparation alone supplies no approval. Reuse the original operation and request after a lost response, and follow cancellation through verified cleanup.

Read the same execution through the official CLI with your configured account and workspace; EXECUTION_ID is execution.id:

bash
openpond training hosted-engram-execution "$EXECUTION_ID" --team-id "$TEAM_ID" --json

Inspect the output and use the Model

The execution read returns result only after genuine completion and artifact custody. Inspect these actual fields, rather than treating the target answer above as a measured output:

FieldWhat to establish
optimizerSteps, meanLoss, finalLossActual finite supervised optimization.
baseWeightsHashBefore, baseWeightsHashAfterThe frozen base is unchanged.
baseOptimizerParameterCount, baseGradientParameterCountBoth are zero.
artifact.manifest, artifact.filesExact learned tables/projections/gates, occupancy and two-file custody.

The execution's result is absent until completion. Read its actual artifact and unchanged-base evidence; the product answer above is an illustrative target, not an execution result.

After completion, choose Save Model; the CLI equivalent is hosted-save-engram-model with an EngramResultSaveRequest. Activate compatible serving separately, then compare the same held-out request with memory On and Off. “A Luma Dock charges Luma inspection sensors” is an illustrative desired answer, not a recorded response. Also test unseen product combinations and unrelated text. Exact compatible parent continuation starts fresh optimizer state; arbitrary LoRA/steering/Engram composition and interrupted optimizer resume are not implied. Stop serving and inspect released capacity when done.

Sources and implementation boundary

Compatibility

A bounded native training check passes on the pinned Qwen base. Serving requires independent runtime and billing qualification.

View as Markdown