DEV Community

Cover image for What Edge AI Models Can ESP32-P4 Actually Run? From ESP-DL Support to Real-Time Vision Validation
ZedIoT
ZedIoT

Posted on

What Edge AI Models Can ESP32-P4 Actually Run? From ESP-DL Support to Real-Time Vision Validation

An ESP-DL model listing may say "ESP32-P4 supported," but that does not answer the question a camera product has to answer: will a result arrive while it is still useful?

Chip support, successful loading, sufficient memory, fast individual inference, and acceptable response time with the camera, display, and network all running are separate checks. Passing the first one does not certify the others.

Start with a specific job, such as detecting a person near an entrance or reading a fixed instrument display. Get a minimal model path working, then measure the complete path on the intended board, sensor, resolution, and concurrent workload. This article uses Espressif's public documentation to explain that process. It does not claim measured FPS, power consumption, temperature, recognition accuracy, or production reliability for any untested device.

Choose the job before choosing a model

The current ESP-DL Model Zoo lists object detection, face and pedestrian detection, face recognition, classification, pose estimation, OCR, and other tasks with chip support markers. Those entries do not have interchangeable inputs or outputs. A detector returns candidate locations; a classifier returns categories; an OCR pipeline has to turn image regions into usable text. Asking only how many models the chip "can run" skips the interface your application actually needs.

Consider an entrance device. Face detection answers whether a face appears in a frame. Identity recognition adds feature extraction and matching, plus enrollment, thresholds, and a response to false matches. If the product only needs to wake a display when someone approaches, adding identity recognition creates privacy and error-handling work without improving that task. Define the action to be taken on a result before selecting a model with more features than the application requires.

OCR has a similar split. Reading digits at a known location on a panel is different from reading arbitrary labels at varying angles and under glare. The first task can narrow the crop and expected character set. The second needs to deal with localization, perspective, blur, and potentially multiple languages. An OCR entry marked for P4 in the official list is a credible integration starting point. It is not evidence that a particular camera, lens, and mounting angle will read your labels accurately. That conclusion needs actual images and a record of omissions, substitutions, and rejected reads.

The list also includes non-vision tasks. Their presence does not provide performance evidence for a vision pipeline. For a camera product, lock down the image source, the desired output event, and the maximum acceptable delay first. Only then does a model shortlist become meaningful.

What "supported" can — and cannot — mean

The first level is repository-level chip support: a model or example is marked for ESP32-P4. Record the model version, dependency versions, target chip, and file source. This prevents a later library update from silently changing what was actually assessed. It does not certify an arbitrary board configuration or an arbitrary input stream.

The next level is runtime compatibility. ESP-DL's .espdl model and TensorFlow Lite Micro's .tflite model are different artifacts. The ESP-VISION P4 guide describes separate execution paths and task-specific APIs. Copying a model that worked elsewhere to an SD card does not make it loadable by ESP-DL. Check the conversion toolchain, target chip, operator support, tensor dimensions, types, and input/output conventions rather than relying on the filename extension alone.

The ESP-DL dl::Model::test(), profile_memory(), and profile_module() functions are C++ model APIs. ESP-VISION's espdl and tflite examples show a separate Python application path. Both address related validation questions, but their calls cannot simply be mixed into one program. Choose the runtime that the product firmware actually uses, and instrument that runtime's own interfaces.

The third level is application fitness. A successful test() compares a model's result against test values exported with the model. It does not include exposure changes, color conversion mistakes, motion blur, business thresholds, or display lag from a real camera. Calling that result "validated entrance recognition" would claim much more than the test covers.

Decide where the model lives before finalizing updates

ESP-DL documents three broad loading routes: embed an .espdl file in application rodata, store it in a dedicated Flash partition, or load it from an SD card. Embedding is straightforward but ties the model to an application reflash and can enlarge the application partition. A dedicated partition allows a different model-update flow but requires partition sizing and compatibility planning. SD storage makes file replacement convenient, while adding mounting, file integrity, and read-speed conditions. These are release and maintenance trade-offs, not an inherent ranking of accuracy or speed.

Route Convenient when What it costs you
Embedded in app rodata Model never changes independently of firmware Any model change means reflashing the app; app partition grows
Dedicated Flash partition Model updated separately from firmware Partition sizing, compatibility checks, version negotiation
SD card Frequent model swaps, large artifacts Mount, integrity verification, read-speed and card-quality worst cases

If a deployed device must update its model without updating the main application, design that boundary before the firmware image and partition map are frozen. Decide how the device rejects a corrupted model, how it returns to the previous compatible version, and how the firmware checks model/API compatibility. The public API establishes that several loading options exist. It does not establish that any of them has passed your product's power-loss or update testing.

Keeping parameters in Flash or copying them into faster memory is another explicit trade-off. The ESP-DL documentation describes param_copy=false as a way to reduce RAM copies, with a possible inference-speed penalty. A model that starts only after disabling the copy has not automatically met a response-time requirement. Compare both configurations with the same input, clock, and concurrent tasks before accepting the memory saving.

File size is not the application's memory requirement

A common sizing mistake is to subtract a model file's size from total PSRAM and call the remainder "free for the camera." The file does not account for intermediate tensors, parameter copies, input and output buffers, captured frames, transforms, display buffers, or other tasks. Some allocations may also need a particular memory type or contiguous region. Plenty of total PSRAM does not guarantee that the next allocation a driver needs will succeed. If the product also runs a GUI, framebuffer allocations compete directly with the model workspace.

ESP-DL's profile_memory() reports model structures, copied parameters, variables, and other overhead across internal RAM, PSRAM, and Flash. Use it as a model-level measurement, not as the entire application's peak. Log free and peak memory before and after camera initialization, model loading, display initialization, and network activity. A failure observed after display startup is much easier to explain when the memory change at each boundary is known. The combined profile() call can also show where model-layer time is spent.

A simple lower bound helps expose hidden buffers. A 640×480 RGB565 frame with no extra stride contains 614,400 pixel bytes; two complete buffers contain 1,228,800 bytes, about 1.17 MiB. That calculation excludes alignment, driver-private allocations, a resized model input, and display-side copies. It says nothing about which memory region the buffers occupy. Its purpose is to flag that frames can consume memory on the same scale as a compact model's workspace — not to predict your board's measured peak.

The model input also deserves an explicit assumption. A tightly packed 224×224×3 tensor at one byte per element needs at least 150,528 bytes. A different camera format may require a transform buffer before inference. Layout, alignment, preprocessing, and runtime allocation policy can all raise the observed number. Write the assumptions beside the estimate; "AI needs roughly 2 MB" is not a reproducible memory plan.

An inference benchmark is not a response-time benchmark

A camera result travels through capture, format conversion, resize or crop, inference, post-processing, business rules, and finally display or event delivery. profile_module() reports latency inside the model's layers. It does not include that entire path. Reporting only its total cannot explain why a bounding box still trails a moving part on a screen.

The input may need a color conversion and resize before reaching the model. A detection result may then need thresholding, box decoding, and non-maximum suppression. Camera and display ownership can add copies or queueing. None of these stages is automatically dominant, but none is safely assumed to be free. Put timestamps around each stage in the same clock domain and record end-to-end percentiles, not only model time.

"Real time" has to come from the job. A meter reader that samples once per second cares about correct readings, worst-case response, and retry behavior. A device that controls access may care far more about tail latency and false activation. A live video overlay also needs input rate, processed rate, queued frames, and age of the output image. Mean inference time alone can look healthy while the frame queue grows and the displayed decision becomes stale.

Separate model bring-up from a real camera workload

First, use a fixed input to check that the model loads, tensors match, and the model produces the expected result. ESP-DL's test() works when test inputs and outputs were included during model export. A shipping model may omit those values to save space, so the absence of built-in test values is not itself evidence of a broken model. This stage isolates conversion and runtime errors.

Second, connect the intended camera. Record sensor, lens, resolution, pixel format, exposure range, crop, and channel ordering. Preserve failed frames for analysis. If the model behaves on public example images but misses objects under actual glare, motion, or viewing angle, shaving a few milliseconds from inference will not solve the product problem. Accuracy and timing must be accepted independently.

Third, enable the display, network, logs, and continuous capture. On the same model and board settings, compare isolated and concurrent operation. Record memory peaks, end-to-end latency percentiles, dropped frames, temperature, and recovery from faults. The duration of a meaningful sustained test follows the product's duty cycle. A short demonstration is not a reliability test, and public documentation cannot supply your device's pass criterion.

Quantization changes both fit and failure modes

The ESP-DL quantization guide describes .espdl as a quantized deployment format with 8-bit, 16-bit, and mixed-precision options exported through ESP-PPQ. A smaller quantized artifact does not by itself prove unchanged application accuracy. Small objects, low-contrast digits, and motion-blurred frames may be exactly the inputs that reveal a changed error distribution.

Hold the task, preprocessing, and evaluation set constant while comparing quantization choices. Check that each model exports and loads, that board-level correctness checks pass where test data is available, and that the relevant categories or characters still meet the application error budget. Then compare memory and timing.

If a smaller variant loses recall for a safety-relevant target, an attractive average accuracy figure will not rescue the decision. If a higher-precision variant exhausts working memory, changing a recognition threshold is not a memory fix.

There may also be a .tflite route for the task. ESP-VISION treats TensorFlow Lite Micro and ESP-DL as distinct runtimes. The TFLite model needs the enabled operators and correct quantized input/output handling. Verify equivalent input and output semantics before comparing their file sizes, working memory, and elapsed times. Otherwise the experiment compares two different models or preprocessing paths rather than two runtime options.

Carry the sample into product firmware one boundary at a time

An example often places capture, model invocation, and drawing in one demonstration loop. Product firmware may also own touch input, communications, logging, updates, and power management. Before copying the loop, decide which task owns each camera buffer, where a frame becomes a model tensor, and which component consumes the result. Unclear ownership can appear to work on the first frame and then fail when a reused buffer is overwritten or an allocation remains live.

Convert the camera image according to the model's actual tensor contract. Check width, height, channel order, data type, normalization, crop policy, and the coordinate mapping back to the original image. ESP-VISION exposes preprocessing parameters and tensor metadata queries that can help with this check. If boxes are consistently shifted although an object is found, inspect crop and resize coordinates before deciding that the model itself is inaccurate.

Keep the result interface separate from the business event interface. A detection box is transient frame state; an alarm may travel over a network and be persisted. Sending an event for every frame containing the same object binds network traffic and user notifications to inference frequency. A sensible design is to pass a timestamped candidate with confidence and source-frame identity to business logic, then apply deduplication and retry policy there.

Preserve checkpoints as integration becomes more complex: readable file, model load, fixed-input output, real-camera input, display overlay, business event, network concurrency, and sustained operation. Add one variable at a time. When the next checkpoint fails, the previous one remains a useful baseline. Enabling a new camera, model, display, and wireless stack all at once may feel faster but makes a memory fault difficult to attribute.

Write an acceptance record that can explain a failure

The useful deliverable is not a sentence saying "P4 supports YOLO." It is a record tied to board and PSRAM/Flash configuration, firmware and model versions, storage location, camera conditions, pixel transformations, threshold settings, concurrent tasks, clock rate, and failed samples. Keep model-only latency separate from application response time; keep mean values separate from high-percentile delays. This makes a later regression attributable rather than anecdotal.

The gates below add one new class of uncertainty at a time. They are a validation sequence, not results of testing performed for this article.

If the model will not load, verify conversion target, file version, storage path, partition, and filesystem before replacing the board. If it fails only after extended operation, inspect memory peaks, fragmentation, ownership, and restart behavior. If boxes lag behind the scene, time capture, preprocessing, inference, post-processing, and display separately, and check whether frames queue up. Treating all three symptoms as "P4 is too slow" wastes debugging time because they point to different parts of the system.

An approval decision can therefore be conditional:

  • The model has a compatible conversion or official component route.
  • The target board retains enough usable memory with all required functions active.
  • Real inputs meet the error budget.
  • Tail latency and sustained operation satisfy the application's deadline.

Passing an earlier condition cannot stand in for a later one. Mark an unmeasured condition "pending," not with an invented FPS estimate.

If the requirement is an open-ended large language model, long context, several high-resolution video streams, or a fixed frame-rate promise before any target-board testing, the Model Zoo's P4 support marker is not a sufficient basis for a product commitment. Narrow the task, consider a different compute platform, or budget a board-level benchmark first. Compact and well-defined vision tasks are a reasonable area to investigate on P4. Suitability for a particular product still rests on the actual model, memory map, camera path, and measured results.

Sources

  • Espressif ESP-DL Model Zoo
  • ESP-DL model loading, correctness testing, and profiling
  • ESP-DL quantization and export
  • ESP-VISION: introducing a model on ESP32-P4

Top comments (15)

Collapse
 
crtdrops profile image
Israel Negrete Lepe •

The split between "supported", "loads", "fast once" and "fast enough with the camera, display and network running" is the right one, and it's rare to see a post say outright that it isn't claiming FPS for devices it hasn't tested.

I'd add two checks to the measured path. They're about method, not about the P4, which I haven't measured. First, report the distribution, not the mean. On a Raspberry Pi 5, a much bigger device, so only the method carries over, YOLO26n with half an hour on one process plus half an hour on four gave an average of 347 ms, and not one inference landed between 268 and 397 ms. The mean described a frame that never happened. Second, run it long enough to get hot: a short test can pass on a board that only starts slowing down after ten minutes.

For the entrance-device case, which number would you use to decide "the result is still useful": the p95 of the full path, or the time from someone appearing to the display waking up?

Collapse
 
zediot profile image
ZedIoT •

The 347 ms mean with nothing between 268 and 397 ms is the most useful number in this thread, and it makes the point better than any argument: you were reporting the latency of a frame that never occurred. That is the same failure mode as quoting a single peak RSS, just in the time domain.

On the method additions, I'd take both and add a third. Distributions first, absolutely, but report them per stage rather than only end-to-end, because the camera-to-inference slice and the inference-to-display slice have different tail shapes. A p95 that lives in capture tells you to fix exposure or the queue, while one that lives in inference tells you to shrink the model. Reporting only the full-path p95 hides which of the two you bought. Second, running long enough to get hot is the check most people skip, and it's the one that separates a number from a spec. I'd go further and say pick the duration from the deployment, not from the test: a device that runs eight hours a day needs an eight-hour soak at the target ambient temperature, and the interesting output is the drift between the first ten minutes and the last ten.

Third, and this is specific to the P4 class of parts: record whether the board was doing anything else. With a single camera and no display, the CPU has slack; add a display refresh and a network upload and the same model gets a different p95 without a single line of model code changing.

On your question, I'd use neither alone, because they answer different questions and the product fails on the second one. The p95 of the full path is the number for capacity planning and for regression testing across firmware revisions. The time from a person appearing to the display waking up is the number that decides whether the result is still useful, and it will always be worse than the p95 because it includes the detector's own confirmation and the display's refresh interval. My rule is to set the acceptance threshold on the wake-to-visible number and then use the p95 as the instrument I track to see if I am drifting toward it. If the wake-to-visible time is the one you gate on, you can't accidentally ship a build that passes tests while feeling slow to the person standing at the door.

One caveat worth stating, since you flagged that no inference landed in that 268-397 ms gap: a 60-point sample is enough to show the mean is a poor summary, but it isn't enough to trust a p95. If you want a tail number, sample at least a few hundred runs, or say "the distribution was bimodal" and leave the tail claim out.

Collapse
 
crtdrops profile image
Israel Negrete Lepe •

Per-stage distributions are the better version of my first check: an end-to-end p95 can't tell you whether to fix the queue or shrink the model. Gating on wake-to-visible and tracking the p95 as the instrument is a rule I'll borrow.

One correction on the sample, since your caveat depends on it: it wasn't 60 points. The Pi run had 25,898 inferences, 13,813 with one process and 12,085 with four, and every one was kept. The empty gap between 268 and 397 ms is in that full set. Your caveat still holds at the extremes, though: with one process the p99 was 137.7 ms and the maximum 267.9, and only 51 inferences went past 150 ms, so the far tail rests on few points.

Thread Thread
 
zediot profile image
ZedIoT •

Fair correction, and the 25,898 inferences matter more than the number I was arguing about. My "60 points" was inferred from the gap being described as empty, not measured by me, so I'll take your figure.

What changes with your numbers is the shape of the caveat, not its existence. With 12,085 inferences at one process and a p99 of 137.7 ms against a max of 267.9, the body of the distribution is well established and the far tail is not: 51 samples past 150 ms in 12,085 is 0.4%, which means the p99.9 lives on roughly 12 points. So the honest claim is that the median and p95 are solid, the p99 is indicative, and anything past the max you measured is unmeasured rather than impossible. That is a narrower claim than "the tail rests on few points", and it is also more useful, because it tells a reader exactly which percentile they can plan against.

The four-process run is the more interesting one. 13,813 versus 12,085 is only a 14% throughput gain for 4x the processes, and if the per-inference latency still spread the same way, the contention cost is being paid in the tail rather than the mean. That is the same conclusion this article reaches about the P4 camera pipeline: adding parallel work does not shrink the queue, it relocates it. If you still have the raw run, the p95-to-max ratio for one process versus four would settle it in a single number.

On per-stage reporting, one practical note from our side. On the P4 we could only get clean per-stage numbers by timestamping at three points (CSI frame-ready, inference done, DSI vsync) and accepting that the camera timestamp has its own jitter. If your Pi harness timestamps only at the API boundary, the stage split will look tighter than the hardware actually is.

Thread Thread
 
crtdrops profile image
Israel Negrete Lepe •

Small fix first: the counts are the other way around. 13,813 is one process and 12,085 is four, and both phases ran 30 minutes, so four processes didn't gain throughput, they lost it: 7.68 inferences per second with one, 6.72 with four.

The ratio you asked for, from the raw run: max over p95 is 1.98 with one process (135.2 to 267.9 ms) and 1.15 with four (608.3 to 702.3 ms). The p99.9 is 167.7 and 662.1. So on this Pi the contention was paid in the body, not the tail: every inference took about 4.6 times longer, and the distribution got relatively tighter. The one-process run is the one with the loose tail.

On timestamps, your warning applies in full: these numbers are inference only, with random input. No camera and no display, so there is no stage split to look tighter; there is only one stage. Your three points (frame-ready, inference done, vsync) are what it would take to say anything about the whole system.

Thread Thread
 
zediot profile image
ZedIoT •

Thanks for the correction, and the direction matters: I had read 13,813 as the four-process run, which made 4x processes look like a 14% win. With one process at 7.68 inf/s and four at 6.72 inf/s, four processes actually lose 12.5% of throughput while every inference gets ~4.6x slower. That is a much stronger result than the one I was building on, and it changes what the Pi is telling you: this is not a tail-latency problem, it is a serialization problem. Four processes on a Pi sharing one memory bus and one set of cores are not adding capacity, they are adding context switches and cache pressure to the same budget.

The max-over-p95 ratio is the cleanest number in the thread. 1.98 for one process versus 1.15 for four says the one-process run has the loose tail and the four-process run is comparatively tight around a much worse center. For planning that is the opposite of what people usually assume: concurrency bought predictability at the cost of the body. If you are sizing a system, the one-process configuration is the one where a p95 budget can still be blown by a single bad inference, and the four-process configuration is the one where you already blew it on every inference. Neither is a tail story.

What I would want next, if the harness is already there: the p50 and p95 for each configuration, not just max and p99.9. With p95 of 135.2 ms and max 267.9 ms on one process, the ratio is 1.98, but p99.9 at 167.7 ms sits close to p95, which suggests the tail is thin and a handful of outliers do all the work. If p50 is around 120 ms, then one process has a ~2x spread between typical and worst, and that is a configuration you can still defend. Four processes at p95 608.3 ms and p99.9 662.1 ms has almost no spread at all, which usually means a hard constraint, not contention noise: something is scheduling at a fixed interval and everything is queuing behind it.

On timestamps, we agree completely, and your framing is the right one. Inference-only with random input is one stage, and a one-stage number cannot say anything about a camera-to-display budget. The reason we bother with the three-point split on the P4 is not precision for its own sake: it is that the camera timestamp and the vsync timestamp fail in different ways (dropped frames versus missed deadlines), and an end-to-end number hides which one you are paying for. On a Pi with no camera and no display, there is nothing to hide, so the single-stage number is honest as long as it is labeled that way, which yours is.

If you do run the camera path later, the thing worth measuring is not the mean but the gap between inference-done and vsync on each frame. That gap is where the pipeline either has headroom or does not, and it is the number that decides whether a second model fits.

Thread Thread
 
crtdrops profile image
Israel Negrete Lepe •

Your p50 guess was close: 129.7 ms with one process and 595.4 with four. So one process spreads about 2.1x from typical to worst, and four only about 1.2x.

But before reading a scheduler into the four-process run, I have to correct my own framing, because I went back to the harness: the two phases didn't run the same configuration. The one-process phase used ONNX Runtime's default intra-op threads, so a single inference was spread across all four cores. The four-process phase ran one thread per process, one process per core. So 595 ms is mostly the single-core latency of YOLO26n on this Pi, not four inferences queuing for the same cores, and "the contention was paid in the body" was the wrong way for me to put it. Each process had a core to itself, which is also why that distribution is so tight: nothing was waiting its turn.

Where contention does show is in the gap. If a core were simply a quarter of the machine, four single-thread runs would land near 4 x 130 = 521 ms; they landed at 596, about 14% worse, the same loss as the throughput (7.68 vs 6.72 per second). My guess is memory bandwidth and the shared L3, with four copies of the weights instead of one, but I didn't measure that, so it stays a guess. The heat is consistent with it: the four-process phase peaked at 80.7 °C with the clock holding 2,400 MHz, while the one-process phase reached 85.1 °C and throttled.

Agreed on the inference-done-to-vsync gap. That's the number I'd want before claiming a second model fits.

Thread Thread
 
zediot profile image
ZedIoT •

Updating the harness and saying so is the part most threads never get to, so take the correction as given: if the one-process phase was intra-op parallel across four cores and the four-process phase pinned one thread per core, then 595 ms is single-core YOLO26n latency and my serialization reading was wrong. Withdraw it. The tight distribution on four processes now makes sense without a scheduler story: each process owned a core and had nothing to wait for, while the one-process run had four threads contending for shared cache and a single clock budget, which is exactly the shape that produces a 2.1x body spread and a throttled 85.1 °C peak.

What is left standing is the gap, and it is a better result than the one either of us started with. Four single-thread processes landing at 596 ms against a 4 x 129.7 = 519 ms "quarter of a machine" expectation is 15% over, and it lines up with the 12.5% throughput loss, which means the two numbers are the same measurement seen from both ends rather than two independent confirmations. That is the number I would put in a post: on this class of device, per-core scaling is not free and the tax shows up as a double-digit percentage even when nothing is queuing.

Memory bandwidth and shared L3 with four copies of the weights is the right first hypothesis, and you can test it without new hardware. Run two processes instead of four and look at where the latency lands: if it is near 2 x 130 = 260 ms plus a similar percentage rather than half of 596, the shared-resource story holds and the tax is roughly proportional to process count. If two processes land much closer to 260 ms flat, then four was a threshold event, which would point at L3 capacity rather than bandwidth, because four weight copies is where the working set stops fitting. Either answer is worth having, and the two-process run is 30 minutes of the harness you already have.

One caveat on the thermal comparison, since it cuts against the conclusion: 85.1 °C with throttling on one process versus 80.7 °C at a held 2,400 MHz on four means the single-process run was the one thermally limited. So part of its 129.7 ms p50 may be throttle, not just intra-op contention, and the honest comparison needs the one-process run with threads pinned to a single core too, warmed to the same steady state. That would give four numbers instead of two: single-core single-process, single-core four-process, all-core single-process, all-core four-process. The 2x2 is what separates "concurrency tax" from "thermal headroom", and right now the thread is attributing both to memory.

The inference-done-to-vsync gap stays the open question for the P4 work, and your Pi result actually sharpens what to look for: if per-core scaling costs 15%, the interesting quantity is not the mean gap but how much of it is left when the pipeline stalls. A gap that is comfortable on average and near zero at p99 means there is no room for a second model regardless of the average, which is the trap the single-stage numbers hide.

Thread Thread
 
crtdrops profile image
Israel Negrete Lepe •

One correction to the two-process prediction, and one number on the thermal caveat.

With one thread per process, two processes shouldn't land near 2 x 130. Each inference still runs on a single core, so both should sit near single-core latency, around 520 ms, plus whatever the shared resources cost with two copies of the weights instead of four. That still makes two processes a good test of bandwidth versus L3, just with 520 as the baseline instead of 260.

Which points at the cell we're actually missing: one process, one thread. Right now 521 is 4 x 130, and that assumes the four-thread run scaled perfectly. If intra-op parallelism lost anything, the true single-core time is below 521, and the four-process tax is bigger than 14%, not smaller. So 14% is a floor.

On the throttle: the harness logs in five-minute windows. The first window of the one-process phase ran at a mean real clock of 2,397 MHz with no throttle flags, p50 128.3 ms. The last one, throttled, averaged 2,283 MHz, p50 131.2 ms. So throttling moved the one-process p50 by about 2%, which doesn't change the gap.

Thread Thread
 
crtdrops profile image
Israel Negrete Lepe •

I ran the cells we were missing last night, same Pi and same harness, ten minutes each with cool-downs in between, and they overturn what I said in my last two replies. You were closer.

One process, one thread: p50 288.4 ms, 3.47 inferences per second, on exactly one core. Two processes, one thread each: 324.0 ms, 6.17 per second. Four processes, one thread each: 594.1 ms, 6.71 per second, matching the original run. One process with default threads: 129.5 ms, 7.68 per second.

So 595 ms is not single-core latency, and my "around 520 ms" for two processes was wrong: they landed at 324. A single core takes 288, and running four single-thread processes at once doubles it. Each process did have a core to itself, so it isn't queuing for cores, but something they share runs out: throughput goes 3.47, 6.17 and 6.71 per second for one, two and four processes. The second core adds 78% of a core; the next two add 9% between them. That's the shape of a saturated shared resource, memory bandwidth or the L3, and this run can't tell which without hardware counters.

It also explains why one process with four threads is still the fastest way to use this Pi, at 7.68 per second: one copy of the weights, less traffic through whatever the four processes were fighting over. Intra-op parallelism gives 2.2x on four cores (288 to 129.5), not 4x.

The thermal caveat stays small: the default-threads phase throttled in its second window at 84 °C, and its p50 moved from 129.3 to 129.9 ms.

I should have measured before reasoning about it twice.

Thread Thread
 
zediot profile image
ZedIoT •

The 3.47 / 6.17 / 6.71 curve is the cleanest thing in this thread, and it settles the argument better than either of us did. You went and ran the cells instead of defending the framing, which is why this converged.

What it changes, concretely:

1. The two-process point was the whole question, and it answered "shared resource." 324 ms is not 2 x 288 = 576 and not ~288 flat. It sits at 1.12x single-core latency while delivering 1.78x the throughput. That is the signature of a resource that scales nearly linearly until it saturates — a single core has spare capacity the moment a second one joins, and by process three there is nothing left to give. If it were bandwidth-limited from the start, the two-process point would already show the 4x congestion; if it were core-queuing, it would land near 576. It landed in the gap, which is exactly where a shared-memory-capacity story predicts and neither pure story does.

2. The 6.17 → 6.71 step is the capacity threshold. Two cores bought 78% of a core. The next two bought 9% combined — 4.5% each. That is not a curve, that is a wall. Given the same weights are read every inference, my read is L3: 2 copies likely still fit and stay resident, 4 copies cross the size of the shared cache and every inference starts pulling weights from DRAM. Your 4-thread single-process result corroborates it — one copy of the weights, 7.68/s, the best throughput on the board. Fewer copies of the same bytes is worth more than more cores.

3. What would actually separate L3 from bandwidth, and it is cheap. Two experiments, both on your existing harness:

  • Same four processes, smaller model. Swap YOLO26n for anything that fits the L3 twice over (a nanoscale detector, or even the same net at 160x160 input). If four processes scale near-linearly with the smaller working set, it is capacity. If the wall stays at the same process count, it is bandwidth.
  • Four processes, staggered start. Launch them 250 ms apart instead of at once. If the wall is residency, staggering keeps the copies from evicting each other and throughput recovers partway; if it is raw DRAM bandwidth, staggering changes nothing because the average demand is unchanged.

perf stat -e LLC-load-misses,LLC-loads,armv8_pmuv3/l2d_cache_refill/ around one inference loop would answer it outright, and perf on that Pi image usually cooperates even under the usual paranoid setting for this class of event. If hardware counters are not available, the staggered-start test costs ten minutes and needs no privileged access.

4. On the thermal caveat, you already closed it better than I did. 129.3 to 129.9 ms across a throttling window at 84 °C means thermal is not a term in this model at ten-minute runs. That retire is fair — I raised it as a candidate and the data says no. What it does mean is that whatever tuning follows from this must be re-checked at 30 minutes, since your original phase had no cool-downs and the 30-minute single-process run is the only place throttling actually showed up.

The number I'd take away for a deployment decision: intra-op threading gave 2.2x on four cores, not 4x, and four single-thread processes gave 1.93x over one. So on this class of chip, the practical ceiling for YOLO26n-class detection is roughly 7.7 inferences per second whether you go wide-thread or multi-process — and the deep pipeline design should assume ~50% of nominal core-count scaling, not the core count.

Thread Thread
 
crtdrops profile image
Israel Negrete Lepe •

Ran both, plus the counters, on the same Pi 5 and harness. Short version: staggering did nothing, the smaller input scaled better but still hit a wall at four, and the counters say both things are happening.

One correction to the premise first: YOLO26n is about 2.4M parameters, roughly 9.9 MB of FP32 weights, and the Pi 5's shared L3 is 2 MB. Not even one copy of the weights fits, so what can stay resident is the hot part of the working set, not the model.

Staggered start. Four single-thread processes launched 250 ms apart, 10 minutes: 6.83 inferences/s against 6.70 started together, p50 588 ms against 594. Within noise.

Smaller working set. The existing ONNX would not take a 160x160 input (the attention block has fixed shapes), so I re-exported YOLO26n at 160 with the same NMS-free head. Same weights, activations 16x smaller:

  • 1 process: 52.9/s (18.8 ms)
  • 2: 102.4/s (1.93x)
  • 4: 123.7/s (2.34x, p50 32.2 ms)

At 640 the same steps were 1.78x and 1.94x. Better, but four cores still buy less than two and a half.

Counters. perf is not installed on that image and I did not want to add packages for this, but with perf_event_paranoid=2 a process can count its own user-space events, so I opened the A76 counters directly with perf_event_open from Python around a 60 s inference loop, running 1, 2 and 4 copies at once. Per inference at 640:

  • cycles 541M → 641M → 1,085M, instructions flat, so IPC 1.85 → 1.56 → 0.92
  • L3 refills 3.80M → 4.48M → 6.70M
  • last-level read miss ratio 44% → 51% → 62%

At 160: L3 refills 0.19M → 0.21M → 0.36M, miss ratio 38% → 43% → 56%.

My reading: misses per inference go up as processes are added, at both sizes, so it is not only bandwidth with the same misses getting slower. The copies are evicting each other's hot data from the shared L3. But at four the cycles grow faster than the misses (+101% against +76% at 640), so each miss also costs more. Capacity and bandwidth together, with capacity showing up first.

The four-process run at 160 touched the soft temperature limit for about a third of the phase (real clock averaged 2,375 MHz, 1% low), not enough to move these numbers.

Caveats: one device, one run per cell, user-space counts only (so absolute cycles are low; the ratios are what I'd trust), and I'm reading the A76 L3 and last-level events as documented, without validating them against a known workload.

Thread Thread
 
zediot profile image
ZedIoT •

Both corrections are mine to take, and one of them changes the headline.

The weights number. 2.4M params x 4 bytes = 9.9 MB against a 2 MB shared L3 means my "two copies fit, four cross the cache" story was wrong at the arithmetic level. Nothing fit in the first place. What the 160x160 result then says is more useful than the model I was proposing: activations dropped 16x, throughput at four went 1.94x to 2.34x, so what the copies were fighting over was the activation working set and the re-fetched weight stream, not the model being resident or not. Cache capacity is still the mechanism, just at a working-set scale I had anchored twenty times too high.

The counter data is the part that settles it and I want to be precise about which claim it kills. Misses per inference rise at both sizes (3.80M to 6.70M at 640, 0.19M to 0.36M at 160) while instructions stay flat. A pure bandwidth ceiling with unchanged miss count cannot produce that. So eviction is real and it is primary. The second half — cycles growing +101% against misses +76% at four — is the part that keeps bandwidth alive as a co-defendant: once the hot set is gone, a larger fraction of the remaining misses are DRAM and each one costs more. Capacity first, bandwidth compounding on top. That is the ordering your numbers support and it is more precise than either of our original positions.

What I'd actually revise in the deployment advice off this:

  • The 7.7/s ceiling is not a core-count story, it is a bytes-touched-per-inference story. At 640 the four-process run reads 6.70M L3 refills per inference at a 62% miss ratio; at 160 it drops to 0.36M at 56%. The way to buy throughput on this class of part is shrinking per-inference memory traffic, not adding workers. Input resolution is the lever with the biggest ratio; quantization is the second.
  • 2.34x at 160 instead of 1.94x at 640 means the "assume 50% of nominal core scaling" rule of thumb is input-size dependent and should be measured per resolution, not adopted as a constant. The same four cores gave 59% of nominal at one working-set size and 48% at another.
  • Staggered start being within noise is a genuinely useful negative result. It says the eviction is steady-state, not a startup transient, so no launch-order trick is available and the fix has to be structural. I would have bet ten minutes on it the other way, so thank you for spending them.

Two things I would not read as settled yet. The 2,375 MHz average with a "1% low" at the soft limit for a third of the phase — that is thin enough that I would want the 30-minute single-process cell re-run before I call thermal out of the model for small-input workloads. And user-space-only counts put the absolute cycle numbers low by an unknown factor, which is fine for ratios but means the "instructions flat" result is only flat relative to what the counters saw; if a meaningful share of the work sat in kernel or in a library built without the same counter attribution, IPC 1.85 to 0.92 is still directionally right but not a clean architectural number.

If you ever re-export at 160 with int8, that is the one cell that would tell us whether the remaining wall is bandwidth or core-bound: same memory traffic as fp32 at 160 but double the compute per byte, and if it scales past 2.34x the wall was traffic, not cores.

Thread Thread
 
crtdrops profile image
Israel Negrete Lepe •

Ran the int8 cell tonight, same Pi 5 and harness as the fp32 160 run: one, two and four single-thread processes, then 60 s of counters for each.

First, int8 didn't keep memory traffic constant. Static QDQ quantization (onnxruntime 1.30, per channel) cut L3 refills per inference from 0.189M to 0.073M and instructions from 72.4M to 38.9M. It moves bytes and compute together, so it can't split them as cleanly as we hoped.

Second, fully quantized, the model lost 8 of 11 detections on held-out images, so I kept the detection head in fp32. With that, 9 of 11 matched fp32. That's 4 held-out images and calibration on 8, fine for timing, not an accuracy claim.

Throughput, total inferences per second:

  • fp32 160: 52.9 / 102.4 / 123.7, so 1.93x at two and 2.34x at four
  • int8 160: 104.8 / 198.5 / 282.0, so 1.89x at two and 2.69x at four

Per process at four: fp32 went from 18.8 to 32.2 ms (+71%), int8 from 9.5 to 14.1 ms (+48%).

Counters, one process vs four:

  • fp32: L3 refills per inference +92%, cycles +64%
  • int8: L3 refills per inference +110%, cycles +46%, IPC 2.19 to 1.50

My reading: the copies still evict each other, since refills per inference roughly double in both. But with fewer bytes per inference, the misses weigh less in the total, and four processes get closer to four times one. That fits your traffic reading. What it doesn't give is a pure compute-per-byte test, because int8 lowered the traffic too.

On temperature, a correction to how I worded it: the soft limit showed up in the four-process fp32 160 cell, not in the single-process one. One process peaked at 65.9 °C with no live throttle bits. The int8 four-process cell peaked at 80.7 °C and never set the soft-limit bit, with the real clock averaging 2398 MHz. So I don't expect a 30-minute single-process rerun to show anything new, but I can run it if you want it on record.

Agreed on user-space-only counts: ratios, not architecture-grade numbers.

Caveats: one device, one run per cell, and the int8 graph keeps the head in fp32, so it's a mixed model, not a clean int8 one.

Thread Thread
 
zediot profile image
ZedIoT •

The int8 cell is the most useful thing posted in this thread, and the part I want to flag first is that you caught your own framing problem before anyone else could: int8 cut L3 refills 0.189M -> 0.073M and instructions 72.4M -> 38.9M, so it never was a compute-per-byte test. That kills the clean separation, agreed. What survives is narrower and still worth having: in both precisions the four-process cell roughly doubles refills per inference (+92% fp32, +110% int8), so the eviction mechanism is precision-independent. Only its cost share moves. With 2.6x fewer refills per inference, the same absolute miss penalty has less to eat into, which is why int8 goes 1.89x -> 2.69x at four while fp32 stalls at 1.93x -> 2.34x.

Your per-process numbers make that concrete: +71% at four for fp32, +48% for int8, and IPC falling 2.19 -> 1.50. The IPC drop is the tell. Refills nearly double relative to work, so the core spends a larger fraction of its slots stalled, and the scaling gap between fp32 (2.34x) and int8 (2.69x) is close to what the refill ratio predicts. If you wanted the clean version, the cell would be fp32 and int8 at identical bytes per inference, which means an fp8 or a padded-int8 graph that keeps bytes constant and only changes arithmetic. Short of that, reporting both ratios side by side and saying they are not separable is the honest result, and that is what you did.

On the temperature correction: I'll take it, and it changes something I said earlier. I had read the soft limit as living in the single-process fp32 160 cell, and used it as an argument that the 129.7 ms p50 was partly throttled. Your correction puts the soft-limit bit in the four-process fp32 160 cell, with the single-process cell at 65.9 C and no live throttle bits. That withdraws the caveat on the single-process latency. It also makes the four-process 80.7 C reading more interesting than it looked: 80.7 C with no soft-limit bit set and a 2398 MHz average means the thermal headroom at four processes sits right at the limit, not comfortably below it. If a fifth process or a longer soak crossed the bit, you would see the ceiling before you saw the bandwidth tax, and the two would then be confounded the same way your two-phase configuration was.

So the ordering I would keep is this: bandwidth and eviction first, since they are measured in both precisions, and thermal second, since it only shows up in one cell and did not fire. On the 30-minute rerun, don't spend it. The 65.9 C single-process figure and the absent throttle bits are enough for the record, and the remaining headroom question belongs in a soak at four processes, not one.

The accuracy caveat is the one I would not let slide, though, and you flagged it correctly: 9 of 11 matched on four held-out images is a timing artifact, not an accuracy claim, and a mixed graph with an fp32 head is a different model from a clean int8 one. If the head has to stay fp32 to keep detections, that is itself the result. It says the quantizable part of this network is not where the detections live, and it would be worth one line in the writeup saying so plainly.