NGramHasher.lookup uses Python loops over B×T — massive bottleneck #8
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
NGramHasher.lookup()(engram.py:82-97) uses nested Python loops over batch, sequence, orders, and heads:For batch=4, seq=2048, 2 orders, 8 heads → 131,072 Python loop iterations per call. This runs on CPU (
.cpu().numpy()) and will dominate training time.Impact
Every training step calls this for every Engram layer. At seq=2048, this will be the bottleneck, potentially making training 10-100× slower than necessary.
Action needed
Files
tergent/engram.py:82-97