diegosouzapw/OmniRoute · error · Error

No float32 tensor found in safetensors file

Error message

No float32 tensor found in safetensors file

What it means

parseSafetensors(): while scanning the safetensors header no tensor entry with dtype f32/float32 was found, so there is no embedding matrix to load — the downloaded model.safetensors is malformed or an unexpected variant.

Solutions

  1. Delete the cached model dir and re-download (corrupt file)
  2. Pin the expected artifact revision on the HF repo
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/lib/memory/embedding/staticPotion.ts:95 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/2ccb35d0ed7d24ef. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/memory/embedding/staticPotion.ts:95

  for (const [key, meta] of Object.entries(header)) {
    if (key === "__metadata__") continue;
    if (!meta.dtype || !meta.shape || !meta.data_offsets) continue;
    const dtype = meta.dtype.toLowerCase();
    if (dtype !== "f32" && dtype !== "float32") continue;

    const [startOffset, endOffset] = meta.data_offsets;
    const dataStart = 8 + headerLen + startOffset;
    const dataEnd = 8 + headerLen + endOffset;
    const dataSlice = buf.slice(dataStart, dataEnd);

    const floatCount = (dataEnd - dataStart) / 4;
    const arr = new Float32Array(floatCount);
    for (let i = 0; i < floatCount; i++) {
      arr[i] = dataSlice.readFloatLE(i * 4);
    }
    return { matrix: arr, shape: meta.shape };
  }
  throw new Error("No float32 tensor found in safetensors file");
}

async function loadModel(): Promise<PotionModel> {
  const modelDir = getModelDir();
  await fs.mkdir(modelDir, { recursive: true });

  const hfBase = `${HF_BASE}/${MODEL_ID}/resolve/main`;

  const vocabPath = path.join(modelDir, "vocab.json");
  const modelPath = path.join(modelDir, "model.safetensors");
  const tokenizerPath = path.join(modelDir, "tokenizer.json");

  await Promise.all([
    ensureFile(vocabPath, `${hfBase}/vocab.json`),
    ensureFile(modelPath, `${hfBase}/model.safetensors`),
    ensureFile(tokenizerPath, `${hfBase}/tokenizer.json`),
  ]);

View on GitHub (pinned to a179ffed5b)