Skip to content

armgit / kokon

Public Imported from GitHub
0

Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.

Mac engine: remove the int8-weights-only Neural Engine path (KOKON_ANE_INT8=w8)

Gabriele Lozupone473ed8ea08b5
diff --git a/engine-mac/README.md b/engine-mac/README.md
index ff1f724..8809260 100644
--- a/engine-mac/README.md
+++ b/engine-mac/README.md
@@ -429,15 +429,10 @@ correctness test that runs on any Mac (`PerChipTests`). Only the M2 Pro has meas
run on the GPU's neural accelerators, before it on the shader cores). Its source compiles at run time on macOS 27,
so it is on wherever Metal 4 runs (`KOKON_NA=0` off). M2 Pro: 6.3 TFLOP/s against MPS's 5.6 at 1536 × 4096 × 4096,
bit for bit the same result (`check-na`); per evaluation at 1024², 3 alternated rounds: 7.57 → 7.48 s.
-- **int8 products on the Neural Engine** (libnnc's M3/M4 path; `KOKON_ANE_INT8=w8` int8 weights, `=1` int8 weights and
- rows). Opt-in on every chip, as their error does not depend on the chip. M2 Pro: one 1792 × 4096 × 4096 tile 10.1 ms
- in fp16, 8.3 ms with int8 weights, 7.0 ms in int8 (`check-ane8`); per evaluation 7.42 → 7.20 / 7.00 s; but the
- velocity at 896² goes from 7.6e-4 to 1.1e-2 / 4.1e-2 (one int8 scale per 4 096 weights where Q4_K has one per 32;
+- **int8 products on the Neural Engine** (libnnc's M3/M4 path; `KOKON_ANE_INT8=1`, int8 weights and rows). Opt-in on
+ every chip, as their error does not depend on the chip. M2 Pro: one 1792 × 4096 × 4096 tile 10.1 ms in fp16, 7.0 ms
+ in int8 (`check-ane8`); per evaluation 7.42 → 7.00 s; but the velocity at 896² goes from 7.6e-4 to 4.1e-2 (one int8 scale per 4 096 weights where Q4_K has one per 32;
activation rows with outliers). **Finer scales do not fix it** (2026-10-25, below): int8 stays opt-in.
-- **int8 weights alone** (`KOKON_ANE_INT8=w8`) are broken in a whole generation: on every Mac in the bench reports and
- on the M2 Pro (2026-10-28) the image comes out black (non-finite) at 512² to 1024², with either DiT file, while one tile
- (`check-ane8`, 5.8e-3), `check-dit` at 896² (1.1e-2) and `time-dit` stay finite; turning off the prefix cache, the
- fused kernels, shared rows, the AMX, fp16 activations or Metal 4 does not fix it. Cause not found; out of the bench.
- **Each product released at once** where signals arrive late (`KOKON_FLUSH_READY=0` off, `=1` on): a wait on
`ready` right after its signal, chosen by a ~50 ms measurement at the engine's start (`Coexecutor.signalArrivesLate`),
every start, so a macOS update is seen. On the M5 Pro (macOS 26.6) a signal inside a command buffer reaches the CPU only at the next wait the
diff --git a/engine-mac/Sources/KokonEngine/Balancer.swift b/engine-mac/Sources/KokonEngine/Balancer.swift
index 006aef9..a8c5cc5 100644
--- a/engine-mac/Sources/KokonEngine/Balancer.swift
+++ b/engine-mac/Sources/KokonEngine/Balancer.swift
@@ -169,7 +169,7 @@ extension Coexecutor {
}
var memoryKey: String {
- "\(context.device.name) rows \(rows) ane \(aneEnabled)\(aneInt8 ? aneHalfRows ? " w8" : " int8" : "") amx \(amxEnabled) ane-attention \(balancer.aneAttention)\(flushRelease ? " flush" : "")"
+ "\(context.device.name) rows \(rows) ane \(aneEnabled)\(aneInt8 ? " int8" : "") amx \(amxEnabled) ane-attention \(balancer.aneAttention)\(flushRelease ? " flush" : "")"
}
/// Takes the remembered shares for this Mac and shape, if any.
diff --git a/engine-mac/Sources/KokonEngine/Bench.swift b/engine-mac/Sources/KokonEngine/Bench.swift
index 59dedb0..643b4a9 100644
--- a/engine-mac/Sources/KokonEngine/Bench.swift
+++ b/engine-mac/Sources/KokonEngine/Bench.swift
@@ -58,8 +58,7 @@ public enum Bench {
var runs = [Run(name: "default (paths above)", environment: [:])]
for path in paths { runs.append(Run(name: "\(path.1)=\(path.2)", environment: [path.1: path.2])) }
- // The opt-in int8 Neural Engine path where it may pay (libnnc's M3/M4 path; less accurate everywhere). Not `w8`:
- // its images come out black in a whole generation on every Mac (README, "int8 weights alone").
+ // The opt-in int8 Neural Engine path where it may pay (libnnc's M3/M4 path; less accurate everywhere).
if (chip.generation ?? 5) >= 3, #available(macOS 26, *) {
runs.append(Run(name: "KOKON_ANE_INT8=1", environment: ["KOKON_ANE_INT8": "1"]))
}
diff --git a/engine-mac/Sources/KokonEngine/Checks.swift b/engine-mac/Sources/KokonEngine/Checks.swift
index 1ff4465..b1dea1d 100644
--- a/engine-mac/Sources/KokonEngine/Checks.swift
+++ b/engine-mac/Sources/KokonEngine/Checks.swift
@@ -375,19 +375,6 @@ extension Checks {
int8.read { y in for i in 0..<(rows * n) { y8[i] = Float(y[i]) } }
let e8 = error { i, j in Double(y8[i * n + j]) * Double(k) * Double(rowScale[i]) * Double(columnScale[j]) }
print(String(format: "int8 program %d×%d×%d: %.2f ms (%.1f TOP/s), relative error %.2e", rows, k, n, t8 * 1e3, flops / t8 / 1e12, e8))
- // int8 weights, fp16 activations: x lifted so |y| = |Σ x w_q| / K <= max|x| · 127 stays under 2^15.
- let w8 = try NeuralEngineProduct(rows: rows, k: k, n: n, int8: true, halfActivations: true)
- let lift = (0..<rows).map { i in exp2(floor(log2(32768 / 127 / max(1e-30, (0..<k).reduce(Float(0)) { max($0, abs(a[i * k + $1])) })))) }
- w8.write(w8.x) { p in for i in 0..<rows { for l in 0..<k { p[i * k + l] = Float16(a[i * k + l] * lift[i]) } } }
- CVPixelBufferLockBaseAddress(w8.w, [])
- let pw = CVPixelBufferGetBaseAddress(w8.w)!.assumingMemoryBound(to: Int8.self)
- for l in 0..<k { for j in 0..<n { pw[l * n + j] = q(w[l * n + j] / columnScale[j]) } }
- CVPixelBufferUnlockBaseAddress(w8.w, [])
- let tw = try time(w8)
- var yw = [Float](repeating: 0, count: rows * n)
- w8.read { y in for i in 0..<(rows * n) { yw[i] = Float(y[i]) } }
- let ew = error { i, j in Double(yw[i * n + j]) * Double(k) * Double(columnScale[j]) / Double(lift[i]) }
- print(String(format: "int8 weights, fp16 activations %d×%d×%d: %.2f ms (%.1f TFLOP/s), relative error %.2e", rows, k, n, tw * 1e3, flops / tw / 1e12, ew))
}
}
diff --git a/engine-mac/Sources/KokonEngine/Coexecution.swift b/engine-mac/Sources/KokonEngine/Coexecution.swift
index 245c155..5cb4923 100644
--- a/engine-mac/Sources/KokonEngine/Coexecution.swift
+++ b/engine-mac/Sources/KokonEngine/Coexecution.swift
@@ -66,23 +66,21 @@ final class Coexecutor {
let aneEnabled: Bool, amxEnabled: Bool
/// **int8 products on the Neural Engine** (`NeuralEngineProduct.int8Program`, `ane8_*` in `ane.metal`), the path
/// libnnc (ccv) takes on the M3 and M4: W per column (its scales once per weight, the weight at each use as in
- /// fp16) and, with `KOKON_ANE_INT8=1`, A per row too; `KOKON_ANE_INT8=w8` keeps the rows fp16. Opt-in on every
+ /// fp16) and A per row (`KOKON_ANE_INT8=1`). Opt-in on every
/// chip: the error does not depend on the chip, and on the M2 Pro (2026-10-25) one 1792 × 4096 × 4096 tile ran
- /// 7.0 ms in int8, 8.3 ms with int8 weights, 10.1 ms in fp16 (`check-ane8`), but the velocity at 896² went from
- /// 7.6e-4 to 4.1e-2 (int8) and 1.1e-2 (int8 weights; one scale per 4 096 values where Q4_K has one per 32).
+ /// 7.0 ms in int8, 10.1 ms in fp16 (`check-ane8`), but the velocity at 896² went from 7.6e-4 to 4.1e-2 (one scale
+ /// per 4 096 values where Q4_K has one per 32). int8 weights with fp16 rows (8.3 ms, 1.1e-2) were removed in 0.1.1:
+ /// a whole generation came out black on every Mac, cause not found.
/// Finer scales do not close the gap (README, "Tried and not kept": 4.8e-3 with one per 32, and scales given as
/// program inputs run slower than fp16).
/// `bench` measures both on M3 and later. Falls back to fp16 when its programs cannot be built (macOS 26+).
private(set) var aneInt8: Bool
- /// With `aneInt8`, the rows stay fp16 (int8 weights only, W8A16: `KOKON_ANE_INT8=w8`).
- let aneHalfRows: Bool
static func int8Selected(_ chip: Chip) -> Bool {
switch ProcessInfo.processInfo.environment["KOKON_ANE_INT8"] {
- case "1", "w8": return true
+ case "1": return true
default: return false
}
}
- static var int8Rows: Bool { ProcessInfo.processInfo.environment["KOKON_ANE_INT8"] != "w8" }
/// **The release made visible at once**: a wait on `ready` right after its signal. On the M5 Pro (macOS 26.6) a
/// signal inside a command buffer reaches the CPU only at the command buffer's end or at the next wait it encodes
/// (a 3 × 20 ms test: the CPU saw the three signals at 60 / 60 / 60 ms, with a wait after each at 20 / 40 / 60).
@@ -188,7 +186,6 @@ final class Coexecutor {
self.aneEnabled = ane
self.amxEnabled = amx
aneInt8 = ane && Coexecutor.int8Selected(Chip.current)
- aneHalfRows = !Coexecutor.int8Rows
flushRelease = Coexecutor.flushReleaseSelected(context)
// The first evaluation's shares from the cost model on this chip's estimated rates (`Chip.unitScale`; on the
// M2 Pro its measured ones). Remembered shares replace them (`recall`).
@@ -220,12 +217,12 @@ final class Coexecutor {
guard rows > 0 else { return [[], []] }
let device = context.device
let first: [ProductSlot] = try (0..<3).map { _ in
- let p = try NeuralEngineProduct(rows: rows, k: Coexecutor.tile, n: Coexecutor.tile, int8: aneInt8, halfActivations: aneHalfRows)
+ let p = try NeuralEngineProduct(rows: rows, k: Coexecutor.tile, n: Coexecutor.tile, int8: aneInt8)
try p.run()
return (p, try p.gpuBuffer(p.x, device: device), try p.gpuBuffer(p.w, device: device), try p.gpuBuffer(p.y, device: device))
}
let second: [ProductSlot] = try first.map { f in
- let p = try NeuralEngineProduct(rows: rows, k: Coexecutor.tile, n: Coexecutor.tile, int8: aneInt8, halfActivations: aneHalfRows,
+ let p = try NeuralEngineProduct(rows: rows, k: Coexecutor.tile, n: Coexecutor.tile, int8: aneInt8,
sharing: f.product, sharingOutput: false)
try p.run()
return (p, f.x, try p.gpuBuffer(p.w, device: device), try p.gpuBuffer(p.y, device: device))
@@ -350,7 +347,7 @@ final class Coexecutor {
let bounds = shared && !aneInt8 ? readers.map { columnScales[$0]! } : [columns] // L: fp16 only
packedRows = shared ? (a.offset, readers) : nil
if aneInt8 {
- try kernel(aneHalfRows ? "ane8w_row_scales" : "ane8_row_scales") { e in
+ try kernel("ane8_row_scales") { e in
e.setBuffer(a.buffer, offset: a.offset, index: 0); e.setBuffer(scales, offset: sigma, index: 1)
e.setBytes(&sh, length: MemoryLayout<Shape>.stride, index: 2)
e.dispatchThreadgroups(MTLSize(width: s.ane, height: 1, depth: 1), threadsPerThreadgroup: MTLSize(width: 256, height: 1, depth: 1))
@@ -368,7 +365,7 @@ final class Coexecutor {
for np in 0..<nParts {
let slot = slots[kp * nParts + np]
var t = shape(kp: kp, np: np)
- try kernel(aneInt8 && !aneHalfRows ? "ane8_pack_rows" : "ane_pack_rows") { e in
+ try kernel(aneInt8 ? "ane8_pack_rows" : "ane_pack_rows") { e in
e.setBuffer(a.buffer, offset: a.offset, index: 0); e.setBuffer(scales, offset: sigma, index: 1)
e.setBuffer(slot.x, offset: 0, index: 2)
e.setBytes(&t, length: MemoryLayout<Shape>.stride, index: 3)
@@ -424,7 +421,7 @@ final class Coexecutor {
for np in 0..<nParts {
var t = shape(np: np)
let ys = (0..<3).map { kp in slots[min(kp, kParts - 1) * nParts + np].y }
- try kernel(aneInt8 ? aneHalfRows ? "ane8w_unpack" : "ane8_unpack" : "ane_unpack") { e in
+ try kernel(aneInt8 ? "ane8_unpack" : "ane_unpack") { e in
for (i, y) in ys.enumerated() { e.setBuffer(y, offset: 0, index: i) }
e.setBuffer(columns, offset: lambda, index: 3); e.setBuffer(scales, offset: sigma, index: 4)
e.setBuffer(c.buffer, offset: c.offset, index: 5)
diff --git a/engine-mac/Sources/KokonEngine/Kernels/ane.metal b/engine-mac/Sources/KokonEngine/Kernels/ane.metal
index 8535c80..d293043 100644
--- a/engine-mac/Sources/KokonEngine/Kernels/ane.metal
+++ b/engine-mac/Sources/KokonEngine/Kernels/ane.metal
@@ -252,37 +252,3 @@ kernel void ane8_unpack(device const half *y0 [[buffer(0)]], device const half *
uint j = s.n0 + jj;
c[(ulong)(s.row0 + i) * s.n + j] = sum * float(s.kPart) * rowScale[i] * columnScale[j];
}
-
-// int8 weights with fp16 rows (W8A16): the rows lifted by σ_i = 2^floor(log2(2^15 / (127 max_k |A_ik|))), since
-// |y| = |Σ_k x_k w_q,kj| / K <= max |x| · 127; then packed by `ane_pack_rows`; C_ij = K s_j Σ_tiles y_ij / σ_i.
-kernel void ane8w_row_scales(device const float *a [[buffer(0)]], device float *sigma [[buffer(1)]],
- constant AneShape &s [[buffer(2)]],
- uint i [[threadgroup_position_in_grid]], uint tid [[thread_index_in_threadgroup]]) {
- threadgroup float shared[8];
- device const float *row = a + (ulong)(s.row0 + i) * s.k;
- float m = 0;
- for (uint c = tid; c < s.k; c += 256) m = max(m, fabs(row[c]));
- m = simd_max(m);
- if (tid % 32 == 0) shared[tid / 32] = m;
- threadgroup_barrier(mem_flags::mem_threadgroup);
- if (tid == 0) {
- float peak = 0;
- for (uint q = 0; q < 8; q++) peak = max(peak, shared[q]);
- float bound = peak * 127.0f;
- sigma[i] = (bound > 0 && isfinite(bound)) ? exp2(floor(log2(32768.0f / bound))) : 1.0f;
- }
-}
-
-kernel void ane8w_unpack(device const half *y0 [[buffer(0)]], device const half *y1 [[buffer(1)]],
- device const half *y2 [[buffer(2)]], device const float *columnScale [[buffer(3)]],
- device const float *sigma [[buffer(4)]], device float *c [[buffer(5)]],
- constant AneShape &s [[buffer(6)]], uint2 g [[thread_position_in_grid]]) {
- uint jj = g.x, i = g.y;
- if (jj >= s.nPart || i >= s.rows) return;
- ulong at = (ulong)i * s.nPart + jj;
- float sum = float(y0[at]);
- if (s.kParts > 1) sum += float(y1[at]);
- if (s.kParts > 2) sum += float(y2[at]);
- uint j = s.n0 + jj;
- c[(ulong)(s.row0 + i) * s.n + j] = sum * float(s.kPart) * columnScale[j] / sigma[i];
-}
diff --git a/engine-mac/Sources/KokonEngine/NeuralEngine.swift b/engine-mac/Sources/KokonEngine/NeuralEngine.swift
index 57a2832..1356b4f 100644
--- a/engine-mac/Sources/KokonEngine/NeuralEngine.swift
+++ b/engine-mac/Sources/KokonEngine/NeuralEngine.swift
@@ -21,8 +21,8 @@ import Foundation
/// - rows in units of 256.
public final class NeuralEngineProduct: @unchecked Sendable {
public let rows: Int, k: Int, n: Int
- /// int8 `w` (`int8Program`), and int8 `x` too unless `halfActivations`; the output fp16.
- public let int8: Bool, halfActivations: Bool
+ /// int8 `x` and `w` (`int8Program`); the output fp16.
+ public let int8: Bool
private let model: MLModel
private let features: MLFeatureProvider
private let options: MLPredictionOptions
@@ -40,15 +40,14 @@ public final class NeuralEngineProduct: @unchecked Sendable {
}
/// `sharing`: a program of the same shape whose `x` surface (and `y`, with `sharingOutput`) this one uses too.
- public init(rows: Int, k: Int, n: Int, int8: Bool = false, halfActivations: Bool = false, sharing: NeuralEngineProduct? = nil,
+ public init(rows: Int, k: Int, n: Int, int8: Bool = false, sharing: NeuralEngineProduct? = nil,
sharingOutput: Bool = true) throws {
- self.rows = rows; self.k = k; self.n = n; self.int8 = int8; self.halfActivations = int8 && halfActivations
- let int8x = int8 && !halfActivations
+ self.rows = rows; self.k = k; self.n = n; self.int8 = int8
(model, directory) = try NeuralEngineProduct.compile(
- "\(rows)x\(k)x\(n)\(int8 ? int8x ? "-int8" : "-w8" : "")",
- program: int8 ? NeuralEngineProduct.int8Program(rows: rows, k: k, n: n, int8x: int8x) : NeuralEngineProduct.program(rows: rows, k: k, n: n),
- inputs: [("x", [rows, k]), ("w", [k, n])], outputs: [("y", [rows, n])], int8Inputs: int8 ? (int8x ? ["x", "w"] : ["w"]) : [])
- x = try sharing?.x ?? NeuralEngineProduct.surface(rows: rows, columns: k, int8: int8x)
+ "\(rows)x\(k)x\(n)\(int8 ? "-int8" : "")",
+ program: int8 ? NeuralEngineProduct.int8Program(rows: rows, k: k, n: n) : NeuralEngineProduct.program(rows: rows, k: k, n: n),
+ inputs: [("x", [rows, k]), ("w", [k, n])], outputs: [("y", [rows, n])], int8Inputs: int8 ? ["x", "w"] : [])
+ x = try sharing?.x ?? NeuralEngineProduct.surface(rows: rows, columns: k, int8: int8)
w = try NeuralEngineProduct.surface(rows: k, columns: n, int8: int8)
y = try (sharingOutput ? sharing?.y : nil) ?? NeuralEngineProduct.surface(rows: rows, columns: n)
func shape(_ dims: Int...) -> [NSNumber] { dims.map { NSNumber(value: $0) } }
@@ -114,12 +113,10 @@ public final class NeuralEngineProduct: @unchecked Sendable {
/// (`ane8_*` in `ane.metal`). The program's form follows libnnc's Core ML int8 GEMM (ccv, BSD-3, Liu Liu:
/// `ccv_nnc_mfa_ane_rowwise_coreml.mm`, which measured the K limit on an M4), in this engine's layout: x [rows, K]
/// and w [K, N] row-major, as the fp16 program, where libnnc multiplies W [N, K] by X [K, M].
- static func int8Program(rows: Int, k: Int, n: Int, int8x: Bool = true) -> String {
+ static func int8Program(rows: Int, k: Int, n: Int) -> String {
let pieces = k <= 2688 ? 1 : (k + 2047) / 2048
let part = k / pieces
- let xType = int8x ? "int8" : "fp16"
- // int8 x: both operands by 1/√K; fp16 x (W8A16): the weight alone by 1/K, x as the caller scaled it.
- let (dx, dw) = int8x ? (1 / Float(k).squareRoot(), 1 / Float(k).squareRoot()) : (1, 1 / Float(k))
+ let (dx, dw) = (1 / Float(k).squareRoot(), 1 / Float(k).squareRoot())
var body = """
fp16 dx = const()[name = string("dx"), val = fp16(\(String(format: "%a", dx)))];
fp16 dw = const()[name = string("dw"), val = fp16(\(String(format: "%a", dw)))];
@@ -127,18 +124,15 @@ public final class NeuralEngineProduct: @unchecked Sendable {
"""
func operands(_ x: String, _ w: String, _ suffix: String, _ xRows: Int, _ kk: Int) -> String {
- (int8x ? """
+ """
tensor<fp16, [\(xRows), \(kk)]> xh\(suffix) = dequantize(input = \(x), scale = dx)[name = string("xh\(suffix)")];
-
- """ : "") + """
tensor<fp16, [\(kk), \(n)]> wh\(suffix) = dequantize(input = \(w), scale = dw)[name = string("wh\(suffix)")];
"""
}
- func xh(_ x: String, _ suffix: String) -> String { int8x ? "xh\(suffix)" : x }
if pieces == 1 {
body += operands("x", "w", "", rows, k) + """
- tensor<fp16, [\(rows), \(n)]> y = matmul(transpose_x = f, transpose_y = f, x = \(xh("x", "")), y = wh)[name = string("y")];
+ tensor<fp16, [\(rows), \(n)]> y = matmul(transpose_x = f, transpose_y = f, x = xh, y = wh)[name = string("y")];
"""
} else {
@@ -151,11 +145,11 @@ public final class NeuralEngineProduct: @unchecked Sendable {
body += """
tensor<int32, [2]> xb\(i) = const()[name = string("xb\(i)"), val = tensor<int32, [2]>([0, \(i * part)])];
tensor<int32, [2]> wb\(i) = const()[name = string("wb\(i)"), val = tensor<int32, [2]>([\(i * part), 0])];
- tensor<\(xType), [\(rows), \(part)]> xq\(i) = slice_by_size(x = x, begin = xb\(i), size = xs)[name = string("xq\(i)")];
+ tensor<int8, [\(rows), \(part)]> xq\(i) = slice_by_size(x = x, begin = xb\(i), size = xs)[name = string("xq\(i)")];
tensor<int8, [\(part), \(n)]> wq\(i) = slice_by_size(x = w, begin = wb\(i), size = ws)[name = string("wq\(i)")];
""" + operands("xq\(i)", "wq\(i)", "\(i)", rows, part) + """
- tensor<fp16, [\(rows), \(n)]> m\(i) = matmul(transpose_x = f, transpose_y = f, x = \(xh("xq\(i)", "\(i)")), y = wh\(i))[name = string("m\(i)")];
+ tensor<fp16, [\(rows), \(n)]> m\(i) = matmul(transpose_x = f, transpose_y = f, x = xh\(i), y = wh\(i))[name = string("m\(i)")];
"""
}
@@ -173,7 +167,7 @@ public final class NeuralEngineProduct: @unchecked Sendable {
program(1.3)
[buildInfo = dict<string, string>({{"coremlc-component-MIL", "3600.16.1"}, {"coremlc-version", "3600.25.2"}})]
{
- func main<ios19>(tensor<int8, [\(k), \(n)]> w, tensor<\(xType), [\(rows), \(k)]> x) {
+ func main<ios19>(tensor<int8, [\(k), \(n)]> w, tensor<int8, [\(rows), \(k)]> x) {
\(body) } -> (y);
}
"""
diff --git a/engine-mac/chips.md b/engine-mac/chips.md
index 8088ab8..09e99df 100644
--- a/engine-mac/chips.md
+++ b/engine-mac/chips.md
@@ -26,4 +26,4 @@ Before working on a chip, look here and in [docs/mac-engine.md](docs/mac-engine.
With it, test set (3 alternated rounds, median): 1024² 49.0 → 39.6 s, 1344×768 48.3 → 39.9 s, edit 51.6 → 43.0 s.
- With the release fixed, `bench` still shows `KOKON_NA=0` (3.92 s per step) and `KOKON_ATTENTION_DIRECT=0` (3.86 s)
ahead of the default (4.08 s): one run each. Direct attention is off on every chip since 0.1.1.
-- `KOKON_ANE_INT8=w8` gives a NaN velocity and a black image here, as on every Mac (README, "int8 weights alone"); `=1` works (1.7 · 10⁻²).
+- `KOKON_ANE_INT8=1` works here (1.7 · 10⁻²).
diff --git a/engine-mac/docs/mac-engine.md b/engine-mac/docs/mac-engine.md
index 060fcf6..7f10b02 100644
--- a/engine-mac/docs/mac-engine.md
+++ b/engine-mac/docs/mac-engine.md
@@ -1276,7 +1276,7 @@ any Mac.**
|---|---|---|---|
| **GPU rows on Metal 4 tensor operations** (`na_matmul`, MetalPerformancePrimitives' `matmul2d`): on the M5 the GPU cores' matrix units, before it the shader cores | wherever Metal 4 runs | 6.3 vs MPS 5.6 TFLOP/s, bit for bit the same; an evaluation 7.57 → 7.48 s | `KOKON_NA=0` |
| **Attention reading K/V from memory** (`flash_attention_direct`) | off on every chip (since 0.1.1) | slower on every Mac measured (M2 Pro 142 ms vs 91; M3 Max, M4 Pro, M4 Max, M5 Pro: 8–18 % per step) | `KOKON_ATTENTION_DIRECT=1` |
-| **int8 products on the Neural Engine** (libnnc's M3/M4 path) | opt-in on every chip | a tile 10.1 → 7.0 ms, but 15–50× the error | `KOKON_ANE_INT8=1` or `w8` |
+| **int8 products on the Neural Engine** (libnnc's M3/M4 path) | opt-in on every chip | a tile 10.1 → 7.0 ms, but 15–50× the error | `KOKON_ANE_INT8=1` |
| **Each product released at once** (`Coexecutor.release`: a wait on `ready` right after its signal, so the CPU sees it before the GPU's own rows) | where signals arrive late, measured at every start (`signalArrivesLate`: M5 Pro on macOS 26.6, M2 Max on 26.2) | M5 Pro: an evaluation 5.50–5.89 → 4.44–4.46 s; where on time it costs ~2.5 % (M2 Pro, macOS 27.2) | `KOKON_FLUSH_READY=0/1` |
| **Starting shares** scaled by the chip's estimated units | always | — | `KOKON_BALANCE=0` keeps the defaults |
@@ -1451,7 +1451,7 @@ All are environment variables read once at start. Defaults are what users run.
| `KOKON_BALANCE` | on | `0`: keep the starting shares |
| `KOKON_HEADS` | balanced | `g,a,c`: fixed attention heads for GPU, Neural Engine, CPU (sum 32, a multiple of 4) |
| `KOKON_ANE_ATTENTION` | off | `1`: Neural Engine heads too |
-| `KOKON_ANE_INT8` | off | `1`: int8 weights and rows on the Neural Engine; `w8`: int8 weights only |
+| `KOKON_ANE_INT8` | off | `1`: int8 weights and rows on the Neural Engine |
| `KOKON_NA` | on with Metal 4 | `0`: MPS for the GPU's rows; `1`: force Metal 4 tensor ops |
| `KOKON_WEIGHTS` | fp16 | `fp32`: unpack weights to fp32 (checks) |
| `KOKON_ACTIVATIONS` | fp16 | `fp32`: fp32 inputs to the GPU's and AMX's products (checks) |