Inferensys

Glossary

Dynamic Batching

Dynamic batching is a federated edge learning technique where local batch size is automatically adjusted per client based on real-time compute and memory capacity to prevent out-of-memory errors and optimize throughput.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
EDGE DEVICE HETEROGENEITY MANAGEMENT

What is Dynamic Batching?

A core technique in federated edge learning for managing diverse hardware constraints.

Dynamic batching is a client-side optimization technique in federated edge learning where the local batch size for on-device training is automatically adjusted per device based on its real-time available memory and compute capacity. This prevents out-of-memory (OOM) errors on constrained hardware and maximizes throughput by using the largest batch a device can safely process, rather than enforcing a fixed, one-size-fits-all size across a heterogeneous client pool. It is a key method for handling device heterogeneity.

The mechanism typically involves an on-device resource monitor that profiles metrics like RAM usage and CPU load before or during training. Based on this profile, the training loop dynamically scales the batch dimension. This contrasts with static batching, which can cripple low-memory devices or underutilize powerful ones. By adapting to each device's instantaneous capacity, dynamic batching improves system-wide efficiency and stability, enabling more devices to participate successfully in the federated learning process.

EDGE DEVICE HETEROGENEITY MANAGEMENT

Key Features of Dynamic Batching

Dynamic batching is a client-side optimization technique in federated edge learning that automatically adjusts the local batch size for on-device training based on real-time resource availability. Its core features are designed to prevent system failures and maximize throughput across a diverse fleet of devices.

01

Real-Time Resource Monitoring

The technique relies on a lightweight on-device resource monitor that continuously tracks key metrics:

  • Available RAM to prevent out-of-memory (OOM) errors.
  • CPU/GPU/NPU utilization to avoid system lag.
  • Battery level and thermal state to preserve user experience and device integrity.
  • Network bandwidth for subsequent update transmission. This live telemetry is the primary input for the batching decision algorithm, allowing the system to react to changing conditions like a user starting a power-intensive app.
02

Adaptive Batch Size Calculation

Based on the resource monitor's input, a heuristic or learned policy calculates the maximum viable batch size. This is not a simple linear scaling. Key considerations include:

  • Memory-bound calculation: Estimating the peak memory footprint of a forward/backward pass for a given batch size.
  • Compute-throughput trade-off: Larger batches improve hardware utilization (e.g., GPU parallelism) but increase per-iteration latency and memory pressure.
  • Energy efficiency: Larger batches may complete the target local epoch count faster, potentially saving energy versus many small, inefficient batches.
03

Integration with Client Selection

Dynamic batching interacts directly with compute-aware selection strategies. The federation server can query devices for their current effective batch size as a proxy for readiness. A device in a low-power state may report a batch size of 1 or 2, signaling it should be deprioritized for the current training round. This allows the orchestrator to form a cohort of clients that can train with reasonable efficiency, improving round completion times and system predictability.

04

Convergence-Aware Safeguards

To ensure training stability, dynamic batching implements safeguards against excessive variance in client updates:

  • Minimum batch size: Enforces a floor (e.g., 4) to maintain a meaningful gradient signal and prevent extreme noise.
  • Gradient accumulation: On very constrained devices, the system can simulate a larger batch by accumulating gradients over several micro-batches before applying an update, preserving convergence properties.
  • Server-side normalization: During federated averaging, the server can weight updates by the actual batch size used, mitigating the bias introduced by clients with vastly different batch sizes.
05

Interaction with Model Compression

Dynamic batching is often used in conjunction with capability-based pruning and federated quantization-aware training (FQAT). The workflow is synergistic:

  1. A device receives a global model already pruned or quantized to match its static capability profile.
  2. Within that model footprint, dynamic batching then adjusts the runtime batch size based on dynamic resource availability. This two-tiered approach—static model adaptation plus dynamic batching—provides fine-grained control over the computational load.
06

Protocols for Asynchronous Operation

In asynchronous federated update settings, dynamic batching is critical for managing stragglers. A slow device with a small batch size will not block the server. The protocol handles:

  • Staleness weighting: Older updates from slow clients may be discounted.
  • Continuous local training: Devices can proceed at their own pace, recalculating batch size each epoch if resources change, without being locked to a synchronous round clock. This maximizes device participation but requires more sophisticated aggregation logic on the server.
FEDERATED EDGE LEARNING

Dynamic Batching vs. Static Batching

A comparison of two batching strategies for on-device training in federated learning systems, focusing on their handling of edge device heterogeneity.

FeatureDynamic BatchingStatic Batching

Core Principle

Batch size is adjusted per client and per round based on real-time resource availability (memory, CPU).

A fixed, uniform batch size is pre-configured and used by all clients for all training rounds.

Resource Adaptation

Primary Objective

Prevent out-of-memory (OOM) errors and maximize throughput across a heterogeneous device pool.

Ensure deterministic, synchronized training behavior across all participating clients.

Handling of Device Heterogeneity

Explicitly designed for it. Accommodates phones, sensors, and embedded systems with varying capabilities.

Poor. Assumes homogeneous or uniformly capable hardware, leading to failures on constrained devices.

System Complexity

Higher. Requires on-device resource monitors, capability profiling, and adaptive scheduling logic.

Lower. Simple to implement and orchestrate with minimal client-side logic.

Predictability of Training Time

Variable per client. Depends on dynamic resource state.

Fixed and predictable per round, given a known batch size and dataset.

Risk of Client Drop-Out

Lower. Proactive adaptation reduces OOM crashes and thermal throttling.

Higher. Constrained devices may fail or be excluded, biasing the global model.

Communication Efficiency

Potentially higher. Can allow larger effective updates from capable devices when resources permit.

Consistent. Update size is directly tied to the fixed batch size.

Integration with Client Selection

Often paired with compute-aware or resource-aware selection strategies.

Compatible with any selection strategy, but may necessitate pre-filtering for capable devices only.

Use Case Fit

Production systems with diverse, real-world edge hardware (e.g., consumer smartphones, IoT fleets).

Controlled research environments, homogeneous hardware clusters, or early prototyping phases.

FEDERATED EDGE LEARNING

Practical Examples of Dynamic Batching

Dynamic batching adapts local training to the real-time constraints of edge devices. These examples illustrate its implementation across different hardware and network conditions.

01

Smartphone-Based Image Classification

A federated learning system trains a vision model for a photo app. Dynamic batching adjusts the local batch size per device:

  • A flagship phone with 8GB RAM uses a batch size of 32.
  • A mid-range phone with 4GB RAM uses a batch size of 16.
  • An older phone with 2GB RAM uses a batch size of 8 or 4. This prevents out-of-memory (OOM) errors and thermal throttling, ensuring all devices can participate without crashing. The server receives updates from a more diverse client pool, improving model robustness.
02

IoT Sensor Anomaly Detection

A network of industrial sensors monitors equipment vibration. These sensors have severely constrained memory (e.g., 512KB RAM).

  • Dynamic batching reduces the batch size to 1 (online learning) or a small mini-batch of 2-4.
  • The training loop uses gradient accumulation to simulate a larger batch over multiple steps before applying updates.
  • This allows the tinyML model to train directly on the sensor, learning local fault patterns without exceeding memory limits or draining the battery with constant communication.
03

Adaptive Batching for Intermittent Connectivity

In a fleet of delivery vehicles, onboard computers train a route optimization model. Network connectivity is sporadic.

  • When a strong Wi-Fi connection is predicted at a depot, the system increases the batch size to perform more local computation, creating a higher-quality update to send in a single transmission.
  • When on a cellular link with poor bandwidth, it reduces the batch size to train faster and send smaller, more frequent updates, preventing a single large transmission from failing. This connectivity-aware batching maximizes useful learning per byte transmitted.
04

Healthcare Wearable Personalization

A federated system personalizes a health monitoring model on smartwatches. Battery and thermal limits are critical.

  • At 80% battery, the watch uses a standard dynamic batch size.
  • When battery falls below 20%, the batch size is minimized to 1 to reduce CPU usage.
  • If the device's internal temperature sensor indicates heating, batch size is reduced or training is paused entirely. This battery-aware dynamic batching prioritizes user experience and device safety while still enabling incremental learning.
05

Server-Assisted Dynamic Batching

For highly heterogeneous clients, the federation server plays an active role.

  1. Client Profiling: The server maintains a registry of device capabilities (CPU cores, RAM).
  2. Initial Assignment: At round start, the server suggests an initial batch size based on profile.
  3. Runtime Feedback: The client's on-device resource monitor reports memory pressure. If high, the client self-adjusts the batch size downward.
  4. Aggregation Adjustment: The server uses techniques like weighted averaging or HeteroFA to account for the variable amount of local work (influenced by batch size) when aggregating updates. This creates a closed-loop system for resource management.
06

Integration with Model Compression

Dynamic batching is often combined with other heterogeneity techniques.

  • Step 1: A global model is pruned via capability-based pruning; a lighter sub-model is sent to a weak client.
  • Step 2: Dynamic batching is applied to this already-small model to find the optimal batch size for the client's current available RAM.
  • Step 3: The client may also use gradient checkpointing to trade compute for memory, allowing a slightly larger batch. This multi-layered adaptation ensures the local training task is precisely tailored to the device's instantaneous capacity, maximizing participation and system throughput.
DYNAMIC BATCHING

Frequently Asked Questions

Dynamic batching is a core technique for managing the diverse hardware capabilities of edge devices in federated learning. These questions address its mechanisms, benefits, and implementation.

Dynamic batching is a client-side optimization technique in federated edge learning where the local batch size for on-device training is automatically adjusted in real-time based on the device's current available memory, compute capacity, and power state. Instead of using a fixed, server-mandated batch size, each client determines the largest batch it can process without causing out-of-memory (OOM) errors or excessive latency, thereby optimizing individual throughput and system-wide reliability. This is a key strategy within Edge Device Heterogeneity Management to handle variations across smartphones, IoT sensors, and embedded systems.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.