microsoft/semantic-kernel · error · MemoryConnectorInitializationError

Dimensionality of {default_dimensionality} exceeds the maxim

Error message

Dimensionality of {default_dimensionality} exceeds the maximum allowed value of {MAX_DIMENSIONALITY}.

What it means

Raised in PineconeMemoryStore.__init__ when default_dimensionality exceeds MAX_DIMENSIONALITY (20000, the Pinecone platform limit). It is a MemoryConnectorInitializationError thrown synchronously during construction, before any Pinecone client is created. The constant is sourced from Pinecone's published known limitations.

Source

Thrown at python/semantic_kernel/connectors/memory_stores/pinecone/pinecone_memory_store.py:67

    def __init__(
        self,
        api_key: str,
        default_dimensionality: int,
        env_file_path: str | None = None,
        env_file_encoding: str | None = None,
    ) -> None:
        """Initializes a new instance of the PineconeMemoryStore class.

        Args:
            api_key (str): The Pinecone API key.
            default_dimensionality (int): The default dimensionality to use for new collections.
            env_file_path (str | None): Use the environment settings file as a fallback
                to environment variables. (Optional)
            env_file_encoding (str | None): The encoding of the environment settings file. (Optional)
        """
        if default_dimensionality > MAX_DIMENSIONALITY:
            raise MemoryConnectorInitializationError(
                f"Dimensionality of {default_dimensionality} exceeds the maximum allowed value of {MAX_DIMENSIONALITY}."
            )
        try:
            pinecone_settings = PineconeSettings(
                api_key=api_key,
                env_file_path=env_file_path,
                env_file_encoding=env_file_encoding,
            )
        except ValidationError as ex:
            raise MemoryConnectorInitializationError("Failed to create Pinecone settings.", ex) from ex

        self._default_dimensionality = default_dimensionality

        self.pinecone = Pinecone(api_key=pinecone_settings.api_key.get_secret_value())
        self.collection_names_cache = set()

    async def create_collection(
        self,

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Reduce default_dimensionality to <= 20000 by using a compatible embedding model.
  2. Validate the dimensionality value against MAX_DIMENSIONALITY before constructing the store.
  3. Confirm the embedding model's actual vector size in its spec and pass exactly that.
  4. Migrate to the non-deprecated PineconeStore + Collection API.

Example fix

// before
store = PineconeMemoryStore(api_key=key, default_dimensionality=50000)

// after
from semantic_kernel.connectors.memory_stores.pinecone.pinecone_memory_store import MAX_DIMENSIONALITY
assert dim <= MAX_DIMENSIONALITY, f"dim {dim} exceeds {MAX_DIMENSIONALITY}"
store = PineconeMemoryStore(api_key=key, default_dimensionality=dim)
Defensive patterns

Strategy: validation

Validate before calling

from semantic_kernel.connectors.memory_stores.pinecone.pinecone_memory_store import MAX_DIMENSIONALITY
if default_dimensionality > MAX_DIMENSIONALITY:
    raise ValueError(f"dimensionality {default_dimensionality} > max {MAX_DIMENSIONALITY}")
store = PineconeMemoryStore(api_key=key, default_dimensionality=default_dimensionality)

Type guard

def is_valid_dimensionality(d: int) -> bool:
    return isinstance(d, int) and 0 < d <= 20000

Try / catch

from semantic_kernel.exceptions.memory_connector_exceptions import MemoryConnectorInitializationError
try:
    store = PineconeMemoryStore(api_key=key, default_dimensionality=dim)
except MemoryConnectorInitializationError as e:
    raise SystemExit(f"bad dimensionality config: {e}") from e

Prevention

When it happens

Trigger: Constructing PineconeMemoryStore(api_key=..., default_dimensionality=N) with N > 20000. Typically a wrong embedding model dimension passed by mistake, or a value computed from config without bounds checking.

Common situations: Switching to a large-dimension embedding model and passing its dimension verbatim; reading dimensionality from an env var as a wrong type or inflated value; copy-paste of an embedding size from a different provider.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/0234e8a93b61b961. Report an issue: GitHub.