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 transformationsreplace_attention_in_fx.ipynb- Transformer attention mechanism replacement (custom → optimized SDPA)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db28bd5ea0d28c096179f68fe4403ad1c9d95b4e70b5e43af85a0f97d039a611
|
|
| MD5 |
f778ad53e87830a9bc387fe21ed515d0
|
|
| BLAKE2b-256 |
21918574a40c905175eb62e44f87249381eb0f5370891502d761a6a7999c115b
|
File details
Details for the file torch_scalpel-0.1.0.dev0-py3-none-any.whl.
File metadata
- Download URL: torch_scalpel-0.1.0.dev0-py3-none-any.whl
- Upload date:
- Size: 2.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a3808aeebd25396798707f5c48a95936c760999f4f0f7ac54cbd7e2033223b8
|
|
| MD5 |
0b97a8e6662746cae70c7c0a45f3beb0
|
|
| BLAKE2b-256 |
a069c6eb6f88294b3af610e8210783fb4e80a29afe9a744410096105de632599
|