Skip to main content

Overview

training_server.py is a modified version of ppo_doom.py designed for distributed training. It runs PPO training on a GPU server while communicating with a remote CL1 device over UDP. Architecture:
  • Training System: Runs VizDoom, PyTorch models, and PPO algorithm
  • CL1 Device: Runs cl1_neural_interface.py to handle neural hardware
  • Communication: UDP protocol for low-latency stimulation/spike exchange
Key Differences from ppo_doom.py:
  • No direct CL SDK imports (CL SDK only on CL1 device)
  • UDP sockets for stimulation commands and spike data
  • MJPEG server for remote visualization
  • Event metadata logging to CL1 device
Location: source/training_server.py

Command-Line Arguments

Basic Options

string
default:"train"
Execution mode for the training serverChoices: train, watch
  • train: Full training mode with gradient updates
  • watch: Observe neural activity without training (inference mode)
string
default:"None"
Path to checkpoint file for loading pre-trained weightsExample: --checkpoint checkpoints/l5_2048_rand/checkpoint_7900.pt
integer
default:"65000"
Maximum number of training episodes before termination
string
default:"cuda"
PyTorch device for gradient computationChoices: cpu, cuda

Neural Interface Options

string
default:"none"
Ablation mode for diagnostic testing of decoder dependency on spikesChoices:
  • none: Normal operation, use real spike features
  • zero: Replace spike features with zeros (tests decoder bias)
  • random: Replace spike features with random values (tests decoder robustness)
boolean
default:"false"
Enable CNN encoder over screen buffer in addition to scalar featuresWhen enabled, processes downsampled screen buffer through convolutional network.

Display & Visualization

boolean
default:"false"
Display the VizDoom game window on the training systemNote: For remote viewing, use the MJPEG stream instead.
string
default:"/data/recordings/doom-neuron"
Directory path on CL1 device for saving neural recordingsThis path is sent to the CL1 device via event metadata. Actual recordings are managed by the CL1 device.
integer
default:"12349"
TCP port for MJPEG visualization streamAccess the live gameplay feed at: http://<training-host>:<port>/doom.mjpeg

Hardware Loop Configuration

integer
default:"10"
Frequency (Hz) for running the game loopThis should match the --tick-frequency setting on the CL1 device.Controls the rate of:
  • Sending stimulation commands to CL1
  • Receiving spike data from CL1
  • Game state updates

UDP Network Configuration

string
default:"localhost"
IP address of the CL1 device running cl1_neural_interface.pyExample: --cl1-host 192.168.1.100
integer
default:"12345"
UDP port for sending stimulation commands to CL1 deviceMust match --stim-port on CL1 device.
integer
default:"12346"
UDP port for receiving spike data from CL1 deviceMust match --spike-port on CL1 device.
integer
default:"12347"
UDP port for sending event metadata to CL1 deviceEvents include episode completions, checkpoints, and training completion signals.Must match --event-port on CL1 device.
integer
default:"12348"
UDP port for sending feedback stimulation commands to CL1 deviceFeedback includes reward signals and event-based stimulation (kills, damage, etc.).Must match --feedback-port on CL1 device.

Feedback Configuration

boolean
default:"true"
Enable episode-level feedback stimulationWhen enabled, applies feedback stimulation at the end of each episode based on total reward.
boolean
default:"false"
Disable episode-level feedback stimulationConvenience flag to turn off episode feedback (sets use_episode_feedback=False).
boolean
default:"true"
Scale episode feedback intensity by TD-error surprise magnitudeWhen enabled, unexpected rewards/penalties receive stronger feedback.
boolean
default:"false"
Disable surprise scaling for episode feedbackUse fixed feedback intensity regardless of prediction error.

Usage Examples

Basic Training Setup

On CL1 Device:
On Training Server:

Custom Port Configuration

Resume from Checkpoint

Watch Mode (Inference)

Disable Episode Feedback

Network Communication

UDP Packet Flow

Training System → CL1 Device:
  1. Stimulation Commands (port 12345): Frequencies and amplitudes for neural stimulation
  2. Event Metadata (port 12347): Episode completion, checkpoint saves, training status
  3. Feedback Commands (port 12348): Reward/event-based stimulation
CL1 Device → Training System:
  1. Spike Data (port 12346): Spike counts per channel group from each hardware tick

UDP Protocol Details

See udp_protocol.py for packet format specifications.

Socket Setup

MJPEG Visualization

The training server hosts an MJPEG stream for remote visualization:
Access: http://<training-host>:12349/doom.mjpeg The stream shows:
  • Game screen (if use_screen_buffer=True)
  • Player stats overlay
  • Episode statistics

Event Metadata

The training system sends metadata to the CL1 device for recording:

Episode End Event

Training Complete Event

These events are logged to the CL1 DataStream for analysis.

Performance Considerations

Network Latency

  • Target Latency: < 5ms round-trip
  • Typical: 1-2ms on local network
  • UDP: No retransmission overhead

Tick Frequency Trade-offs

Recommendation: Start with 10 Hz, increase once training is stable.

Troubleshooting

No Spike Data Received

High Packet Loss

  • Reduce tick frequency
  • Check network bandwidth
  • Use wired connection instead of WiFi
  • Ensure no firewall blocking UDP ports

Latency Issues

  • Monitor latency with built-in logging (every 1000 packets)
  • Consider switching to 1Gbps or 10Gbps network
  • Reduce batch size to decrease compute time

See Also