Adeptly is a Python 3.12+ library for building adaptive agents in real-time environments. The current core is a PyTorch DQN stack, with trainer and low-latency runtime utilities designed for interactive loops (games, simulations, online control).
- PyTorch 2.x DQN agent with:
- replay buffer
- target networks (hard or soft updates)
- epsilon scheduling
- optional Double DQN target computation
- Trainer orchestration (
DQNTrainer) for:- warmup/update cadence controls
- checkpointing
- evaluation episodes
- Real-time actor/learner split (
RealTimeInferenceLoop) for latency-sensitive action selection with deferred learning. - Multimodal observation stack for batched image + telemetry + optional event/text inputs via
ObservationBatchandMultimodalQNetwork. - Compatibility shims for legacy imports (
adeptly.dqn.DQNAgent) andAdeptlyEnginewhile migration is in progress.
- Architecture overview: agent components, end-to-end data flow, training loop orchestration, and multimodal pipeline.
- Migration guide: step-by-step migration from legacy
DQNAgentusage to the current API.
Adeptly has moved to a PyTorch-first implementation and no longer relies on TensorFlow graph/session semantics.
AdeptlyEngineis deprecated and now a no-op context manager.adeptly.dqn.DQNAgentis deprecated; import fromadeptly.agents.dqninstead.- Training/inference loops should use
DQNTrainerandRealTimeInferenceLoopfor modern usage patterns.
See MIGRATION.md for concrete before/after examples.
from adeptly import CounterEnv, DQNTrainer, TrainerConfig
from adeptly.agents.dqn import DQNAgent, DQNConfig
agent = DQNAgent(
observation_size=1,
action_size=2,
config=DQNConfig(min_replay_size=32, batch_size=32),
)
trainer = DQNTrainer(
agent=agent,
env_factory=lambda: CounterEnv(target=5, max_steps=16),
config=TrainerConfig(
total_steps=2_000,
update_frequency=2,
replay_warmup_steps=64,
target_update_cadence=100,
checkpoint_interval=500,
evaluation_episodes=5,
),
)
metrics = trainer.train()
print(metrics)import numpy as np
from adeptly import RealTimeInferenceLoop
loop = RealTimeInferenceLoop(agent)
obs = np.array([0.0], dtype=np.float32)
action = loop.actor_step(obs)
loop.submit_transition(
obs,
action,
reward=0.2,
next_observation=np.array([1.0], dtype=np.float32),
done=False,
)
loop.learner_update(max_updates=1)import torch
from adeptly.observations import MultimodalQNetwork, ObservationBatch
model = MultimodalQNetwork(
image_channels=3,
telemetry_dim=6,
action_size=4,
sequence_vocab_size=256,
)
observations = ObservationBatch(
image_frames=torch.randint(0, 256, (8, 3, 84, 84), dtype=torch.uint8),
scalar_telemetry=torch.randn(8, 6),
events_or_text=torch.randint(0, 256, (8, 12), dtype=torch.int64),
)
q_values = model(observations)
actions = torch.argmax(q_values, dim=1)Near-term priorities:
- Expand trainer ergonomics (resume flows, richer metrics export, and callback hooks).
- Add end-to-end examples for real-time actor/learner deployment patterns.
- Extend multimodal training utilities beyond inference-only examples.
- Continue reducing legacy surface area and remove deprecated shims in a future major release.
- Improve benchmarking coverage across synthetic and game-like environments.
This repository uses uv for deterministic local workflows.
uv python install 3.12
uv venv --python 3.12
uv sync --frozen --extra devuv run make format
uv run make lint
uv run make typecheck
uv run make test
uv run make docs
uv run pre-commit run --all-filesThe /docs directory is generated output and is not rebuilt automatically during normal edits.
To rebuild it locally, run:
uv run make docsSee CONTRIBUTING.md for contributor workflow and PR checklist details.