INT8 inference needs an order of operations A developer added a new `05-ebpf-jev` module to `llm.asm` that specifies the exact order of operations for INT8 inference in eBPF-Jev: accumulate products and bias, interpret the result as signed, right-shift, then clamp. The module ships a Python reference and a shared C header, and worked examples show that shifting each product before accumulation or clipping the accumulator early produces different neurons (1 vs 0 and 127 vs 7). The developer notes that Python's floor-rounding right shift differs from C-style truncation on negatives, and that the C helper's unsigned 32-bit accumulation wraps at the boundary, so ports using unbounded integers can disagree at extreme values. For the integer inference contract in eBPF-Jev, I read the arithmetic as a sequence: accumulate products and bias, interpret the signed result, shift, then clamp. Rearranging those operations changes the function. “It is all INT8” is not enough of a specification. The new 05-ebpf-jev addition to llm.asm makes that sequence visible in both a Python reference and a shared C header. Its hidden layer accumulates into a wider value, applies a right shift and a nonnegative clamp, then carries part of the hidden output into the next event. 1 2 3 I worked through tiny invented inputs to isolate the arithmetic. These are numerical illustrations, not pretrained-model outputs or a kernel benchmark. Take products 3 and 3 , zero bias and a right shift of 2 . Adding first gives 6 2 = 1 . Shifting each product first gives 0 + 0 = 0 . The discarded remainders cannot combine after they have been discarded. Original worksheet of the executed integer examples. Inputs are illustrative. Image by Shivam Dwivedi. Clipping early loses a different kind of information. With two products of 127 × 127 , the accumulator is 32258 . A shift of 4 gives 2016 , and the final hidden value saturates at 127 . If I clip the accumulator to 127 first and then shift, I get 7 . Both wrong routes look like plausible attempts to keep intermediate values small. Both implement a different neuron. Save the following as demo.py and run python3 demo.py . products contains already-multiplied terms, so the example can focus on accumulation and rescaling. The shifts are chosen inputs. python def signed32 value : return value + 1 << 31 % 1 << 32 - 1 << 31 def hidden products, bias, shift : acc = signed32 bias + sum products return min 127, max 0, acc shift small = 3, 3 correct = hidden small, 0, 2 shift each = min 127, max 0, sum p 2 for p in small large = 127 127, 127 127 late clip = hidden large, 0, 4 early clip = min 127, max 0, sum large 4 assert correct, shift each == 1, 0 assert late clip, early clip == 127, 7 assert -3 1 == -2 and int -3 / 2 == -1 assert hidden 1 , 1 << 31 - 1, 0 == 0 print "sum then shift / shift each:", correct, shift each print "shift then clamp / clamp early:", late clip, early clip print "negative shift / truncation:", -3 1, int -3 / 2 print "signed wrap:", signed32 1 << 31 - 1 + 1 for acc in range -1024, 1025 : for shift in range 8 : assert acc shift == acc // 2 shift print "integer division cross-check passed" sum then shift / shift each: 1 0 shift then clamp / clamp early: 127 7 negative shift / truncation: -2 -1 signed wrap: -2147483648 integer division cross-check passed The negative example matters for the output layer. Python’s signed right shift rounds downward: -3 1 is -2 . Converting -3 / 2 to an integer truncates toward zero and gives -1 . If the result selects a lookup-table entry, that difference changes the index. In the checked source, the clamped logit is offset by 128 before the sigmoid-table lookup. 1 2 The loop independently compares shifts with integer floor division across the shown range. That checks this arithmetic identity; it does not check a trained network’s decisions. The C helper accumulates through an unsigned 32-bit variable and then interprets the result as signed before shifting. Its comment explicitly makes wrapping part of the intended behavior, including extreme biases. 2 My signed32 helper models that wrap with integer modulo arithmetic. At the edge in the code, adding 1 to 2147483647 becomes -2147483648 . The hidden activation consequently becomes zero. Python’s otherwise unbounded integers would not do that automatically. A cross-language port that quietly uses unbounded accumulation can therefore disagree at the boundary even when all its small examples pass. That does not tell me whether a particular exported weight pack reaches this edge. It tells me what must be preserved—or explicitly ruled out by bounds—when testing a port. The source’s actual hidden update, signed conversion, shift and table lookup belong in parity tests with the same weights, inputs and carried state. Agreement on these toy calculations is an early arithmetic check. It is not evidence of eBPF verifier acceptance, live latency, calibrated risk scores or protection against real attacks. I did not load its weights or run its kernel hooks. Alexey Fateev and contributors, Python fixed-point reference https://github.com/alesha-pro/llm.asm/blob/9389c88db493ead23452df29b2c9be21594065ce/05-ebpf-jev/ml/fixed point.py . Alexey Fateev and contributors, shared C inference helpers https://github.com/alesha-pro/llm.asm/blob/9389c88db493ead23452df29b2c9be21594065ce/05-ebpf-jev/bpf/ebpf jev common.h . Alexey Fateev and contributors, fixed-point architecture contract https://github.com/alesha-pro/llm.asm/blob/9389c88db493ead23452df29b2c9be21594065ce/05-ebpf-jev/SPEC CONTRACT.md . Python documentation, integer bitwise operations https://docs.python.org/3/library/stdtypes.html bitwise-operations-on-integer-types . Original explanatory figure and example, CC BY 4.0. Credit: Shivam Dwivedi. No third-party image assets. AI was used to draft the article.