How gat45/htp-npu-runtime works
This repository is a reproducible Android inference benchmarking and tuning workspace for Qualcomm HTP/NPU and Adreno GPU, with an APK profiler and a separate Python governor. The main user workflow is to configure benchmark campaigns, execute guarded device scripts, collect throughput and hardware/thermal evidence, then compare placements, MTP, and layer profiles. The governor adds a observe-to-execute tuning loop backed by cost, causal, and provenance memories. The graph reflects README capabilities and the supplied source index; unsampled device scripts and runtime wiring are not expanded into guessed call paths.
Main entry points: ExperimentController.kt Campaign controller · engine.py Governor loop · PerLayerProfiler.kt Layer campaigns · HardwareProfiler.kt Hardware profiling
Components 22
Android profiling
- Campaign controller
apk_profiler/ExperimentController.kt - Layer campaigns
apk_profiler/PerLayerProfiler.kt - Execution providers
apk_profiler/ExecutionProvider.kt
Device execution
- Root command runner
apk_profiler/RootShell.kt - Script integrity
apk_profiler/ScriptGuard.kt - Thermal and placement experiments
device
Adaptive governor
- Governor loop
governor/engine.py - Project adapter
governor/adapter.py - OnePlus adapter
governor/op15.py - Action policy
governor/policy.py - Performance cost model
governor/cost_model.py - Causal memory
governor/causal.py - Provenance memory
governor/provenance.py
Measurement and memory
- Common collector
apk_profiler/CommonCollector.kt - Hardware profiling
apk_profiler/HardwareProfiler.kt - Log parsing
apk_profiler/LogParser.kt - GGUF inspection
apk_profiler/GgufReader.kt - Roofline prediction
apk_profiler/RooflinePredictor.kt - Layer format profiler
governor/profiler.py - Benchmark fact indexing
governor/index_facts.py
Other components
- Engineer
- Android device
Connections 30
- Engineer → Campaign controller: configures
README.md - Campaign controller → Execution providers: selects provider
apk_profiler/ExperimentController.kt - Campaign controller → Root command runner: executes scripts
apk_profiler/RootShell.kt - Campaign controller → Common collector: collects metrics
apk_profiler/ExperimentController.kt - Campaign controller → Hardware profiling: profiles device
apk_profiler/ExperimentController.kt - Campaign controller → Log parsing: parses output
apk_profiler/ExperimentController.kt - Campaign controller → Script integrity: verifies scripts
apk_profiler/ExperimentController.kt - Layer campaigns → Campaign controller: delegates campaigns
apk_profiler/PerLayerProfiler.kt - Layer campaigns → Hardware profiling: uses profiling
apk_profiler/PerLayerProfiler.kt - Layer campaigns → Script integrity: guards scripts
apk_profiler/PerLayerProfiler.kt - Layer campaigns → Log parsing: parses results
apk_profiler/PerLayerProfiler.kt - Root command runner → Android device: runs root commands
apk_profiler/RootShell.kt - Script integrity → Root command runner: checks hashes
apk_profiler/ScriptGuard.kt - Common collector → Root command runner: reads device data
apk_profiler/CommonCollector.kt - Hardware profiling → Root command runner: reads profiling logs
apk_profiler/HardwareProfiler.kt - Hardware profiling → Log parsing: parses profiler output
apk_profiler/HardwareProfiler.kt - Hardware profiling → GGUF inspection: uses model metadata
apk_profiler/HardwareProfiler.kt - Engineer → Governor loop: starts tuning
README.md - Governor loop → Project adapter: requests actions
governor/engine.py - Governor loop → Action policy: ranks actions
governor/engine.py - Governor loop → Performance cost model: updates estimates
governor/engine.py - Governor loop → Causal memory: uses causal memory
governor/engine.py - Governor loop → Provenance memory: uses provenance
governor/engine.py - Project adapter → OnePlus adapter: specializes device
governor/op15.py - OnePlus adapter → Layer format profiler: profiles layers
governor/op15.py - Benchmark fact indexing → Provenance memory: stores facts
governor/index_facts.py - Benchmark fact indexing → Causal memory: records relations
governor/index_facts.py - Engineer → Thermal and placement experiments: runs experiments
README.md - Thermal and placement experiments → Android device: measures placement and heat
README.md - Engineer → Layer campaigns: requests layer analysis
README.md