PE

An expert assistant for adding and debugging artificial dendrites in PyTorch neural networks using the PerforatedAI library.

Install

mkdir -p .claude/skills/perforatedai && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/19304" && unzip -o skill.zip -d .claude/skills/perforatedai && rm skill.zip

Installs to .claude/skills/perforatedai

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Expert in PerforatedAI library for adding artificial dendrites to PyTorch neural networks. Triggers: 'Perforate my model' (start interactive setup), 'debug my perforated model' (debug/optimize existing integration). Also use when: debugging dendrite training, configuring PAI settings, troubleshooting dendrite issues, working with PAINeuronModule or PAIDendriteModule. For analyzing completed training results, use the perforatedai-analyze skill.
447 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Add artificial dendrites to PyTorch models
  • Configure dendrite training settings
  • Debug existing PerforatedAI integrations
  • Analyze model architecture for PAI compatibility

How it works

The skill analyzes existing PyTorch training scripts to inject dendrite modules and configuration calls, or debugs existing implementations.

Inputs & outputs

You give it
PyTorch training script path
You get back
Integrated dendrite code or debug report

When to use perforatedai

  • Add artificial dendrites to a PyTorch model
  • Debug existing PerforatedAI integration
  • Configure dendrite training settings

About this skill

PerforatedAI Dendrite Network Skill

Available Resources

This skill has access to (via the PerforatedAI git submodule):

Feel free to reference these when helping users debug or understand implementation details.

Entry Points

1. "Perforate my model" - Interactive Setup

When the user says "Perforate my model", start the interactive setup process.

IMPORTANT: Your role is to analyze code and make edits. Never run the user's training script - only ask them to run it and provide output.

First, check if PAI is already partially integrated:

Ask for their training script path, then read it and check for:

  • PAI imports: from perforatedai import globals_perforatedai as GPA and utils_perforatedai as UPA
  • Configuration calls: GPA.pc.set_* functions
  • Model initialization: UPA.perforate_model() call
  • Optimizer setup: GPA.pai_tracker.setup_optimizer() or set_optimizer_instance()
  • Training loop: GPA.pai_tracker.add_validation_score() call

If PAI integration is already present:

Tell them: "I see you already have some PerforatedAI integration! Let me check what's complete and what's missing..."

Analyze what's been done and report:

  • ✅ Completed steps (e.g., "Imports added", "Configuration set", "Model initialized")
  • ❌ Missing steps (e.g., "Optimizer setup missing", "Training loop not updated")

Then ask: "Would you like me to:

  1. Complete the missing integration steps
  2. Debug/optimize your existing setup (say 'Debug my perforated model')
  3. Start fresh with a different approach"

Based on their choice:

  • Option 1: Continue from the first incomplete step
  • Option 2: Jump to the "Debug My Perforated Model" workflow below
  • Option 3: Confirm they want to replace existing code, then start from Step 1

If no PAI integration found:

Proceed with Step 1 below.

Prerequisites: Install PerforatedAI Packages

Before doing anything else, instruct the user to install the two required pip packages. These are not bundled with the server — the user must install them in their Python environment:

pip install perforatedai perforatedbp
  • perforatedai — core dendrite library (globals_perforatedai, utils_perforatedai, etc.)
  • perforatedbp — Perforated Backpropagation extension (required for dendrite scoring)

Ask them to confirm the install completed without errors before continuing.

Step 1: Discovery

1.1 Get Training Script and Analyze Model

Ask: "What's the path to your training script?"

  • If they provide a path: Read the script and analyze it to determine:

    • Model architecture type (CNN, Transformer, ResNet, Custom, etc.)
    • Model version/size (e.g., ResNet18 vs ResNet50, GPT2-small vs GPT2-large)
    • Input dimensions and data format
    • Training loop structure
    • Optimization metric being used
    • Whether the script has configurable model selection (command-line arguments for model, architecture parameters, etc.)
  • If they say they don't have a script yet: Tell them:

    "PerforatedAI is an optimization tool for existing models. Please build an initial training setup first and get a baseline working before integrating dendrites. Once you have a working training script, come back and say 'Perforate my model' to add dendritic optimization."

    Then stop - do not proceed with integration.

1.2 Check for Library-Managed Training

Before proceeding with the standard integration steps, check whether the user's script uses a training library that requires a different integration path.

Look for these patterns in their script:

  • HuggingFace Transformers Trainer: imports of Trainer or TrainingArguments from transformers, or a call to trainer.train()
  • PyTorch Lightning: imports of pl.LightningModule, pl.Trainer, or lightning.pytorch

If you find HuggingFace Trainer usage:

Tell them: "I see your script uses the HuggingFace Trainer. The PAI integration is slightly different when using Trainer — the fork handles several things automatically that you'd otherwise do manually."

IMMEDIATELY load and follow the library skill:

Use read_file to load: .github/skills/perforatedai-libraries/transformers/SKILL.md
Read the entire file from line 1 to the end.

Follow every step in that skill. Do NOT continue with steps 1.2 onward in this skill.


If you find PyTorch Lightning usage:

Tell them: "I see your script uses PyTorch Lightning. PAI has specific integration requirements for Lightning modules. Please check Examples/libraryExamples/pytorch_lightning/ for reference examples, and refer to the standard PAI API steps below with special attention to placing add_validation_score inside your validation_epoch_end hook."

Then continue with step 1.2 below — the standard integration steps apply, but flag to the user that optimizer setup goes through Lightning's configure_optimizers and the restructuring block goes in validation_epoch_end.


If neither is found: proceed normally with step 1.2.


1.3 Ask About Optimization Goal

Ask: "What are you optimizing for?"

Options:

  • Accuracy / Loss / Decision Making - Improve model performance metrics
  • Efficiency / Model Size - Reduce parameters while maintaining performance

Based on their answer:

If Accuracy/Loss/Decision Making:

  • Proceed to Step 2 with standard dendrite growth settings (maximize metric or minimize loss)

If Efficiency/Model Size:

  • Educate them first: "Important: Dendrites ADD parameters to your model, but they do so more efficiently than traditional approaches. To optimize for efficiency with PerforatedAI, you should start with a smaller base model and then add dendrites strategically. This will allow you to achieve better performance than a larger model with fewer parameters. Let's work together to find the right balance for your use case."

  • Based on your earlier analysis of their training script, determine if model selection is configurable:

    • Does it have command-line arguments that specify model architecture, variant, or size (e.g., --model, --arch, --model_name, --resnet_version, --width, --depth, --num_heads, --num_layers, --hidden_dim)?
    • Does it have config files that specify model architecture or size parameters?
    • Or is the model hardcoded in the script?
  • Then proceed based on what you find:

    If model IS configurable (has --model, --arch, or config arguments):

    • ASK what they're currently using, tailored to what's configurable:
      • If they have --model or --arch argument: "I see your script has a --model argument. What model are you currently using?"
      • If they have architecture size parameters (e.g., --width, --depth, --num_heads, --num_layers): "I see your script supports configurable architecture. What are your current settings? (e.g., width, depth, number of heads/layers)"
      • If they have both model selection AND size parameters: "I see your script supports different configurations. What model and settings are you currently using? (e.g., model name, width, depth, number of layers/heads)"
    • Wait for their answer before proceeding

    If model is NOT configurable (hardcoded in script):

    • Analyze the code to identify what model they're using
    • Tell them: "I can see you're using [ModelName] in your script."
    • Proceed directly based on what you found (no need to ask)
  • Then determine the path based on their model (🚨 CRITICAL: For efficiency, the model MUST be smaller - always recommend downsizing):

    For Pretrained Models (e.g., ResNet50, BERT-base, GPT2-medium):

    If they're using a larger variant within a model family (ResNet50, ResNet34, BERT-base, GPT2-medium, etc.):

    • Tell them: "You're using [ModelName]. To optimize for efficiency, I have two options for you.

      Important: Dendritic optimization often allows a smaller architecture to achieve the accuracy goals you would have previously needed the larger model for. The dendrites add targeted capacity exactly where needed, making efficient architectures surprisingly powerful.

      Option 1: Smaller variant in the same family

      • ResNet50 → ResNet18 + dendrites (or ResNet34 as intermediate step)
      • ResNet34 → ResNet18 + dendrites
      • BERT-base → BERT-small or DistilBERT + dendrites
      • GPT2-medium → GPT2-small + dendrites

      Option 2: Switch to a more efficient architecture type

      • ResNet50/34 → MobileNetV2 or EfficientNet-B0 + dendrites
      • BERT-base → DistilBERT + dendrites
      • ViT-Base → MobileViT or EfficientNet + dendrites

      Which would you like to try?"

    • Wait for their choice before making any changes

    • After they choose, make the appropriate changes:

      • If model was configurable via arguments: Modify their script's default argument or tell them which argument to change
      • If model was hardcoded: Modify their script to load the chosen model
    • After making changes, tell them: "I've updated your script to use [ChosenModel]. Before we add dendrites, please run a quick training test to confirm it loads correctly and trains without errors. This smaller model will have lower accuracy initially, which is expected. Dendrites will help recover performance."

    • Wait for confirmation before proceeding to Step 2

    If they're already using the smallest variant within their model family (ResNet18, BERT-small, GPT2-small, etc.):

    • Tell them: "You're using [CurrentModel], which is the smallest in its family. For maximum efficiency, I recommend switching to a

Content truncated.

When not to use it

  • When the user does not have a working baseline training script

Prerequisites

perforatedai pip packageperforatedbp pip package

Limitations

  • Requires manual installation of required pip packages
  • Does not run user training scripts directly

How it compares

It automates the integration of dendritic computation into standard PyTorch layers instead of manual layer modification.

Compared to similar skills

perforatedai side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
perforatedai (this skill)010dReviewAdvanced
langsmith-observability46moReviewIntermediate
mflux-debugging31moNo flagsAdvanced
debug-distributed15moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry