Component Libraries •
Project Templates
Docs •
Install •
Tutorials •
Developer Guides •
Contribute •
Blog •
Discord
Xircuits Component Library for integrating PyTorch! Build and deploy machine learning models with ease.
This library integrates PyTorch into Xircuits workflows, providing tools for seamless model development, training, and general PyTorch operations. It streamlines complex machine learning tasks with modular components.



Before you begin, you will need the following:
- Python3.9+.
- Xircuits.
Defines a custom PyTorch model with optional flattening and a configurable optimizer and loss function for training.

Adds a Linear Layer to a sequential model with specified input and output features.

Adds a 1D convolutional layer with configurable kernel size, stride, padding, and other parameters.

Inserts a Transformer Encoder layer with multi-head attention and configurable feedforward dimensions and activation.
Adds a Transformer Decoder layer with attention mechanisms and flexible feedforward configurations.
Creates an LSTM layer for sequence modeling, supporting options for bidirectionality, dropout, and projection.
Adds a ReLU activation layer to a model, applying non-linearity to enhance model learning.
Incorporates a Dropout layer to reduce overfitting by randomly zeroing out input elements during training.
We have provided an example workflow to help you get started with the PyTorch component library. Give it a try and see how you can create custom PyTorch components for your applications.
This workflow automates PyTorch model training by connecting modular components for data loading, training, testing, and saving. It simplifies complex training pipelines, reduces boilerplate code, and ensures reusability across projects.
This workflow demonstrates a PyTorch-based prediction pipeline. It automates the process of loading a saved model, preprocessing an input image into a tensor, and predicting the image's class using predefined labels.
This workflow demonstrates training a custom neural network using PyTorch components, allowing flexible layer and parameter configurations.
To use this component library, ensure that you have an existing Xircuits setup. You can then install the PyTorch library using the component library interface, or through the CLI using:
xircuits install pytorch
# base Xircuits directory
git clone https://github.com/XpressAI/xai-pytorch xai_components/xai_pytorch
pip install -r xai_components/xai_pytorch/requirements.txt