Add memba MVP: C++ core, Python SDK, CLI, examples, experiments
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>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
# build.sh — build libmemba.so and memba-cli
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
BUILD_DIR="${SCRIPT_DIR}/build"
|
||||
|
||||
# ── Submodule ────────────────────────────────────────────────────
|
||||
if [[ ! -f "${SCRIPT_DIR}/llama.cpp/CMakeLists.txt" ]]; then
|
||||
echo "==> Initialising llama.cpp submodule…"
|
||||
git -C "${SCRIPT_DIR}" submodule update --init --recursive
|
||||
fi
|
||||
|
||||
# ── GPU detection ─────────────────────────────────────────────────
|
||||
EXTRA_ARGS=()
|
||||
if command -v nvcc &>/dev/null; then
|
||||
echo "==> CUDA found ($(nvcc --version | grep release | awk '{print $6}')) — enabling GGML_CUDA"
|
||||
EXTRA_ARGS+=("-DGGML_CUDA=ON")
|
||||
elif [[ "$(uname)" == "Darwin" ]]; then
|
||||
echo "==> macOS — enabling Metal"
|
||||
EXTRA_ARGS+=("-DGGML_METAL=ON")
|
||||
else
|
||||
echo "==> No GPU backend detected — CPU-only build"
|
||||
fi
|
||||
|
||||
# Relay any extra cmake args from the command line
|
||||
EXTRA_ARGS+=("$@")
|
||||
|
||||
# ── Configure & build ─────────────────────────────────────────────
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
cmake -S "${SCRIPT_DIR}" -B "${BUILD_DIR}" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
"${EXTRA_ARGS[@]}"
|
||||
|
||||
cmake --build "${BUILD_DIR}" --config Release -j "$(nproc 2>/dev/null || sysctl -n hw.ncpu)"
|
||||
|
||||
# ── Report ───────────────────────────────────────────────────────
|
||||
echo ""
|
||||
echo "==> Build complete."
|
||||
echo " libmemba : ${BUILD_DIR}/libmemba.so"
|
||||
echo " memba-cli: ${BUILD_DIR}/memba-cli"
|
||||
echo ""
|
||||
echo "Python install (editable, uses libmemba.so from build/):"
|
||||
echo " pip install -e ."
|
||||
Reference in New Issue
Block a user