Skip to main content

A Transformer architecture with internal PID control for stabilizing learning dynamics.

Project description

PID-Transformer: A Control-Theoretic Approach for Stabilizing Large-Scale Neural Networks

Control-Theoretic Stabilization for Large-Scale Transformers

A novel Transformer architecture with embedded PID control logic for robust and interpretable representation dynamics.
Includes Group-wise PID, AdaptiveDim switching, and Gating-based trajectory feedback.


Installation

You can install the package in the following ways:

PyPI

pip install pidtransformer

From wheel or tar.gz

pip install pidtransformer-1.0.0-py3-none-any.whl or pip install pidtransformer-1.0.0.tar.gz


Quick Start

  1. Clone and prepare the environment

  1. Run a training experiment

python experiments/train_baseline.py
--experiment_name "PID_Optimal_Filtered"
--kp 0.002852 --ki 0.001240 --kd 0.012805
--d_filter 3


  1. Visualize hidden state trajectories

python experiments/plot_trajectory.py
PID_Off_history.json PID_Optimal_Filtered_history.json
--output_file trajectory_comparison.png


Core Components

Module Description
GeometricPIDController A vector-based controller applying P/I/D logic to model-internal error signals.
PIDLayer Combines FFN + projection to control space + PID feedback loop.
AdaptiveDim Dynamically switches dimensionality (e.g. 256→128) to optimize stability over time.
Group-wise PID PID applied across subgroups of hidden dimensions.
Trajectory Tracker Captures hidden state evolution to visualize smoothness/curvature via PCA.

Interactive Visualization

Launch in Browser

Go to Live Demo

You’ll see:

PCA latent space trajectories

Loss/PID Norm curves

GSA bar chart

Diagrammatic explanation of PIDLayer and controller design


Reproducible Experiments

Baseline Model (no control)

python experiments/train_baseline.py --experiment_name "PID_Off" --kp 0 --ki 0 --kd 0

Full Control Model

python experiments/train_baseline.py --experiment_name "AdaptiveDim"
--kp 0.1 --ki 0.01 --kd 0.05 --use_adaptive_dim --use_group_pid --ortho_weight 0.01

Endurance-scale

python experiments/train_baseline.py --experiment_name "Endurance_AdaptiveDim"
--num_steps 5000 --log_freq 50 --use_adaptive_dim --use_group_pid


Citation

If you use this work in your research, please cite:

@article{pidtransformer2025, title={AdaptiveDim+Gating PID-Transformer: A Control-Theoretic Approach for Stabilizing Large-Scale Neural Networks}, author={KANG JA IL}, year={2025} }

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pidtransformer-1.0.2.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pidtransformer-1.0.2-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file pidtransformer-1.0.2.tar.gz.

File metadata

  • Download URL: pidtransformer-1.0.2.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for pidtransformer-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ad048a12c0b7a621a8ca7cd04656cfee1d42656c6c78a98875039bb6dcc60eb6
MD5 8212ba26fed66941eb7fc76e6081b5ef
BLAKE2b-256 14c3d0101d666643940cdf586a798ae8cd4c63432f48e01bf5e14f1078dd5872

See more details on using hashes here.

File details

Details for the file pidtransformer-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pidtransformer-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 27.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for pidtransformer-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6c09d6958e6fedfe87185409eab063e00b61612ed37a345da6d5643f1cbd2810
MD5 570cafd6b5215547451d0be23f464e94
BLAKE2b-256 db1b745cb6cff44f7d73be5bbee416ae198258d7a9f1fbb64c319b3f422b2e0c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page