Skip to main content

HaoLine (好线) - Universal Model Inspector. See what's really inside your models.

Project description

HaoLine (好线)

Universal Model Inspector — See what's really inside your models.

PyPI version Python 3.10+ License: MIT

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

haoline-0.2.1.tar.gz (325.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

haoline-0.2.1-py3-none-any.whl (210.6 kB view details)

Uploaded Python 3

File details

Details for the file haoline-0.2.1.tar.gz.

File metadata

  • Download URL: haoline-0.2.1.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

Hashes for haoline-0.2.1.tar.gz
Algorithm Hash digest
SHA256 936dc1560ad7f5e29a603b84b8ab540a002d336424dd70372a1e7bb4562e1aaf
MD5 fb21c203871a8e04d30d5bda460a5a7b
BLAKE2b-256 b88a5fea2d73959a3ad90c87628d2ace193c82a7c82bcdb850ea8ef2dabceb47

See more details on using hashes here.

File details

Details for the file haoline-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: haoline-0.2.1-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

Hashes for haoline-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 48510ee96450eb74f9384c44e7b4796dfa9b266788da920d820d3027b1de4727
MD5 0288c31d308f2efe49303f3346185fc4
BLAKE2b-256 2cc7f75a19e797f83c9e72c6974fbb1e4405b72c3cf1038397f22351fbc8a16c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page