Skip to content

fix: activation memory config crashes get_default() with OpenAI#1051

Open
anatolykoptev wants to merge 1 commit intoMemTensor:mainfrom
anatolykoptev:fix/default-config-activation-memory
Open

fix: activation memory config crashes get_default() with OpenAI#1051
anatolykoptev wants to merge 1 commit intoMemTensor:mainfrom
anatolykoptev:fix/default-config-activation-memory

Conversation

@anatolykoptev
Copy link

Summary

Two bugs in default_config.py that crash get_default() when enable_activation_memory=True:

Bug 1: act_mem injected into MOSConfig (extra=forbid)

get_default_config() adds act_mem dict to the config passed to MOSConfig(**config_dict), but MOSConfig has no act_mem field and inherits extra="forbid" from BaseConfig:

pydantic_core.ValidationError: 1 validation error for MOSConfig
act_mem
  Extra inputs are not permitted [type=extra_forbidden]

Bug 2: KV cache with openai backend

get_default_cube_config() hardcodes extractor_llm backend to "openai" for KV cache memory, but KVCacheMemoryConfig validator requires huggingface/huggingface_singleton/vllm (KV cache extracts internal attention tensors via build_kv_cache, which needs local model access):

ConfigurationError: KVCacheMemoryConfig requires extractor_llm backend
to be 'huggingface' or 'huggingface_singleton', got 'openai'

Reproduction

from memos.mem_os.utils.default_config import get_default

# This crashes with ValidationError
config, cube = get_default(
    openai_api_key="sk-...",
    enable_activation_memory=True,
)

Fix

  • Remove act_mem from get_default_config() — the enable_activation_memory bool flag is sufficient for MOSConfig; act_mem config belongs in MemCube config only.
  • In get_default_cube_config(), require explicit activation_memory_backend kwarg (e.g. "huggingface") instead of hardcoding "openai". Skip act_mem gracefully when no compatible local backend is provided.

Test plan

  • get_default(openai_api_key="sk-...", enable_activation_memory=True) no longer crashes
  • get_default(openai_api_key="sk-...", enable_activation_memory=True, activation_memory_backend="huggingface", activation_memory_llm_config={...}) creates valid act_mem config
  • get_default(openai_api_key="sk-...") continues to work as before

Two bugs in `get_default_config()` / `get_default_cube_config()`:

1. `get_default_config()` injects `act_mem` dict into MOSConfig when
   `enable_activation_memory=True`, but MOSConfig has no `act_mem` field
   and inherits `extra="forbid"` from BaseConfig. This causes a
   `ValidationError: Extra inputs are not permitted` for any user calling
   `get_default()` with activation memory enabled.

2. `get_default_cube_config()` hardcodes `extractor_llm` backend to
   `"openai"` for KV cache activation memory, but `KVCacheMemoryConfig`
   validator requires `huggingface`/`huggingface_singleton`/`vllm`
   (KV cache needs local model access for attention tensor extraction).
   This causes `ConfigurationError` even if bug MemTensor#1 is fixed.

Fix: Remove `act_mem` from MOSConfig dict (the `enable_activation_memory`
bool flag is sufficient). In MemCube config, require explicit
`activation_memory_backend` kwarg instead of hardcoding `"openai"`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant