Skip to main content

PyTorch transformers meets fx graph manipulation

Project description

torch-scalpel 🔬

Surgical modifications to PyTorch transformer architectures via FX graph manipulation

Vision

Traditional research codebases struggle with abstraction design. Predicting where innovation will emerge is impossible, making future-proof APIs elusive. Instead of building rigid abstractions around transformer components, torch-scalpel aims to treat the FX intermediate representation from torch.compile as the primary interface for architectural modifications.

We aim to enable surgical precision in transformer research by operating directly on computation graphs as middleware in the torch.compile pipeline. The goal is to swap normalization strategies, evolve attention mechanisms (custom implementations → optimized SDPA), experiment with activation functions... all through targeted graph-level transformations that preserve semantic structure while enabling systematic architectural evolution.

Status

🚧 Early Development - Experimental, viability study phase

Notebooks

Research notebooks exploring core concepts and validating technical feasibility before designing the library API:

  • compiled_fx_manipulations.ipynb - FX graph exploration, pattern matching, and surgical transformations
  • replace_attention_in_fx.ipynb - Transformer attention mechanism replacement (custom → optimized SDPA)

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

torch_scalpel-0.1.0.dev0.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

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

torch_scalpel-0.1.0.dev0-py3-none-any.whl (2.0 kB view details)

Uploaded Python 3

File details

Details for the file torch_scalpel-0.1.0.dev0.tar.gz.

File metadata

  • Download URL: torch_scalpel-0.1.0.dev0.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.9

File hashes

Hashes for torch_scalpel-0.1.0.dev0.tar.gz
Algorithm Hash digest
SHA256 db28bd5ea0d28c096179f68fe4403ad1c9d95b4e70b5e43af85a0f97d039a611
MD5 f778ad53e87830a9bc387fe21ed515d0
BLAKE2b-256 21918574a40c905175eb62e44f87249381eb0f5370891502d761a6a7999c115b

See more details on using hashes here.

File details

Details for the file torch_scalpel-0.1.0.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for torch_scalpel-0.1.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a3808aeebd25396798707f5c48a95936c760999f4f0f7ac54cbd7e2033223b8
MD5 0b97a8e6662746cae70c7c0a45f3beb0
BLAKE2b-256 a069c6eb6f88294b3af610e8210783fb4e80a29afe9a744410096105de632599

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