HaoLine (好线) - Universal Model Inspector. See what's really inside your models.
Project description
HaoLine (好线)
Universal Model Inspector — See what's really inside your models.
A graph-level analysis tool that inspects neural network architectures (ONNX, PyTorch, TensorFlow, TensorRT), computes static complexity metrics, surfaces structural risk signals, and auto-generates human-readable reports.
Installation
pip install haoline
# With LLM summaries (requires API key)
pip install haoline[llm]
# With all features (LLM, PDF export, GPU metrics)
pip install haoline[full]
Quick Start
Analyze a Model
# Basic analysis
haoline analyze model.onnx
# With hardware profile
haoline analyze model.onnx --hardware rtx4090
# Generate HTML report with charts
haoline analyze model.onnx --out-html report.html --with-plots
# Full analysis with AI summary
haoline analyze model.onnx --hardware auto --with-plots --llm-summary --out-html full_report.html
Compare Model Variants
# Compare FP32, FP16, INT8 quantizations
haoline compare \
--models resnet_fp32.onnx resnet_fp16.onnx resnet_int8.onnx \
--baseline-precision fp32 \
--out-html comparison.html --with-charts
Features
- Parameter counts - Per node, per block, and globally
- FLOP estimates - Identify compute hotspots
- Memory analysis - Peak activation memory and VRAM requirements
- Risk signals - Detect problematic architecture patterns
- Hardware estimates - GPU utilization predictions for 30+ NVIDIA profiles
- Runtime profiling - Actual inference benchmarks with ONNX Runtime
- Visualizations - Operator histograms, parameter/FLOPs distribution charts
- LLM Summaries - AI-generated executive summaries
- Interactive graphs - D3.js neural network visualizations
- Shareable Reports - HTML, Markdown, PDF, and JSON output formats
Supported Formats
| Format | Read | Write |
|---|---|---|
| ONNX | ✅ | - |
| PyTorch (.pt, .pth) | ✅ | - |
| TensorFlow SavedModel | ✅ | - |
| TensorRT Engine | 🔜 | - |
| SafeTensors | 🔜 | - |
Python API
from haoline import ModelInspector
inspector = ModelInspector()
report = inspector.inspect("model.onnx")
# Get metrics
print(f"Parameters: {report.params.total:,}")
print(f"FLOPs: {report.flops.total:,}")
print(f"Peak Memory: {report.memory.peak_activation_bytes / 1e9:.2f} GB")
# Export
report.to_json("report.json")
report.to_markdown("model_card.md")
report.to_html("report.html")
LLM Setup (Optional)
HaoLine can generate AI-powered summaries of your model architectures. Install with LLM support and set the API key for your preferred provider:
pip install haoline[llm]
| Provider | Environment Variable | Get API Key |
|---|---|---|
| OpenAI | OPENAI_API_KEY |
platform.openai.com |
| Anthropic | ANTHROPIC_API_KEY |
console.anthropic.com |
| Google Gemini | GOOGLE_API_KEY |
aistudio.google.com |
| xAI Grok | XAI_API_KEY |
console.x.ai |
# Set your preferred provider's API key
export OPENAI_API_KEY="sk-..." # OpenAI
export ANTHROPIC_API_KEY="sk-ant-..." # Anthropic
export GOOGLE_API_KEY="..." # Google Gemini
export XAI_API_KEY="xai-..." # xAI Grok
# Windows PowerShell
$env:OPENAI_API_KEY="sk-..."
# Use in analysis (auto-detects available provider)
haoline model.onnx --llm-summary
Security Notice
⚠️ Loading untrusted models is inherently risky.
Like PyTorch's torch.load(), HaoLine uses pickle and numpy.load(allow_pickle=True) when loading JAX model parameters. These can execute arbitrary code if the model file is malicious.
Best practices:
- Only analyze models from trusted sources
- Run in a sandboxed environment (Docker, VM) when analyzing unknown models
- Review model provenance before loading
License
MIT License - See LICENSE for details.
Etymology
HaoLine (好线) combines:
- 好 (hǎo) = "good" in Chinese
- A personal touch from the author
"The good path through your neural network."
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file haoline-0.2.0.tar.gz.
File metadata
- Download URL: haoline-0.2.0.tar.gz
- Upload date:
- Size: 325.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7869bf105aff9e3cb5d3295b7fe344fda4cecfa6866264b592d58427e5dce17
|
|
| MD5 |
0b7ad3f014cd7aea16130be09d7e2580
|
|
| BLAKE2b-256 |
02dc9c4c951e7496475dfe1295561d4de37f5b722005e9de78b01e486e26b447
|
File details
Details for the file haoline-0.2.0-py3-none-any.whl.
File metadata
- Download URL: haoline-0.2.0-py3-none-any.whl
- Upload date:
- Size: 210.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
826ca0b2c62d1383a0c8623a53ae060e2f02010bfb28a1d609b1d87ae6abf93d
|
|
| MD5 |
dbb611ad14a415c07812eaff9eddeb7a
|
|
| BLAKE2b-256 |
de534eb747688e2d20c7e2c74d8debb9da6e354166f124cfcf046434775535b4
|