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.4.tar.gz (24.2 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.4-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pidtransformer-1.0.4.tar.gz
  • Upload date:
  • Size: 24.2 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.4.tar.gz
Algorithm Hash digest
SHA256 d0235df1e3f1ff1f4830399f019d3eb4ceab929c1ded39fb1d0767d0a74268ae
MD5 6b03115936291ede160eb9425f01da13
BLAKE2b-256 62d5ea94087f7acb7c8201047b130cb15ae8f19ae69ae017ade148879cfcbd9c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pidtransformer-1.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6d2772cab769a6f70a5b35c57d1502376e711e63888130d9c4fde285f09cadb0
MD5 9b28423ec58236e3663491dee153cbc1
BLAKE2b-256 f355ec949b1126475a1b7354c84dbbfdc93b34604b65979a27aed3d531f43900

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