C++ core (libmemba.so): - include/memba/state.h — C API (state_new/free/save/load/get_size) - src/state.cpp — MEMB file format: magic, version, SHA-256 model_id, CRC-32, opaque llama_state_*_data() blob - src/cli.cpp — minimal demo binary with greedy sampler - CMakeLists.txt + build.sh with llama.cpp submodule, CUDA auto-detect Python SDK (memba): - core.py — file I/O via llama-cpp-python's exposed C functions, unwraps _LlamaContext to access raw context pointer (≥0.3.x) - session.py — high-level Session with auto-save/load, ChatML wrapper for instruct models, raw mode for base models - cli.py — typer-based: chat (REPL), run (one-shot), list, rm, info Examples: - 01_basic_save_load.py, 02_chat_session.py Experiments (throwaway POCs documenting product-direction findings): - recall_poc.py — git log → state → cross-process query - mood_poc.py — batch sentiment trajectory, Mamba vs Transformer - mood_stream_poc.py, mood_batch_poc.py — variants - diag_saveload.py — minimal save/load isolation test - README.md documents the headline finding: save/load is byte-identical, but Falcon-Mamba-7B-Instruct does not retain facts across conversation turns even in-process — limits viable products to single-prompt analysis and persona priming. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
50 lines
1.8 KiB
CMake
50 lines
1.8 KiB
CMake
cmake_minimum_required(VERSION 3.14)
|
|
project(memba VERSION 0.1.0 LANGUAGES CXX C)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
# ── llama.cpp submodule ──────────────────────────────────────────
|
|
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/llama.cpp/CMakeLists.txt")
|
|
message(FATAL_ERROR
|
|
"llama.cpp submodule not initialised.\n"
|
|
"Run: git submodule update --init --recursive")
|
|
endif()
|
|
|
|
set(LLAMA_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
|
set(LLAMA_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
|
set(LLAMA_BUILD_SERVER OFF CACHE BOOL "" FORCE)
|
|
add_subdirectory(llama.cpp)
|
|
|
|
# ── libmemba (shared) ────────────────────────────────────────────
|
|
add_library(memba SHARED src/state.cpp)
|
|
|
|
target_include_directories(memba
|
|
PUBLIC include
|
|
PRIVATE llama.cpp/include
|
|
)
|
|
target_link_libraries(memba PRIVATE llama)
|
|
|
|
set_target_properties(memba PROPERTIES
|
|
OUTPUT_NAME memba
|
|
VERSION ${PROJECT_VERSION}
|
|
SOVERSION 0
|
|
)
|
|
|
|
# ── memba-cli ────────────────────────────────────────────────────
|
|
add_executable(memba-cli src/cli.cpp)
|
|
|
|
target_include_directories(memba-cli
|
|
PRIVATE include
|
|
llama.cpp/include
|
|
)
|
|
target_link_libraries(memba-cli PRIVATE memba llama)
|
|
|
|
# ── Install ──────────────────────────────────────────────────────
|
|
install(TARGETS memba memba-cli
|
|
LIBRARY DESTINATION lib
|
|
RUNTIME DESTINATION bin
|
|
)
|
|
install(FILES include/memba/state.h DESTINATION include/memba)
|