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.1.tar.gz (11.5 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.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pidtransformer-1.0.1.tar.gz
  • Upload date:
  • Size: 11.5 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.1.tar.gz
Algorithm Hash digest
SHA256 28219cbceb8a383950c2887a2244aa009e955aded69576d4f7388664e71dc4b6
MD5 b59d9c0806b76f593bc7b0bf387169c7
BLAKE2b-256 ce3927de329036255a383d99fe6d56979c18e29083bfc2d77af470140b982a00

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pidtransformer-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a6fd15287fdfcc10b12a5ffbfa6eda0a788e089e13f0136b2d811b9e3497ea2a
MD5 4aec7999cb0dfcf5b9ae48428853cb5d
BLAKE2b-256 ac8886355a0f22c1655ea6c356cab998632ef2b2929e998606d18d169f8720b8

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