- C++ 55.3%
- Python 40%
- Jupyter Notebook 4.3%
- CMake 0.4%
|
|
||
|---|---|---|
| assets | ||
| configs | ||
| cpp | ||
| data | ||
| docs | ||
| environment | ||
| models | ||
| notebooks | ||
| paper | ||
| reproducibility | ||
| scripts | ||
| src | ||
| tests | ||
| .gitignore | ||
| CMakeLists.txt | ||
| LICENSE | ||
| poetry.lock | ||
| pyproject.toml | ||
| README.md | ||
| RESEARCH.md | ||
π ai-multi-reference-timekeeping
AI-Assisted Multi-Reference Timekeeping for Commodity Networks
This repository contains the reference implementation and reproducibility artifacts for the paper:
An AI-Assisted Multi-Reference Timekeeping Architecture for Commodity Networks
π€ Riaan de Beer
π Zenodo DOI: https://zenodo.org/records/18366050
This project explores a low-cost, AI-assisted approach to time synchronization that synthesizes a virtual master clock from multiple imperfect timing references (e.g., GNSS π, PTP π, NTP π) using classical estimation techniques augmented with lightweight machine learning π€.
The goal is to improve practical packet-level synchronization on commodity hardware β without requiring atomic clocks βοΈ or specialized time cards.
π¬ Scientific Foundation
This project is grounded in Relativistic Temporal Logic and Distributed Systems Theory. We move beyond standard linear timekeeping to provide a multi-reference framework designed for the next generation of AI agents.
-
Theory & Proofs: For a deep dive into the mathematical transforms, dilation matrices, and causal manifolds, please see: π RESEARCH.md π
-
Academic Citation: If you are using this framework for peer-reviewed research, please refer to the Citation section below.
π Research Deep-Dive
We have formalized the mechanics of Computational Dilation and Temporal Anchoring. To explore the underlying physics and math of this implementation, check out our Research Paper Summary.
π Theoretical Foundation
This project formalizes timekeeping by treating temporal progression as a relativistic coordinate system. Instead of a single linear clock, we define a Temporal State Vector where time is mapped across multiple reference frames.
1. The Reference Frame Model
Each reference frame F_i (e.g., an AI agent's internal simulation clock) is defined relative to the Master Reference Frame (M) by the tuple:
F_i = (t_{0,i}, \phi_i, \chi_i)
Where:
t_{0,i}: The Temporal Anchor (epoch offset).\phi_i: The Dilation Factor (relative clock speed).\chi_i(t): The Drift Function (stochastic or systemic error).
2. Forward Transform
To map Master Time (T_M) to a specific Local Reference (t_i), we apply the following transform:
t_i = \phi_i (T_M - t_{0,i}) + \chi_i(T_M)
3. Inter-Frame Transformation
To translate directly between two non-master frames (Frame A and Frame B) without intermediary calculation, we use the composed transform:
t_B = \frac{\phi_B}{\phi_A} t_A + \phi_B(t_{0,A} - t_{0,B})
This allows the system to determine the Relative Temporal Velocity (\frac{\phi_B}{\phi_A}) between two disparate AI contexts.
4. Dynamic Time Warping (Non-Linear Dilation)
In scenarios where processing speed varies (e.g., high-inference loads or hardware throttling), \phi becomes a time-dependent function \phi(t). The local time is then derived via integration:
t_i = \int_{t_{0,i}}^{T_M} \phi_i(\tau) \, d\tau
π― Motivation
High-precision time synchronization is increasingly important for distributed systems, including:
- β±οΈ Time-sensitive networking (TSN)
- πΎ Coordinated I/O and storage pipelines
- π¦ Packet scheduling and timestamping
- π§ͺ Experimental distributed systems research
Commercial solutions typically rely on atomic oscillators and dedicated PCIe time cards, which remain costly and inaccessible to many researchers and open-source projects.
This work investigates whether intelligent multi-reference fusion, combined with lightweight local learning, can narrow the gap for practical synchronization tasks using commodity hardware.
π§ What This Project Does
- π Fuses multiple heterogeneous timing references into a single virtual clock
- π Combines a state-space clock model with a lightweight neural network
- π Adapts reference weighting based on observed jitter, stability, and context
- π Exposes time via standard mechanisms (PTP, PHC, NTP)
- β»οΈ Targets reproducibility using open-source tools and Google Colab notebooks
π°οΈ Time Server Scaffold (Sensors + AI Weighting)
The repository now includes a time server scaffold in src/ai_multi_reference_timekeeping/time_server.py
that lets you:
- π§© Plug in sensor inputs (temperature, humidity, pressure, AC hum, SDR SNR, Geiger CPM, audio activity)
- π‘ Collect references over NTP, GPS NMEA, or the hardware RTC (via
hwclock) - π Listen from GPIO/USB/serial by wiring sensors with
GpioPulseSensor,SerialLineSensor, oropen_line_source - π§ Adjust reference variance using a lightweight inference model
- π Estimate drift and slew from recent offsets
Example usage:
from ai_multi_reference_timekeeping.fusion import ReferenceFusion, VirtualClock
from ai_multi_reference_timekeeping.kalman import ClockCovariance, ClockKalmanFilter, ClockState
from ai_multi_reference_timekeeping.time_server import (
LightweightInferenceModel,
NtpReference,
SensorAggregator,
TimeServer,
)
kalman = ClockKalmanFilter(
state=ClockState(offset=0.0, drift=0.0),
covariance=ClockCovariance(p00=1.0, p01=0.0, p10=0.0, p11=1.0),
process_noise_offset=1e-4,
process_noise_drift=1e-6,
)
clock = VirtualClock(kalman_filter=kalman, fusion=ReferenceFusion())
class EnvSensor:
def sample(self) -> dict[str, float]:
return {"temperature_c": 27.0, "humidity_pct": 40.0}
server = TimeServer(
clock=clock,
references=[NtpReference(name="nist")],
sensors=SensorAggregator(EnvSensor()),
inference=LightweightInferenceModel(),
)
update, frame, drift_estimate, drift_hint = server.step(dt=1.0)
print(update.fused_offset, drift_estimate.drift, drift_hint)
π« Non-goals
This project explicitly does not aim to:
- β Replace atomic clocks or high-stability oscillators
- β Provide nanosecond-level absolute UTC accuracy under all conditions
- β Serve as a primary time standard
- β Offer cryptographic guarantees against fully adversarial time manipulation
The system prioritizes robustness, accessibility, and cost-effectiveness for packet-level synchronization in experimental and operational environments.
ποΈ Repository Structure
ai-multi-reference-timekeeping/
βββ paper/ # π LaTeX source and figures for the paper
βββ notebooks/ # π Google Colabβfriendly notebooks
βββ src/ # π§© Fusion, ML, and evaluation code
βββ data/ # ποΈ Example and processed datasets
βββ models/ # π§ Trained and baseline models
βββ configs/ # βοΈ Configuration files
βββ scripts/ # π οΈ CLI utilities
βββ reproducibility/ # π Experimental protocols and hardware notes
βββ environment/ # π¦ Dependency specifications
βββ LICENSE
βββ README.md
βοΈ Google Colab Reproducibility
The notebooks in notebooks/ are designed to run directly in Google Colab β no specialized hardware required.
π° Recommended entry point:
β Notebook test runs:
notebooks/10_test_fusion.ipynbβ validates fusion and quality weighting
notebooks/11_test_time_server.ipynbβ validates time server + ML variance model
Each notebook includes an Open in Colab link and installs dependencies automatically.
π Evaluation Metrics
The evaluation framework focuses on standard timing metrics, including:
- β²οΈ Time Deviation (TDEV)
- π Maximum Time Interval Error (MTIE)
- π PTP offset stability
- π°οΈ Holdover behavior during reference loss
Absolute UTC ground truth is not required for most experiments.
π Security and Threat Model
The system is designed to tolerate noisy, intermittent, and partially unreliable timing sources.
It does not assume a fully adversarial environment.
Considered threats include:
- π‘ GNSS degradation, multipath, and interference
- π Network-induced delay asymmetry
- β οΈ Transient reference instability
Coordinated compromise of all timing references is considered out of scope.
π License
This project is licensed under the Apache License 2.0.
See the LICENSE file for details.
π Citation
If you use this work, please cite:
@misc{debeer2026aimrt,
title = {An AI-Assisted Multi-Reference Timekeeping Architecture for Commodity Networks},
author = {de Beer, Riaan},
year = {2026},
doi = {10.5281/zenodo.XXXXXXX}
}
π§ Status
This repository accompanies a research paper and is intended to evolve.
Contributions, discussion, and replication studies are welcome π€.
π Acknowledgments
This work builds on established research in time metrology, clock ensembles, and IEEE 1588 Precision Time Protocol, and aims to make these ideas more accessible to open-source and experimental systems communities.