How truekiwwy/llm-surgeon works
LLM Surgeon is a Rust command-line model-surgery tool with MCP access and desktop interfaces. The main user workflow is to inspect local model files and machine capacity, derive or supply a steering direction or patch, apply the edit with backup/rollback safeguards, then evaluate the result. Separate capabilities include graph analysis, LoRA and checkpoint-diff operations, automated patch pipelines, plugins, and agent tools. The sampled sources support the core orchestration and several subsystem links; unsampled GUI and other modules are included from the tree and README, with uncertain connections omitted.
Main entry points: app.rs Command orchestration · patch/mod.rs Patch apply and restore · extract/mod.rs Direction extraction · eval/mod.rs Model evaluation
Components 19
User interfaces
- CLI commands
src/cli.rs - Command orchestration
src/app.rs - Desktop app
crates/surgeon-gui/src/app.rs - Terminal interface
src/tui/app.rs
Model analysis
- Local model files
- Hardware budget
src/hardware/mod.rs - Direction extraction
src/extract/mod.rs - Weight graph
src/graph/mod.rs
Weight editing
- Patch apply and restore
src/patch/mod.rs - GGUF editing
src/patch/gguf/mod.rs - SafeTensors engine
src/engine/mod.rs - Checkpoint surgery
src/surgery/mod.rs - LoRA operations
src/lora/mod.rs
Generation and evaluation
- Generation backends
src/backend/mod.rs - Model evaluation
src/eval/mod.rs
Automation and extensions
- Patch pipeline
src/pipeline/run.rs - MCP server and tools
src/mcp/server.rs - Extraction plugins
src/plugin/mod.rs
Other components
- User
Connections 27
- User → CLI commands: runs commands
README.md - User → Desktop app: uses desktop
README.md - User → Terminal interface: uses terminal
- CLI commands → Command orchestration: dispatches to
src/app.rs - Command orchestration → Hardware budget: checks capacity
src/app.rs - Command orchestration → Direction extraction: runs extraction
src/app.rs - Command orchestration → Patch apply and restore: applies patches
src/app.rs - Command orchestration → Model evaluation: runs evaluation
src/app.rs - Command orchestration → Patch pipeline: runs pipeline
src/pipeline/front.rs - Local model files → Hardware budget: measures size
src/hardware/mod.rs - Local model files → Direction extraction: captures activations
src/extract/mod.rs - Local model files → Weight graph: analyzes weights
README.md - Direction extraction → Patch apply and restore: supplies direction
README.md - Patch apply and restore → SafeTensors engine: edits tensors
src/engine/mod.rs - Patch apply and restore → GGUF editing: applies GGUF edits
src/patch/mod.rs - Patch apply and restore → Local model files: writes edited weights
README.md - Checkpoint surgery → Local model files: reads checkpoints
README.md - LoRA operations → Local model files: merges adapters
README.md - Command orchestration → Checkpoint surgery: runs surgery
src/app.rs - Command orchestration → LoRA operations: runs LoRA
src/app.rs - Model evaluation → Generation backends: uses generators
src/backend/mod.rs - Generation backends → Model evaluation: serves generation
src/backend/mod.rs - Model evaluation → Local model files: measures outcomes
README.md - Patch pipeline → Patch apply and restore: promotes patch
src/pipeline/run.rs - MCP server and tools → Patch pipeline: starts worker
- MCP server and tools → Command orchestration: invokes commands
src/mcp/server.rs - Direction extraction → Extraction plugins: runs methods
src/extract/mod.rs