MemPalace/mempalace · error · DimensionMismatchError

qdrant collection {self._collection_name!r} expects embeddin

Error message

qdrant collection {self._collection_name!r} expects embedding dimension {remote_dim}, got {dimension}

What it means

Raised by _ensure_remote_collection() when the remote Qdrant collection already exists (possibly created by another process or an earlier session) and its stored vector size differs from the dimension of the batch being written. This is the cross-process variant of the known-dimension check: it queries the server's collection config and compares sizes.

Source

Thrown at mempalace/backends/qdrant.py:759

        with self._lock:
            self._ensure_open()
            if self._known_dimension is not None:
                if self._known_dimension != dimension:
                    raise DimensionMismatchError(
                        f"qdrant collection {self._collection_name!r} expects "
                        f"embedding dimension {self._known_dimension}, got {dimension}"
                    )
                return
            if not self._remote_exists():
                self._client.create_collection(self._remote_collection, dimension)
                self._client.create_payload_index(
                    self._remote_collection, _PAYLOAD_DOCUMENT, "text"
                )
                self._known_dimension = dimension
                return
            remote_dim = self._remote_dimension()
            if remote_dim is not None and remote_dim != dimension:
                raise DimensionMismatchError(
                    f"qdrant collection {self._collection_name!r} expects "
                    f"embedding dimension {remote_dim}, got {dimension}"
                )
            self._known_dimension = remote_dim or dimension

    def _scroll_all(
        self,
        *,
        qdrant_filter: Optional[dict] = None,
        with_vector: bool = False,
    ) -> list[dict]:
        self._ensure_open()
        if not self._remote_exists():
            if self._marker_exists():
                raise CollectionNotInitializedError(self._collection_name)
            return []
        rows = []
        offset = None

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Inspect the remote collection: GET /collections/<name> and read result.config.params.vectors.size
  2. Align your embed model with that size, or migrate: create a new collection with the new model and re-ingest
  3. If the remote collection is stale/wrong, delete it in Qdrant AND remove the local marker so the backend recreates it
  4. Ensure every client of the shared Qdrant server pins the same embedding model via embedder identity

Example fix

# before
# remote collection exists at 768; embedding with 384-dim model:
col.upsert(documents=docs, ids=ids, embeddings=embed384)  # DimensionMismatchError
# after
embed768 = [model_768.embed(d) for d in docs]
col.upsert(documents=docs, ids=ids, embeddings=embed768)
Defensive patterns

Strategy: try-catch

Try / catch

from mempalace.backends.base import DimensionMismatchError
try:
    collection.upsert(...)
except DimensionMismatchError as e:
    remote_size = collection._remote_dimension()  # decide: re-embed or revert model

Prevention

When it happens

Trigger: Process A created the collection at 768 dims; process B (or the same process after a restart, before _known_dimension was cached) calls upsert with 384-dim embeddings. Also when someone manually recreated the collection in Qdrant with a different size, or a different palace points at the same remote collection name.

Common situations: Embedding model changed between sessions; multiple machines/processes sharing one Qdrant server with different model configs; manual collection recreation in the Qdrant dashboard; restoring a Qdrant volume from another setup.

Related errors


AI-assisted analysis of MemPalace/mempalace@06cb6987f0 (2026-08-15). Data as JSON: /api/errors/aa8c7a88dd6720b6. Report an issue: GitHub.