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.
Keep the small contributions until after the sum
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.
Execute the contract, including its edge
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.
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 accumulator has a contract too
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.
References
Alexey Fateev and contributors, Python fixed-point reference.
Alexey Fateev and contributors, shared C inference helpers.
Alexey Fateev and contributors, fixed-point architecture contract.
Python documentation, integer bitwise operations.
Asset credits
Original explanatory figure and example, CC BY 4.0. Credit: Shivam Dwivedi. No third-party image assets.
AI disclosure
AI was used to draft the article.


