Skip to main content

Per-layer latency and memory profiler for transformer inference.

Project description

glasstrace

CI

Per-layer latency and memory profiler for transformer inference.

glasstrace shows you where time actually goes inside your LLM. Decomposes inference cost by layer, operation, and inference phase (prefill vs decode).

Why

When you call model.generate(), you get a number: total latency. That's not enough to make anything faster. glasstrace turns the black box into a measured picture: which layers are slow, where memory pressure lives, and what changes when you tweak batch size or sequence length.

Install

pip install git+https://github.com/manu-j3400/glasstrace.git

PyPI release coming with v1.0.

Usage

import glasstrace
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B")
inputs = tokenizer("Hello, world!", return_tensors="pt")

with glasstrace.profile(model) as p:
    out = model.generate(**inputs, max_new_tokens=50)

print(p.report())

Status

v0.1.0 — alpha. Works on Qwen 2.5 0.5B and Llama 3.2 1B with CUDA. Tracks nn.Linear and nn.LayerNorm modules. Memory tracking, HTML reports, and broader model coverage planned for v0.2.

Roadmap

  • v0.1 — Per-module CUDA timing, text-table report
  • v0.2 — Prefill vs decode split, memory tracking, HTML report
  • v0.3 — Multi-model tested coverage, CLI
  • v0.4 — Comparative analyses across Llama, Qwen, Phi (blog post)
  • v1.0 — PyPI release, docs, demo video

License

MIT

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

glasstrace-0.2.0.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

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

glasstrace-0.2.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file glasstrace-0.2.0.tar.gz.

File metadata

  • Download URL: glasstrace-0.2.0.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for glasstrace-0.2.0.tar.gz
Algorithm Hash digest
SHA256 32551d5a14515e04aaaac7f2582aace94c4d2177de79078e7c957ff6e842fffe
MD5 cff97c8fd7cc03ab23f7fc292b8ab9f1
BLAKE2b-256 7d090f08cc0df37a5b9b21896ca84ff05cde8a20fc389a44964d038429660005

See more details on using hashes here.

File details

Details for the file glasstrace-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: glasstrace-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for glasstrace-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76922241f44c6d7f659df4aa257db3952a9b07a8c13143c23ee1249644ae6014
MD5 313326f46588902c6653740fac969c96
BLAKE2b-256 387482763ba044706cf211e1f8c0a5a5c1c26f950ecb67342a5b6a889623a373

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