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.3.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.3-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pidtransformer-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 b3a1bf91a8e29a304906f0f364f535c1fcad6d960cf0aec76d6cf5308464c9b1
MD5 00d74a8e7ccbe8cace95a9b302f809ca
BLAKE2b-256 42dd8ca552803894ede594b863dabefa05fe30b18223311259361d3df900d58c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pidtransformer-1.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1596583481b718050f98f90fc2597da262289590b5e649b8a350834bf53e2525
MD5 a79dbace65c1bd748ab2f6a7d9b6be12
BLAKE2b-256 5be59a3c7f5b4feaaae7fa416726d97758d9386ea5ce338449f83bdb9e933042

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