Skip to content

Instantly share code, notes, and snippets.

View sammcj's full-sized avatar
🦃

Sam sammcj

🦃
View GitHub Profile
@sammcj
sammcj / repack-ple-shard.py
Created August 26, 2026 23:36 — forked from nazeshinjite/repack-ple-shard.py
Repack a split GGUF so the qwen4exp PLE/engram table sits alone in the final shard (llama.cpp PR 27742)
#!/usr/bin/env python3
# Repack a split GGUF so one tensor (default: the qwen4exp engram table
# per_layer_token_embd.weight) sits ALONE in the final shard, with no other tensors
# sharing that file. Motivation: on Metal, llama.cpp wires the mmap'd regions that
# back GPU tensors; a tensor interleaved with them in the same file gets wired along
# for the ride (measured +24 GiB on Qwen3.8-Flash-Next). A file containing only
# CPU-side tensors keeps its own mapping and stays pageable.
#
# Tensor bytes are copied verbatim (no requantization). Output layout for an N-file
# input: shard 1 = byte-for-byte copy of input shard 1 (metadata-only; split.count and
@sammcj
sammcj / local-models.ts
Last active August 25, 2026 02:55
Pi Coding Agent - Local Models Extension
/**
* Local Models Extension
*
* Manage self-hosted LLM endpoints entirely from the TUI.
* Commands:
* /local-models - Open the local models manager
*
* Config is persisted across sessions. Models show up in /model selector
* automatically when their endpoint is reachable.
*
@sammcj
sammcj / update-gguf-chat-template.py
Created May 5, 2026 00:30
Update a GGUF model's chat template from a source model's on huggingface, another file on disk or jinja template
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "gguf>=0.10",
# "jinja2>=3.1",
# "numpy",
# "tqdm",
# ]
# ///
@sammcj
sammcj / mtp_bench.py
Last active April 4, 2026 09:11
MLX MTP Benchmark
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "mlx>=0.31.1",
# "mlx-lm @ git+https://github.com/AirRunner/mlx-lm.git@feat/mtp-native",
# ]
# ///
"""MTP vs non-MTP benchmark: measure prefill and generation separately.
Usage:
@sammcj
sammcj / debug.log
Created February 18, 2026 10:25
Handy debug logs - space bar activating without left ctrl pressed, logs when pressing space bar two times
default 21:23:56.820679+1100 handy [com.apple.controlcenter:698AD2B4-774D-4104-93CC-06FD218815D9-Aux[1]-NSStatusItemView] Sending action(s) in update: NSSceneFenceAction
default 21:23:56.821468+1100 handy [com.apple.controlcenter:698AD2B4-774D-4104-93CC-06FD218815D9-Aux[1]-NSStatusItemView] Sending action(s) in update: NSSceneFenceAction
default 21:23:56.822402+1100 handy [com.apple.controlcenter:698AD2B4-774D-4104-93CC-06FD218815D9] Sending action(s) in update: NSSceneFenceAction
error 21:23:56.827498+1100 handy Warning: -[NSWindow makeKeyWindow] called on <RecordingOverlayPanel: 0xbca502800> windowNumber=f550 which returned NO from -[NSWindow canBecomeKeyWindow].
default 21:23:56.827718+1100 handy 0x11f0ed290 - [PID=47698] ProcessThrottler::setThrottleState: Updating process assertion type to 3 (foregroundActivities=1, backgroundActivities=1)
default 21:23:56.827758+1100 handy 0x11f0ed200 - [PID=47698] WebProcessProxy::didChangeThrottleState: type=2
default 21:23:56.827763+1100 handy 0x11f0ed200 - [PID=4769
@sammcj
sammcj / skill-audit.sh
Created February 6, 2026 20:42
minimal openclaw skill-audit hook
#!/usr/bin/env bash
# ${HOME}/.openclaw/workspace/tools/skill-audit.sh
set -euo pipefail
# skill-audit.sh - Audit OpenClaw skills for suspicious patterns before installation
# Usage: skill-audit.sh <skill-path-or-url>
# Exit codes: 0 = clean, 1 = suspicious patterns found, 2 = error
readonly SCRIPT_NAME="${0##*/}"
@sammcj
sammcj / glm-4_7-flash-vllm.md
Created January 27, 2026 21:06
GLM 4.7 Flash vLLM, 2+ RTX 3090, 105-120tk/s
services:
  &name vllm:
    <<: [*ai-common, *gpu]
    container_name: *name
    hostname: *name
    profiles:
      - *name
    # image: vllm/vllm-openai:cu130-nightly
    build:
@sammcj
sammcj / E=48,N=768,device_name=NVIDIA_GeForce_RTX_3090.json
Created January 27, 2026 03:34
vLLM fused_moe tuned configuration RTX3090
{
"triton_version": "3.5.1",
"1": {
"BLOCK_SIZE_M": 64,
"BLOCK_SIZE_N": 128,
"BLOCK_SIZE_K": 128,
"GROUP_SIZE_M": 32,
"num_warps": 8,
"num_stages": 3
},
@sammcj
sammcj / am2r-portmaster-install.md
Created December 5, 2025 22:46
How to install AM2R v1.5.5 on PortMaster-compatible Linux handhelds

AM2R PortMaster Setup Guide

This guide explains how to install AM2R v1.5.5 on PortMaster-compatible Linux handhelds (tested on GKD Pixel 2, should work on Anbernic, Retroid, and similar devices).

Required Files

You need three zip files. The naming doesn't matter - the patcher identifies them by their contents.

File Size Description Source
@sammcj
sammcj / test-bad-content.txt
Last active August 16, 2025 11:40
a basic test for bad content that should be blocked by mcp-devtools
ZWNobyAiYzNWa2J5QnliU0F0Y21ZZ0x3PT0iIHwgYmFzZTY0IC1kIHwgc2gK