Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
f355890
docs: add MemPalace setup instructions for Kimi Code
Yasas1994 Jun 14, 2026
b4e2c56
docs: add AGENTS.md memory protocol and update MemPalace setup instru…
Yasas1994 Jun 14, 2026
325d035
chore(pytorch): replace TensorFlow optional deps with PyTorch, keep l…
Yasas1994 Jun 14, 2026
fa7de0f
feat(pytorch): add GeLU activation layer
Yasas1994 Jun 14, 2026
e5fd7a5
feat(pytorch): add MaskedConv1D with mask propagation
Yasas1994 Jun 14, 2026
4b91aa5
feat(pytorch): improve MaskedConv1D init and tests
Yasas1994 Jun 14, 2026
33970f6
feat(pytorch): add MaskedBatchNorm and MaskedLayerNorm
Yasas1994 Jun 14, 2026
b81081f
feat(pytorch): fix MaskedLayerNorm stats and lint issues
Yasas1994 Jun 14, 2026
c4d0fa8
feat(pytorch): add attention and pooling layers
Yasas1994 Jun 14, 2026
81e176e
feat(pytorch): refine pooling/attention layers and tests
Yasas1994 Jun 14, 2026
cb55bcb
feat(pytorch): add remaining custom layers and RepresentationModel
Yasas1994 Jun 14, 2026
df9123e
feat(pytorch): fix RepresentationModel and remaining layer issues
Yasas1994 Jun 14, 2026
6cf8903
feat(pytorch): add model modules (embedding, heads, JaegerModel)
Yasas1994 Jun 14, 2026
707e79e
feat(pytorch): apply positional embeddings and add ProjectionHead test
Yasas1994 Jun 14, 2026
6c61c57
feat(pytorch): add ArcFace loss
Yasas1994 Jun 14, 2026
895d454
feat(pytorch): add per-class precision/recall metrics
Yasas1994 Jun 14, 2026
e3486e0
feat(pytorch): add ModelBuilder
Yasas1994 Jun 14, 2026
4bc86d7
feat(pytorch): fix ModelBuilder contract and mask propagation
Yasas1994 Jun 14, 2026
93a1fd1
test(pytorch): add TF vs PyTorch forward parity test
Yasas1994 Jun 14, 2026
a04bc62
feat(pytorch): add NumpyFullDataset and dataset builder
Yasas1994 Jun 14, 2026
6f9ad13
feat(pytorch): wire collator and add dataset builder tests
Yasas1994 Jun 14, 2026
2ece76a
feat(pytorch): fix dataset mask shapes and add model integration test
Yasas1994 Jun 14, 2026
0bd5a64
feat(pytorch): add NumpyRawDataset and transforms
Yasas1994 Jun 14, 2026
4bcd01e
feat(pytorch): fix NumpyRawDataset labels, codon padding, and shuffle
Yasas1994 Jun 14, 2026
293f039
feat(pytorch): fix codon table and raw crop semantics
Yasas1994 Jun 14, 2026
8253c3c
feat(pytorch): add CSVDataset
Yasas1994 Jun 15, 2026
96909d8
feat(pytorch): add train_one_epoch and evaluate engine
Yasas1994 Jun 15, 2026
ad572d8
feat(pytorch): add Trainer class
Yasas1994 Jun 15, 2026
b50e44f
feat(pytorch): add EarlyStopping and ModelCheckpoint callbacks
Yasas1994 Jun 15, 2026
682f409
feat(pytorch): add distributed training helper
Yasas1994 Jun 15, 2026
31adbae
feat(pytorch): update jaeger train command for PyTorch
Yasas1994 Jun 15, 2026
53a2ca1
feat(pytorch): add PyTorch inference runner
Yasas1994 Jun 15, 2026
4833ba2
feat(pytorch): update jaeger predict command for PyTorch
Yasas1994 Jun 15, 2026
38c62c2
feat(pytorch): update SLURM scripts and Singularity container for PyT…
Yasas1994 Jun 15, 2026
6a9f878
feat(pytorch): remove legacy TensorFlow training and inference code
Yasas1994 Jun 15, 2026
41a52c0
chore(release): final QA and v1.27.1 prep
Yasas1994 Jun 15, 2026
cf1f52b
docs(mempalace): persist PyTorch migration plan and project memory co…
Yasas1994 Jun 15, 2026
2757cf0
revert: keep MemPalace/planning files untracked
Yasas1994 Jun 15, 2026
cd67bbd
feat(pytorch): complete PyTorch migration, Numba data conversion, and…
Yasas1994 Jun 15, 2026
322ca0a
feat(nnlib): native PyTorch layer registry, SiameseModel, and DVF bas…
Yasas1994 Jun 15, 2026
2a7e507
refactor(data): move pytorch dataset loaders from data/ to dataops/
Yasas1994 Jun 15, 2026
54c136f
feat(training): moving-average loss in progress bar + complete dataop…
Yasas1994 Jun 15, 2026
526c598
chore(config): untrack train_config/nn_config_500bp_dvf.yaml
Yasas1994 Jun 15, 2026
fe98769
feat(training): show cumulative epoch mean loss in progress bar
Yasas1994 Jun 15, 2026
b63bbac
feat(training): add per-batch timing profiling to train/eval loops
Yasas1994 Jun 15, 2026
2bad2c2
fix(cli): restore jaeger train command and add --profile flag
Yasas1994 Jun 15, 2026
7f504e4
fix(training): respect classifier/reliability train and validation st…
Yasas1994 Jun 15, 2026
9eeea43
fix(training): synchronize CUDA during profiling for accurate timings
Yasas1994 Jun 15, 2026
84afcf7
fix(train): guard against overwriting existing checkpoints
Yasas1994 Jun 15, 2026
035e9e7
fix(train): resume from checkpoint without device mismatch
Yasas1994 Jun 15, 2026
13f49a7
feat(nnlib): support any torch.optim optimizer by name
Yasas1994 Jun 15, 2026
75aa876
fix(train): resume from checkpoint respects last completed epoch
Yasas1994 Jun 15, 2026
6dc756e
feat(training): add ReduceLROnPlateau and TerminateOnNaN callbacks
Yasas1994 Jun 15, 2026
019643f
refactor(training): remove Trainer's built-in checkpoint save
Yasas1994 Jun 15, 2026
c8c632a
feat(training): add JsonLogger callback and remove built-in history save
Yasas1994 Jun 15, 2026
c8c16f3
feat(metrics): make classifier/reliability metrics configurable
Yasas1994 Jun 15, 2026
bda5e1d
build: add torchinfo dependency for model summary
Yasas1994 Jun 15, 2026
8e659a6
feat(nnlib): add ModelSummary wrapper around torchinfo
Yasas1994 Jun 15, 2026
0a1c406
test(summary): cover missing and failing torchinfo
Yasas1994 Jun 15, 2026
92029b5
refactor(train): extract _make_dummy_input helper
Yasas1994 Jun 15, 2026
9b8ff6e
feat(train): print torchinfo model summary before training
Yasas1994 Jun 15, 2026
d4bda43
test(train): assert model summary is logged
Yasas1994 Jun 15, 2026
94cf881
test: fix caplog capture for model summary warning tests
Yasas1994 Jun 15, 2026
0ce69ba
docs: note implementation deviations in model summary design
Yasas1994 Jun 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 170 additions & 0 deletions .agents/mempalace-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# MemPalace Setup for Kimi Code

MemPalace is configured for this project. To recreate the setup on a new machine, follow the steps below.

## 1. Install MemPalace

```bash
uv tool install mempalace
```

`pipx install mempalace` works too. Plain `pip` is fine inside an activated virtualenv.

## 2. Register the MemPalace MCP server with Kimi Code

Add to `~/.kimi-code/mcp.json`:

```json
{
"mcpServers": {
"mempalace": {
"command": "mempalace-mcp",
"args": [],
"env": {}
}
}
}
```

Use a custom palace path if needed:

```json
{
"mcpServers": {
"mempalace": {
"command": "mempalace-mcp",
"args": ["--palace", "/path/to/palace"],
"env": {}
}
}
}
```

## 3. Initialize and mine the project

From the repository root:

```bash
mempalace init . --yes
mempalace mine .
```

The project already includes a `mempalace.yaml` that maps the `jaeger` wing to the repository folders.

## 4. Verify the integration

Test the MCP server directly:

```bash
echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | mempalace-mcp | python -m json.tool
```

In a fresh Kimi Code session:

```bash
kimi -p "List the tools from the mempalace MCP server."
```

You can then ask Kimi to search the palace, e.g.:

```bash
kimi -p "Search the palace for training speed comparisons."
```

## 5. Optional — pre-approve safe MemPalace tools

Add to `~/.kimi-code/config.toml`:

```toml
[[permission.rules]]
decision = "allow"
pattern = "mcp__mempalace__status"

[[permission.rules]]
decision = "allow"
pattern = "mcp__mempalace__list_*"

[[permission.rules]]
decision = "allow"
pattern = "mcp__mempalace__search"

[[permission.rules]]
decision = "allow"
pattern = "mcp__mempalace__get_*"

[[permission.rules]]
decision = "deny"
pattern = "mcp__mempalace__delete_*"

[[permission.rules]]
decision = "deny"
pattern = "mcp__mempalace__kg_invalidate"
```

This allows read-only/search operations and keeps destructive operations behind manual approval.

## 6. Always save plans and decisions

Create `AGENTS.md` in the project root with explicit MemPalace memory instructions. Kimi Code loads it as a project-level system prompt, so every session is reminded to:

- Search the palace before answering questions about past plans or decisions.
- Save every new or updated plan to the `jaeger/plans` room via `mcp__mempalace__add_drawer`.
- Record decisions as knowledge-graph facts via `mcp__mempalace__kg_add`.
- Write a session diary entry at the end of each session via `mcp__mempalace__diary_write`.

See the current `AGENTS.md` in this repo for the exact wording.

## 7. Autosave hooks

MemPalace's autosave hooks are adapted to Kimi Code via a small shim because Kimi Code's hook JSON and transcript layout differ from Claude Code/Codex.

### 7.1 Install the shim

Create `~/.kimi-code/hooks/mempalace-autosave.py` with the contents from the project plan or from the canonical version maintained in this repository (if committed). The shim:

- Receives Kimi Code `Stop` and `PreCompact` hook events.
- Looks up the session directory in `~/.kimi-code/session_index.jsonl`.
- Converts `agents/main/wire.jsonl` to a Claude-Code-style transcript.
- Writes the transcript under `~/.mempalace/kimi_transcripts/<session_id>/` so MemPalace only mines that directory.
- Invokes `mempalace hook run --hook stop|precompact --harness claude-code`.
- Does **not** re-mine the project automatically (to avoid lock contention); run `mempalace mine .` manually after significant code changes.

Make it executable:

```bash
chmod +x ~/.kimi-code/hooks/mempalace-autosave.py
```

### 7.2 Register the hooks

Append to `~/.kimi-code/config.toml`:

```toml
[[hooks]]
event = "Stop"
command = "/home/yasas-wijesekara/.kimi-code/hooks/mempalace-autosave.py"
timeout = 60

[[hooks]]
event = "PreCompact"
command = "/home/yasas-wijesekara/.kimi-code/hooks/mempalace-autosave.py"
timeout = 60
```

Adjust the absolute path to match your home directory.

### 7.3 Verify hooks

After a fresh Kimi Code session reaches ~15 user messages, check:

```bash
tail -20 ~/.mempalace/hook_state/hook.log
```

You should see `TRIGGERING SAVE at exchange 15` and a diary checkpoint entry. Trigger `/compact` and check the log again for a `PRE-COMPACT triggered` line.

## References

- MemPalace: <https://mempalaceofficial.com/>
- MemPalace hooks guide: <https://mempalaceofficial.com/guide/hooks.html>
- Kimi Code hooks docs: <https://www.kimi.com/code/docs/en/kimi-code-cli/customization/hooks.html>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ kimi-export-*.md
# Local/test train configs
train_config/nn_config_500bp_*_test.yaml
train_config/nn_config_500bp_*_zeus_v2.yaml
train_config/nn_config_500bp_dvf.yaml
Loading
Loading