Skip to main content

torch-code-tracing

PyPI - Version PyPI - Downloads

Code trace your PyTorch model to understand its exexution and intermediate tensor shapes.

Install

pip install git+https://github.com/justinchuby/torch-code-tracing.git

Usage

from torch_code_tracing import TracingMode

with TracingMode(succinct=True, color=True):
    out = model(*args, **kwargs)
out = model(**example_kwargs)  # test.py:41 in <module>:
 ⬇️
 output = func(self, *args, **kwargs)  # site-packages/transformers/utils/generic.py:969 in wrapper:
  ⬇️
  inputs_embeds = self.get_input_embeddings()(llm_input_ids)  # site-packages/transformers/models/gemma3/modeling_gemma3.py:1175 in forward:
   ⬇️
   return super().forward(input_ids) * self.embed_scale.to(self.weight.dtype)  # site-packages/transformers/models/gemma3/modeling_gemma3.py:144 in forward:
    # embedding(bf16[262208, 2560], i64[2, 3], 0) -> bf16[2, 3, 2560];
   return super().forward(input_ids) * self.embed_scale.to(self.weight.dtype)  # site-packages/transformers/models/gemma3/modeling_gemma3.py:144 in forward:
    # mul.Tensor(bf16[2, 3, 2560], bf16[]) -> bf16[2, 3, 2560];
  cache_position = torch.arange(  # site-packages/transformers/models/gemma3/modeling_gemma3.py:1179 in forward:
   # arange.start(30, 33, device=meta, pin_memory=False) -> i64[3];
  causal_mask = self._update_causal_mask(  # site-packages/transformers/models/gemma3/modeling_gemma3.py:1205 in forward:
   ⬇️
   causal_mask = torch.full(  # site-packages/transformers/models/gemma3/modeling_gemma3.py:1050 in _update_causal_mask:
    # full([3, 33], -3.3895313892515355e+38, dtype=torch.bfloat16, device=meta, pin_memory=False) -> bf16[3, 33];
   causal_mask = torch.triu(causal_mask, diagonal=1)  # site-packages/transformers/models/gemma3/modeling_gemma3.py:1056 in _update_causal_mask:
    # triu(bf16[3, 33], 1) -> bf16[3, 33];
...

Download files

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

Source Distribution

torch_code_tracing-0.1.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

torch_code_tracing-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file torch_code_tracing-0.1.1.tar.gz.

File metadata

  • Download URL: torch_code_tracing-0.1.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for torch_code_tracing-0.1.1.tar.gz
Algorithm Hash digest
SHA256 78e43c65e923ea916e6c75c21bff84902eca85aee9977155e77a39560118de2b
MD5 b902dbade54b65cd22a0f1642199622f
BLAKE2b-256 4524d8e273ab4daffa9ce8d6c10b49ea2793c495eea99f1661902f037ce8e4bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_code_tracing-0.1.1.tar.gz:

Publisher: main.yml on justinchuby/torch-code-tracing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file torch_code_tracing-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for torch_code_tracing-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 703066ba639e6f463af9e5da9bc9f6a019d1709a076b27e51b670a1b7c2f380b
MD5 c183987c14cad538e11cc846ed4427f9
BLAKE2b-256 74d1a6e59a6e760d867dbc6266a5d0a41a14d16eccca1382db4507f608d0df82

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_code_tracing-0.1.1-py3-none-any.whl:

Publisher: main.yml on justinchuby/torch-code-tracing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Supported by

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