Skip to main content

Recursive Diffusion-Type (RDT) Kernel — entropy-regulated nonlinear diffusion operator in PyTorch.

Project description

RDT Kernel

Recursive Diffusion-Type Kernel (RDT)
Author: Steven Reid (RRG314 Research Group)
License: MIT


Overview

The RDT Kernel is a nonlinear, entropy-regulated diffusion operator implemented in PyTorch.
It provides a compact and efficient way to evolve scalar fields under a coupled logarithmic potential and Laplacian diffusion dynamic:

\ \frac{\partial L}{\partial t} = -\alpha \log(L) + D \nabla^2 L \

Unlike conventional linear diffusion equations, the RDT Kernel introduces a logarithmic potential term that regulates field entropy, maintaining bounded and stable evolution even in recursive or chaotic systems.
It is lightweight, numerically stable, and compatible with CPU, GPU, and TPU backends.


Key Features

  • Cross-hardware operation (CPU, GPU, TPU)
  • Entropy-regulated diffusion with a logarithmic potential
  • Fully parallelized PyTorch implementation
  • Differentiable and compatible with machine-learning workflows
  • Guaranteed positivity and bounded energy through clamping
  • Minimal dependencies (requires only torch; optional torch_xla for TPU)

Typical Applications

Domain Example Uses
Machine Learning / AI Physics-informed neural networks, differentiable PDE layers, generative or diffusion models
Scientific Computing Nonlinear diffusion and stability simulations, entropy-bounded PDE solvers
Computational Physics Entropy-driven field relaxation, recursive geometric entropy studies
Signal & Image Processing Nonlinear smoothing and denoising, texture evolution
Information Theory Modeling entropy growth and information diffusion

Because it is differentiable and hardware-agnostic, the RDT Kernel can be integrated directly into PyTorch autograd graphs for end-to-end training of PDE-based or hybrid AI-physics systems.


Mathematical Foundation

The RDT equation combines two terms:

1. Logarithmic Entropy Term
(-α log L) — acts as a restoring potential that resists uncontrolled growth and encodes entropy regulation.

2. Diffusion Term
(D ∇² L) — implements standard Laplacian smoothing, spreading gradients spatially to stabilize field variations.

Together these form a self-stabilizing PDE suitable for equilibrium-seeking and diffusion-reaction systems.


API Reference

get_device()

Detects the best compute backend.

device, name = get_device()
# returns ("cuda", "GPU"), ("cpu", "CPU"), or ("TPU")

rdt_kernel(L, alpha=0.5, D=0.1, dx=1.0)

Computes the instantaneous field derivative:

Parameter Type Description
L Tensor Input scalar field (must be positive)
alpha float Logarithmic potential coefficient
D float Diffusion coefficient
dx float Spatial step size

Returns: Tensor — field derivative (∂L/∂t)

step(L, alpha=0.5, D=0.1, dx=1.0, dt=0.01)

Advances the field one time step using:

\ L_{t+1} = L_t + \Delta t \cdot \text{RDT}(L_t) \

The output is clamped to remain positive and bounded.


Quick Start

import torch
from rdt_kernel import step, get_device

device, name = get_device()
print("Running on", name)

L = (1 + 0.1 * torch.rand((1, 256, 256))).to(device)

for _ in range(100):
    L = step(L, alpha=0.5, D=0.1, dx=1.0, dt=0.01)

print("Mean field value:", L.mean().item())

Integration Examples

As a Differentiable Layer

import torch.nn as nn
from rdt_kernel import step

class RDTLayer(nn.Module):
    def __init__(self, alpha=0.5, D=0.1, dx=1.0, dt=0.01):
        super().__init__()
        self.alpha, self.D, self.dx, self.dt = alpha, D, dx, dt

    def forward(self, L):
        return step(L, self.alpha, self.D, self.dx, self.dt)

In a Physics Simulation Pipeline

from torchdiffeq import odeint
from rdt_kernel import rdt_kernel
import torch

t = torch.linspace(0, 1, 100)
L0 = torch.ones((1, 128, 128))
sol = odeint(lambda t, L: rdt_kernel(L), L0, t)

Performance

  • Efficient for large grids (512×512 and higher)
  • Linear memory scaling on GPU
  • TPU-compatible via torch_xla
  • Numerically stable for dt ≤ 0.05 in most scenarios

Installation

From GitHub

git clone https://github.com/RRG314/rdt-kernel.git
cd rdt-kernel
pip install .

From PyPI (when available)

pip install rdt-kernel

Requirements

  • Python ≥ 3.8
  • PyTorch ≥ 1.12
  • Optional: torch_xla for TPU support

Research Context

The RDT Kernel originated in the Recursive Geometric Entropy and Entropy Field Theory (REFT) framework.
It provides a minimal computational mechanism for entropy-bounded field evolution—relevant to stability analysis, information diffusion, and recursive geometric systems.


Roadmap

  • Add 3-D and multi-dimensional variants
  • Benchmark mixed-precision (FP16/BF16)
  • Add symbolic auto-differentiation module
  • Publish official PyPI distribution

License

MIT License © 2025 Steven Reid
Permission is granted to use, copy, modify, and distribute this software with attribution.


A lightweight, entropy-regulated diffusion operator bridging physics and computation.

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

rdt_kernel-1.0.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

rdt_kernel-1.0.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rdt_kernel-1.0.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rdt_kernel-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0f69ed2f1b5bacd60b65b30eb67dbfbcd8a97a2a271e52838369e4b456a39b9f
MD5 6e3fa113e0ac76cbfce5e6f708661d7e
BLAKE2b-256 f3d957a2a3690a5f39edfe282174be7683542c9b088b80e5815f076813c73afa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rdt_kernel-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rdt_kernel-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e26f52a2dc9ed617e4a52947f55d65ab3a40ef28881df23b47567da9da3cbdac
MD5 3af21e4105e6591854cad75e9aabeb90
BLAKE2b-256 14352d2bc1ee8d06b8ec3a1277ed546eb78e154dbda41420630c15c0a4aa24fb

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