SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2407.05858 · 2024

Fast On-device LLM Inference with NPUs

arXiv · PDF · Open in the Atlas

Code that ran

7 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 7 failures of our instrument; 1 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2407.05858.json · badge: /api/ran/2407.05858.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
ubiquitouslearning/mllm canonical (classifier label)
classifier basis: census
7 ran · 1 no recorded run
FunctionStatusWhere it lives
bench Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ubiquitouslearning/mllm/mllm-kernel/benchmarks/bench_w4a16_vs_w8a8.py
code served (permissive licence) · get_code("a28ecbe6e5033c8a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import time
from typing import Callable
import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a simple callable that performs a basic operation
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

model = SimpleModel()
input_tensor = torch.randn(2, 4)

def dummy_fn():
    """A simple callable that performs a computation."""
    with torch.no_grad():
        _ = model(input_tensor)

ARGS = {
    "fn": dummy_fn,
    "warmup": 5,
    "repeat": 20
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
bench_fn Ran
ran; our contract draft was wrong, not the code
ubiquitouslearning/mllm/mllm-kernel/benchmarks/bench_int8_scaled_mm.py
code served (permissive licence) · get_code("7357a837ed37641c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import time
from typing import Callable, Optional

torch.manual_seed(0)

# Create a simple function to benchmark
def sample_fn(x, y):
    return x + y

# Create small test tensors (batch=2, dim=4)
x = torch.randn(2, 4)
y = torch.randn(2, 4)

# Define all arguments for bench_fn
ARGS = {
    'fn': sample_fn,
    'args': (x, y),
    'kwargs': {},
    'warmup': 2,
    'repeat': 3
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
cache_once Ran
ran; our contract draft was wrong, not the code
ubiquitouslearning/mllm/mllm-kernel/mllm_kernel/jit_utils/compile.py
code served (permissive licence) · get_code("3561fac4ee82308f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import functools
from typing import Callable, TypeVar, Any

F = TypeVar('F', bound=Callable[..., Any])

def cache_once(fn: F) -> F:
    """
    NOTE: `functools.lru_cache` is not compatible with `torch.compile`
    So we manually implement a simple cache_once decorator to replace it.
    """
    result_map = {}

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        key = (args, tuple(sorted(kwargs.items(), key=lambda x: x[0])))
        if key not in result_map:
            result_map[key] = fn(*args, **kwargs)
        return result_map[key]
    return wrapper


torch.manual_seed(0)

def sample_function(x: int, y: str = "default") -> str:
    """A simple function to be decorated."""
    return f"{x}_{y}"

ARGS = {
    "fn": sample_function
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
define_ir Ran
ran; our contract draft was wrong, not the code
ubiquitouslearning/mllm/mllm/compile/ir/rtti_kind_gen.py
code served (permissive licence) · get_code("bbbbfb5c0137cbc7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from typing import List

class Cls:
    def __init__(self, name: str):
        self.name: str = name
        self.childs: List = []
        self.enum_name: str = name
        self.classof_s = None
        self.classof_e = None

    def derive(self, cls):
        self.childs.append(cls)
        return cls

def define_ir(name: str, op: Cls, val: Cls, attr: Cls):
    ret = {'Op': Cls(f'{name}Op'), 'Value': Cls(f'{name}Val'), 'Attribute': Cls(f'{name}Attr')}
    op.derive(ret['Op'])
    val.derive(ret['Value'])
    attr.derive(ret['Attribute'])
    return ret

# Create the base Cls instances that will be parents
op_base = Cls('Op')
val_base = Cls('Value')
attr_base = Cls('Attribute')

ARGS = {
    'name': 'TestIR',
    'op': op_base,
    'val': val_base,
    'attr': attr_base
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
dump_cls_to_kinds Ran
ran; our contract draft was wrong, not the code
ubiquitouslearning/mllm/mllm/compile/ir/rtti_kind_gen.py
code served (permissive licence) · get_code("bcfe58bee8070d9b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from typing import List

class Cls:
    def __init__(self, name: str):
        self.name: str = name
        self.childs: List = []
        self.enum_name: str = name
        self.classof_s = None
        self.classof_e = None

    def derive(self, cls):
        self.childs.append(cls)
        return cls

# Build a test class hierarchy
root_cls = Cls("Expression")

# Create some child classes
int_expr = Cls("IntExpr")
bin_op = Cls("BinOp")
add_op = Cls("AddOp")
sub_op = Cls("SubOp")

# Build the hierarchy
root_cls.derive(int_expr)
root_cls.derive(bin_op)
bin_op.derive(add_op)
bin_op.derive(sub_op)

ARGS = {
    "cls": root_cls,
    "ignore_top_level": True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
filter_files Ran
ran; our contract draft was wrong, not the code
ubiquitouslearning/mllm/task.py
code served (permissive licence) · get_code("0f9d587155d9c348")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import re
import tempfile
import shutil

# Create a temporary directory structure for testing
temp_dir = tempfile.mkdtemp()

# Create some test files
os.makedirs(os.path.join(temp_dir, "subdir1"), exist_ok=True)
os.makedirs(os.path.join(temp_dir, "subdir2"), exist_ok=True)
os.makedirs(os.path.join(temp_dir, "ignore_me"), exist_ok=True)

# Create test files with various names
open(os.path.join(temp_dir, "test.txt"), 'w').close()
open(os.path.join(temp_dir, "test.py"), 'w').close()
open(os.path.join(temp_dir, "data.csv"), 'w').close()
open(os.path.join(temp_dir, "subdir1", "file1.txt"), 'w').close()
open(os.path.join(temp_dir, "subdir1", "file2.py"), 'w').close()
open(os.path.join(temp_dir, "subdir2", "readme.md"), 'w').close()
open(os.path.join(temp_dir, "ignore_me", "secret.txt"), 'w').close()

ARGS = {
    "directory": temp_dir,
    "patterns": ["*.txt", "*.py"],
    "ignore_dirs": ["ignore_me"],
    "r": True,
    "case_sensitive": True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
wildcard_to_regex Ran
ran; our contract draft was wrong, not the code
ubiquitouslearning/mllm/task.py
code served (permissive licence) · get_code("09b13e2db7924d88")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def wildcard_to_regex(pattern):
    escaped = re.escape(pattern)
    processed = escaped.replace('\\*', '.*').replace('\\?', '.')
    return f'^{processed}$'

ARGS = {
    'pattern': '*.txt'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
prepare_marlin_weights Not yet run
unverified (harvested, no recorded run)
ubiquitouslearning/mllm/mllm-kernel/benchmarks/bench_w4a16_vs_w8a8.py
code served (permissive licence) · get_code("2e0d11defc022118")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 8 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

On-device inference for Large Language Models (LLMs), driven by increasing privacy concerns and advancements of mobile-sized models, has gained significant interest. However, even mobile-sized LLMs (e.g., Gemma-2B) encounter unacceptably high inference latency, often bottlenecked by the prefill stage in tasks like screen UI understanding. We present llm.npu, the first LLM inference system utilizing on-device Neural Processing Unit (NPU) offloading to reduce prefill latency. llm.npu enhances NPU offloading efficiency by re-constructing the prompt and model in three levels: (1) At prompt level, it divides variable-length prompts into multiple fixed-sized chunks while maintaining data dependencies; (2) At tensor level, it identifies and extracts significant outliers to run on the CPU/GPU in parallel with minimal overhead; (3) At block level, it schedules Transformer blocks in an out-of-order manner to the CPU/GPU and NPU based on their hardware affinity and sensitivity to accuracy. Compared to competitive baselines, llm.npu achieves 22.4x faster prefill speed and 30.7$\times$ energy savings on average, and up to 32.8x speedup in an end-to-end real-world application. For the first time, llm.npu achieves more than 1,000 tokens/sec prefilling for a billion-sized model.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2407.05858")
get_code_for_paper("2407.05858")
have("2407.05858")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2407.05858.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2407.05858.svg)](https://syntology.ai/paper/2407.05858)

Connect an agent — have() is free.