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 visualization support
pip install haoline[viz]

# With LLM summaries (requires Anthropic API key)
pip install haoline[llm]

# With all features
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.1.0.tar.gz (325.5 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.1.0-py3-none-any.whl (210.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: haoline-0.1.0.tar.gz
  • Upload date:
  • Size: 325.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for haoline-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d571e06541fc6564c960c6ec4473f2339bcf477cfb3f0b3fdb1a1dd97bb34630
MD5 c776811df6af4c84518ceba6503fb9dc
BLAKE2b-256 5dc61fd1f58d9cc531f291b4799fd9523780c3bc3a169ab296e1bad808dba8ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: haoline-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 210.3 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 99bea01858e12746bc59b2ac618f5f44fb7638c1e59be5f7880771194c0da705
MD5 bf38dbe831b4de9a9060813249ff82a2
BLAKE2b-256 1edda29baf61f4f62ea7f043df4b8d3849333a991ca813265cb84a18cfb061a6

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