Ports HuggingFace models to NeuronX Distributed Inference for AWS Trainium/Inferentia. Handles architecture analysis, NeuronX implementation, compilation, inference testing, and accuracy validation.
Ships in neuron. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This document provides the agent direct instructions on how to port a model from pytorch and running on NVIDIA GPU to pytorch/Neuron running on Trainium. The agent will be expected to follow these steps below.
When the user specifies dry-run:
export PATH=<pathToVenv>/bin:$PATH
NXDI_SRC=$(python3 -c "import neuronx_distributed_inference; print(neuronx_distributed_inference.__path__[0])")
NXD_SRC=$(python3 -c "import neuronx_distributed; print(neuronx_distributed.__path__[0])")
TRANSFORMERS_SRC=$(python3 -c "import transformers; print(transformers.__path__[0])")
USER_INVOCATION_DIR="$(pwd)"
Follow references/setup_flow.md. It handles venv validation, install consent, and exit code recovery. Do not proceed until it completes successfully.
After success, retain the 3 resolved paths from the script output for use throughout the workflow:
| Variable | Description |
|---|---|
${NXDI_SRC} | Path to NeuronX Distributed Inference source |
${NXD_SRC} | Path to NeuronX Distributed source |
${TRANSFORMERS_SRC} | Path to HuggingFace Transformers source |
READ references/systemPrompts/systemPrompt.md in this skill directory. It contains prerequisites (including version checks), project guidelines, tool documentation, debugging support, codebase navigation, and hardware context. Run all prerequisite checks and follow all guidelines throughout the workflow.
Extract these six required parameters from the user's request before starting:
| Parameter | Description |
|---|---|
ModelName | The HuggingFace model class name (e.g., ArceeForCausalLM) |
pathToModelImplementationDirectory | Path to the model source directory (e.g., transformers/src/transformers/models/arcee) |
NameOfImplementationFile | The modeling file name (e.g., modeling_arcee.py) |
NameOfConfigurationFile | The configuration file name (e.g., configuration_arcee.py) |
huggingFaceModelID | The HuggingFace model ID (e.g., arcee-ai/AFM-4.5B-Base) |
pathToModelWeightsDirectory | Path to store/load model weights (e.g., agent_artifacts/data) |
If any required parameter is missing, prompt the user for it before starting the workflow.
The skill's references/knowledge_base/ directory contains porting guides, known issues, and implementation patterns. The NeuronSDK source code (NxDI and NxD) is accessed via the resolved dependency paths ${NXDI_SRC} and ${NXD_SRC} from the "Resolve Dependencies" step. The HuggingFace Transformers source is at ${TRANSFORMERS_SRC}. All directories not created by you should be read only.
Review references/knowledge_base/ for porting patterns and common pitfalls relevant to the target model's architecture. Refer to references/knowledge_base/NEURONX_PORTING_GUIDE.md for porting patterns and references/knowledge_base/MODEL_IMPLEMENTATION_GUIDE.md for common implementation patterns. Come back to references/knowledge_base/ whenever you hit an issue during porting.
Then analyze the NeuronSDK source at ${NXDI_SRC} and ${NXD_SRC}. Pay particular attention to the model implementations and modules directories. When analyzing NeuronxDistributed and NeuronxDistributedInference understand the architecture of each model, and the various mechanisms used to build each model. including differences in attention, embedding, mlp, mixture of experts, encoder, decoder, generation and sampling, and parallelization, and sharding, please describe all of the architectural details.
Please give me an architectural description of each of the existing supported models and also identify common traits amongst models including relationships between one model and another.
Based on your understanding, including all of the existing available components in the Neuron SDK you have analyzed in directories NeuronxDistributed and NeuronxDistributedInference, please now analyze a CUDA specific implementation of {{ modelName }} in the project root sub-directory {{ pathToModelImplementationDirectory }} it contains the implementation of the model in file {{ NameOfImplementationFile }} and configuration of the model in {{ NameOfConfigurationFile }} and then create a version of this model that works based on the neuronx_distributed_inference framework in this repository. In the same directory will be a configuration file which will provide you the configuration you need. Please pay attention to the configurations, particularly the quantization, torch_dtype. Do a basic implementation of {{ modelName }} model using no sharding be thorough in your explanation, and ensure that the code produced is well documented and refers to the functions and files in the project root sub-directory {{ pathToModelImplementationDirectory }} directory where possible.
You will need to reuse all of the existing Neuron components and where you cant you need to flag them in comments. Before concluding a component cannot be reused, check if the base class supports override hooks or accepts None for optional parameters. When you port this model from huggingface please keep the names for each component of the model consistent with huggingface. If you can not please include a _u in the name to indicate that it does not have a 1:1 mapping. Implement it a component at a time and test the individual components before proceeding onto the next step, dont skip tests if distributed initialization or other features of the framework are required. For instance if there is a MLP, or attention component, implement the MLP component and test it first by doing a forward pass before going onto the Attention component. Always read the helper function's signature before calling it, and use only the parameters it accepts. Leverage the documents in the references/knowledge_base/ directory as a guide to ensure you avoid all the past mistakes. When you create the new code only leverage the NeuronxDistributed and NeuronxDistributedInference frameworks and pytorch, and do not use anything outside of the NeuronxDistributed and NeuronxDistributedInference. Do not modify any of the existing framework code. Do not pip install any additional packages. When you create the resulting ported implementation please place it in neuron_port sub-directory in the project.
Use the compile_neuron_model tool. Download weights using {{ huggingFaceModelID }} to {{ pathToModelWeightsDirectory }} if they don't exist. Pay attention to the configuration files of the downloaded weights and make sure they match the model configurations and the usage for neuron configurations. Also review examples in ${NXDI_SRC}/examples and ${NXDI_SRC}/test to understand how models are configured, compiled, deployed and tested. Use print statements instead of python logging. Store compiled output in agent_artifacts/data. If compilation fails, debug using the Debugging Support in references/systemPrompts/systemPrompt.md and references/knowledge_base/ before proceeding. You also have access to known issues through the tickety-mcp server (search_tickets, get_ticket).
Do not proceed to inference until compilation succeeds.
Use the run_neuron_inference tool. Make sure when you load model weights you leverage convert_hf_to_neuron_state_dict — see examples in ${NXDI_SRC}/models. You must re-use the inference tool, not create your own script.
Do not proceed to validation until inference produces coherent output.
Validate against the HuggingFace golden reference using the Validation Tool:
agent_artifacts/tmp/validation_config.json based on assets/example_validation_config.json. Map all fields to match your ported model.python scripts/validate_model.py --config agent_artifacts/tmp/validation_config.json --mode token --batch-size 1 --seq-len <same_as_compilation> 2>&1 | tee agent_artifacts/tmp/validation.log
Success criteria: >= 95% greedy token match rate. Exit code 0 means passed.
Iteration loop if validation fails (<95% match rate):
rm -rf agent_artifacts/data/compiled_model && rm -rf /var/tmp/neuron-compile-cacheOnce validation passes, save a final port summary to agent_artifacts/traces/port_summary.md covering: model name, HF ID, architecture decisions, TP degree, seq_len, compilation parameters, validation match rate, and any issues encountered during the port.
GATE: Do NOT declare success until validation passes with >= 95% greedy token match. Do not stop, or declare that you are done until you meet the complete success criteria.
assets/example_gptoss_usage.py (opens in a new tab)assets/example_phi3_usage.py (opens in a new tab)assets/example_phimoe_usage.py (opens in a new tab)assets/example_validation_config.json (opens in a new tab)assets/test_gptoss_inference.py (opens in a new tab)assets/test_phi3_inference.py (opens in a new tab)assets/test_phimoe_inference.py (opens in a new tab)references/knowledge_base/COMPREHENSIVE_LLAMA3_NEURONX_GUIDE.md (opens in a new tab)references/knowledge_base/Category1_Porting_Config_Compilation_Issues.md (opens in a new tab)references/knowledge_base/Category1_Scripts_Compilation_Config_Summary.md (opens in a new tab)references/knowledge_base/Category2_Scripts_Sharding_Memory_Weights_Summary.md (opens in a new tab)references/knowledge_base/Category2_Sharding_Memory_Issues.md (opens in a new tab)references/knowledge_base/Category3_Accuracy_Debugging_Analysis.md (opens in a new tab)references/knowledge_base/Category3_Scripts_Accuracy_Debugging_Summary.md (opens in a new tab)references/knowledge_base/ERRORS_AND_FIXES.md (opens in a new tab)references/knowledge_base/EXISTING_MODEL_ARCHITECTURES.md (opens in a new tab)references/knowledge_base/ExecutionOutOfBounds_Error_Fix.md (opens in a new tab)references/knowledge_base/GPTOSS_FAILURE_ANALYSIS_HONEST.md (opens in a new tab)references/knowledge_base/GPTOSS_FINAL_SUCCESS_REPORT.md (opens in a new tab)references/knowledge_base/IMPLEMENTATION_SUCCESS_FINAL.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/neuron:neuron-framework-autoport ModelName, pathToModelImplementationDirectory, nameOfImplementationFile, nameOfConfigurationFile, huggingFaceModelID, pathToModelWeightsDirectory, pathToVenv (optional)from neuron
neuron@tsvikas is listed by tsvikas/skills — review the source before installing
npx claudepluginhub tsvikas/skills --plugin neuron13 skills in this plugin
/neuron-explorer-profile-schemaReference for the neuron-explorer profile schema (the parquet tables produced
when `neuron-explorer view`/`ingest` processes a profile). Use when the user
asks "what tables are in the profile", "what fields are in <Table>", "where
does this field come from", "where can I find matmul/source-line info in the
schema", or wants to fetch the canonical schema YAML matching the installed
neuron-explorer version. Companion to /neuron-nki-profile-querying — that
skill writes SQL; this skill explains what the columns mean and where the
data originates.
/neuron-framework-autoport-vllm-neuronPort a HuggingFace model architecture to the vLLM-Neuron Trainium2 backend. Handles architecture research, code generation, and validation./neuron-framework-equivalenceVerifies functional equivalence between two implementations of the same model using a hierarchical 8-stage algorithm. Orchestrates model tree comparison, component-level R-ratio testing, E2E logit comparison, and distributional checks. Use when porting models between frameworks, hardware targets, or precision regimes — e.g., HuggingFace to NxDI, PyTorch to ONNX, GPU to Neuron, FP32 to BF16, or any source-target pair./neuron-framework-profile-analysis-vllm-neuronIngests vllm-neuron model execution artifacts into parquet using
neuron-explorer and guides profile analysis: identifies
prefill/decode NEFFs, segments by collective boundaries,
computes per-engine bounds and DMA efficiency, and produces
structured workload reports.
Use when encountering "analyze profile", "ingest profile",
"query system trace", "what's the bottleneck",
"decode step time", "prefill breakdown",
"segment by layer", "DMA efficiency".
/neuron-framework-profiling-vllm-neuronGuides profiling vllm-neuron models on Trainium: capturing device (NTFF) and
system traces from a live server via vLLM's /start_profile and /stop_profile
endpoints (the primary method), or offline via `vllm bench throughput` +
`neuron-explorer capture` (fallback). Covers the neuron_profiler config,
steady-state decode capture, and the common traps.
Use when encountering "profile model", "benchmark vllm-neuron",
"profile running server", "start_profile", "stop_profile",
"profile live vllm serve", "capture NEFF from vllm", "get system trace",
"capture NTFF from model run", "get profiling artifacts", "profile decode step",
"profile MoE model", "per-rank profiling".
/neuron-hardware-entitlementComputes per-operator mandatory compute/HBM work and component-boundary activation HBM for a single transformer-LLM inference parallelism config on AWS Neuron (Trainium trn1/trn2/trn3), and attributes a deployed graph's actual resident HBM back to those operator floors. Use when localizing which operator or component binds on tensor-engine versus HBM work within a chosen {TP, PP, CP, bucket, bs, prefill} cell, auditing ideal component fusion, routing optimization effort to regions with real headroom, or diffing actual resident HBM against its floor. Builds on neuron-parallelism-planner (imports its analytic engine + meta-device oracle); driven by a run-spec (HF config.json + hardware constants), ships a worked example.Other plugins' skills for the same job