ansonantony_
  • Home
  • Projects
  • Blog
  • CV
  • Guestbook
  • Newsletter
  • Contact

// stay updated

new posts and project updates, by email

© 2026 Anson Antony

githubinstagramcoffeerss

built with next.js + supabase · privacy

← all projects

// project · 78 commits · October to November 2026

WaferEdge

Watches wafer results at the machine in real time and stops a bad lot before more wafers are processed.

13 of 13defect excursions put on hold

With the cross-lot rule, a median 2.0 h after the first bad wafer, against 3.0 h for the batch alarm. Simulated fab.

See the results ↓View code on GitHub ↗

●Results from benchmark runs against tool emulators, not real equipment. Nothing runs live here.

  • C++23
  • CUDA
  • AVX2
  • SECS-II / HSMS
  • CMake

edge › waferedge-edge: tool 127.0.0.1:5077

edge › HOLD LOT-000081 (near_full, after wafer 2018)

tool › HOLD LOT-000081: HCACK 0

0.16 ms

decision

118 ns

decode

5 / 211

false holds

Printed in a recorded run: the edge host holds a lot whose wafers show a near-full defect pattern, and the tool accepts (HCACK 0). Stats from the WaferEdge README.

01 Results

Why the stop rule matters more than speed

When a machine starts damaging wafers, every wafer it processes after that is money lost. So the stop command has to reach the machine before it starts on the next wafer. A tool tests a wafer every few seconds to minutes, and WaferEdge decides in well under a millisecond, so speed is never the bottleneck. What decides how early a problem is caught is the rule for when to stop, which is why the rules were tested on a simulated fab too.

Time budget: decision against the next wafer

Log scale. Each step to the right is ten times longer.

next wafer: seconds to minutes
WaferEdge
0.1 ms1 ms10 ms0.1 s1 s10 s1 min10 min
WaferEdge decides in 0.16 ms at the median and at most 0.71 ms for 999 of 1,000 wafers in these runs. Even if the next wafer arrived just one second later, the decision would be about 6,173 times faster than it needs to be.

A live run, recorded

The machine on the left, WaferEdge on the right. Amber lines are lot holds.

recording · 2026-11-15wafers sent 0lots held 0
jump to a hold:

// tool emulator (the machine)

$ build/release/tools/tool-emulator data/waferlens_demo.wmap --port 5077 --rate 250 --limit 6000
tool-emulator: 6000 wafers from data/waferlens_demo.wmap, 250 wafers/s, listening on port 5077

// WaferEdge edge host

$ build/release/tools/waferedge-edge --port 5077
A real run, replayed line by line in the recorded order and timing. Quiet stretches longer than 1.5 s are shortened and marked. The tool emulator sends wafer results from the WaferLens simulated fab at 250 wafers per second, far faster than a real tool, and the edge host holds lots that show a defect pattern on 3 of their last 5 wafers. The wafer counter assumes that steady rate; the final 5,843 is what the tool reported. Recorded on AMD Ryzen 5 7535HS with Radeon Graphics (12 threads, AVX2 yes, FMA yes), WaferEdge commit a3a05de.Reading the logs. Each program prints the time since it started, and the tool was started about 0.45 s before the edge host, so the same hold shows 0.45 s apart in the two panes. It is one event, not a delay. The numbers after "wafer" are wafer IDs from the WaferLens data set, not a count, so they can exceed the 6,000 wafers sent.Why the last line is slower than the benchmark. It reports about 0.55 ms from received to decided, against 0.13 to 0.18 ms in the benchmark below. This line is the median over only the 13 wafers that triggered a hold, in a run with two separate programs at a slow 250 wafers per second, where the worker thread sleeps between wafers and has to wake up for each one. The benchmark measures every wafer at 1,000 to 10,000 per second in one process, where the worker stays awake.

Latency: wafer result to hold decision

Microseconds (1,000 µs = 1 ms). Lower is better.

Text summary: Synthetic 40×40, 1,000 wafers/s: median 162 µs, p99 309 µs, p99.9 428 µs. Synthetic 40×40, 5,000 wafers/s: median 130 µs, p99 258 µs, p99.9 477 µs. WaferLens demo, 1,000 wafers/s: median 176 µs, p99 350 µs, p99.9 477 µs. WaferLens demo, 10,000 wafers/s: median 130 µs, p99 311 µs, p99.9 709 µs. Laptop, one worker thread, CPU rules, median of 3 runs. Raw latency distributions are not kept in the repo, so no histogram.

Throughput: CPU against GPU

Wafer maps checked per second, log scale. Higher is better.

Text summary: batch 1: CPU 31,800, GPU 8,100 maps/s. batch 16: CPU 110,000, GPU 110,000 maps/s. batch 1,024: CPU 152,000, GPU 986,000 maps/s. batch 16,384: CPU 151,000, GPU 875,000 maps/s. The GPU draws level with the whole CPU at about 16 maps per batch. At a tool's real wafer rate the CPU rules are the faster choice.

Closing the loop on the simulated fab

WaferLens's 24,090 simulated wafers, replayed in the order they were tested, through WaferEdge's detector and hold rule. Hours from the first bad wafer reaching test to the hold, median over 13 excursions. The default per-lot rule is slower than the batch alarm, a negative result kept on purpose. The perfect-detector row shows how much of the gap is the rules missing patterned wafers, and the last row is the cost of doing nothing: all 1,891 patterned wafers reach test.

Closed-loop results on WaferLens excursions
MonitorHeldHoursBad wafers tested firstFalse holds
WaferLens batch alarm (3 in 24 h, all lots)13 of 133.072n/a
Rules, 3 of a lot's last 5 wafers (default)13 of 138.11472
Rules, 2 of 5 per lot13 of 132.5372
Rules, 2 of 5, or 3 in 24 h across lots13 of 132.0315
Perfect detector, 3 of 5, or 3 in 24 h13 of 133.2390
No hold at all0 of 13n/a18910

02 How it works

  1. step 1

    The machine reports each wafer

    A tool emulator sends wafer test results over SEMI HSMS and SECS-II, the standard protocol between fab equipment and the factory host.

  2. step 2

    Read the message without copying it

    The decoder reads every field in place in the network buffer, with no copying and no memory allocation, so it never stalls.

  3. step 3

    Look for a defect pattern

    Fast rules on the CPU (AVX2) or FabEye's CNN on the GPU decide whether the wafer map shows a spatial pattern such as an edge ring or a scratch.

  4. step 4

    Stop the lot

    If 3 of a lot's last 5 wafers show the same pattern, the edge host sends a hold command (S2F41) back to the tool, which stops processing that lot.

// tap a step to see what it does

  1. ↓→
  2. ↓→
  3. ↓→
  4. ↓→

4/6 DetectionThe core step: decides whether the wafer map shows a spatial defect pattern. Fast rules on the CPU with AVX2, or FabEye's CNN on WaferEdge's own CUDA kernels.

Architecture. One network thread decodes; analytics threads detect and decide; the hold goes back over the same connection.

03 Summary

WhatResultCompared with
Wafer result to the decision to hold the lot, median0.13 to 0.18 msAcross all four benchmark runs. A tool sorts a wafer every few seconds to minutes
Same, slowest 1 in 100 wafers (p99)0.26 to 0.35 msMeasured open loop at 1,000 to 10,000 wafers per second, so stalls are counted
Defect excursions put on hold, replaying 24,090 simulated wafers13 of 13Cross-lot rule: 2.0 h after the first bad wafer, against 3.0 h for WaferLens's batch alarm
Decoding one 40×40 wafer report from the equipment protocol118 ns0 memory allocations, about 8 million reports per second on one core
FabEye's CNN on WaferEdge's own GPU kernels (batch 256)19,448 to 25,516 maps/sPyTorch fp16 on the same GPU 9,756, ONNX Runtime on CPU 1,092
Pattern checks on the GPU (batch 1,024)986k maps/sAbout 6 times the whole 6-core CPU (152k maps/s)
Laptop CPU
Ryzen 5 7535HS, 6 cores, AVX2
Laptop GPU
RTX 3050 Laptop, 6 GB
System
WSL2 Ubuntu, CUDA 13.3, GCC 13
Decode timings
4-thread cloud VM, no GPU

Source: the WaferEdge README, re-measured on 2026-11-10. The CNN timings on this laptop should be read as plus or minus 10 to 20%.

04 Technical details, for engineers›

Stack. C++23 (GCC 13, Clang 18), CUDA 13, AVX2, Asio coroutines, CMake presets, Google Benchmark, pybind11 Python bindings over the buffer protocol.

Protocol. SEMI HSMS framing, SECS-II items and a GEM subset (implemented from public descriptions, not certified). Wafer reports decode in place to views over the receive buffer: 118 ns for a 40×40 report, 120 ns for 200×200, 40 ns for an S2F41 hold, 0 allocations. An HSMS transaction over TCP loopback takes about 7 µs (p99 20 µs).

Threads. One network thread, analytics workers, single-producer single-consumer lock-free rings between them, no allocation on the hot path. Overload turns into counted drops, not an unbounded queue: one worker keeps up with 30,000 synthetic maps per second and starts dropping at 40,000.

Measurement. Latency is taken from each wafer's scheduled time in an open-loop schedule, so a stall delays the wafers behind it and coordinated omission is counted. WSL2 can pause the whole process; those stalls are reported, not removed.

GPU. Batched spatial-signature kernels (features, Hough line, clusters), CUDA Graphs, double-buffered streams (about 1.30M maps per second at 16,384 maps). FabEye's CNN on WaferEdge's own kernels keeps FabEye's conformal coverage in every precision (90% target: 0.8925, 0.8926, 0.8951 for fp32, fp16, int8). The CNN beats the rules on accuracy (macro-F1 0.858 against 0.655 on WM-811K test lots).

CI. GitHub Actions builds the dev, Clang and release presets, runs AddressSanitizer with UBSan and ThreadSanitizer, fuzzes the SECS-II decoder, HSMS framing and GEM layer with libFuzzer, and compiles the CUDA code. GPU tests run locally because CI runners have no GPU.

Limits. The excursions, their timing and their ground truth come from WaferLens's simulator. All timings are from one laptop under WSL2.

// other projects

FabEye →Classifies defect patterns on semiconductor wafer maps and flags the uncertain ones for human review.WaferLens →Spots when a chip factory's yield starts dropping and points to the machine that caused it.Robot Navigation →Drives a small robot to its goals in simulation, steering around the obstacles its laser scanner sees.