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.
Glossary
Dynamic Batching

What is Dynamic Batching?
A core technique in federated edge learning for managing diverse hardware constraints.
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.
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.
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.
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.
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.
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.
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:
- A device receives a global model already pruned or quantized to match its static capability profile.
- 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.
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.
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.
| Feature | Dynamic Batching | Static 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. |
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.
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.
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.
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.
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.
Server-Assisted Dynamic Batching
For highly heterogeneous clients, the federation server plays an active role.
- Client Profiling: The server maintains a registry of device capabilities (CPU cores, RAM).
- Initial Assignment: At round start, the server suggests an initial batch size based on profile.
- Runtime Feedback: The client's on-device resource monitor reports memory pressure. If high, the client self-adjusts the batch size downward.
- 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.
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.
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Dynamic batching operates within a broader ecosystem of techniques designed to manage the extreme variability of edge hardware. These related concepts address complementary challenges in compute, memory, connectivity, and scheduling.
Resource-Aware Scheduling
A federated learning orchestration strategy that dynamically assigns training tasks to edge clients based on their real-time available computational power, memory, and energy constraints. Unlike static schedules, it continuously evaluates device state to:
- Prioritize clients with surplus CPU/GPU cycles.
- Avoid overloading devices nearing memory limits.
- Defer tasks for devices with low battery. This ensures efficient round completion and protects user experience.
Client Capability Profiling
The systematic process of measuring and cataloging the static and dynamic resources of enrolled edge devices. This creates a registry used by the server for intelligent orchestration. Profiled metrics include:
- Static: CPU architecture, total RAM, NPU support.
- Dynamic: Available memory, battery percentage, network bandwidth, thermal status. This foundational data enables techniques like dynamic batching and compute-aware selection.
Memory-Constrained Optimization
A suite of techniques that modify the federated training process to operate within the strict RAM limitations of edge devices. These are often used in conjunction with dynamic batching and include:
- Gradient Checkpointing: Trading compute for memory by re-calculating activations during the backward pass.
- Selective Layer Updating: Only computing gradients for a subset of model layers per round.
- Capability-Based Pruning: Transmitting a sparser sub-model to clients based on their memory profile.
Variable-Length Training Rounds
A federated learning protocol that allows clients to perform different numbers of local SGD steps based on their available resources, rather than enforcing a fixed epoch count. A device with high compute might perform 10 local epochs, while a constrained device may only manage 2. The server must then account for this heterogeneity in local computation when aggregating updates, often using weighting schemes based on steps or data processed.
Asynchronous Federated Updates
A communication protocol where the server aggregates client model updates as soon as they are received, without waiting for a synchronized round to finish. This accommodates clients with highly variable training times caused by dynamic batching and other heterogeneity factors. Benefits include:
- Higher device participation rates.
- Reduced idle time for fast clients.
- Challenges include managing update staleness and designing stable aggregation for non-iid updates.
Federated Dropout
A technique that randomly drops out a subset of neurons or entire layers for individual clients during a training round. This creates smaller, client-specific sub-models that reduce computation and memory load—acting as a form of architectural dynamic batching. Benefits include:
- Lower per-client resource requirements.
- A form of regularization that can improve generalization.
- Enables participation from very low-capacity devices. The server aggregates updates only for the active parameters in each round.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us