Repository navigation
Import pt2 - #1693
Open
syamajala wants to merge 2 commits into
Open
Import pt2#1693syamajala wants to merge 2 commits into
syamajala wants to merge 2 commits into
Conversation
New bin/import-pt2 tool that reads a .pt2 archive written by torch.export.save() and rebuilds its graph with ComputationGraphBuilder, then outputs V1 JSON (default) or DOT (--dot). - pt2_archive: minimal zip reader (zip64 aware) for the stored, uncompressed entries PyTorch writes; finds models/model.json under any top-level directory. No libtorch dependency. - pt2_to_computation_graph: translates ATen nodes to builder calls. Parameters and buffers are implied by their owning op (conv2d weight -> out_channels/kernel, bias -> use_bias, etc.); weight values are not imported. After every op, FlexFlow's inferred shape is checked against the shape recorded in the .pt2. - Supported ops: conv2d, batch_norm, linear, silu/relu/gelu/sigmoid/tanh/ exp/rsqrt, add/sub/mul/div (tensor and scalar), cat, chunk/split, view/reshape/flatten/(un)squeeze, transpose/permute, max_pool2d, adaptive_avg_pool2d, upsample_nearest2d, matmul/bmm, softmax, plus pass-through of detach/clone/dropout(eval)/no-op casts. Unsupported ops, dynamic shapes and unsupported arguments fail with an error naming the node. Tested on ultralytics YOLOv10x (batch 8, end2end=false): the imported graph is structurally identical to export-model-arch yolov10x (576 non-weight layers, 513 weights, same attrs, shapes, wiring and outputs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Import pytorch pt2 files into flexflow. Walks the model.json and calls ComputationGraphBuilder. Verified with yolov10. Dumped flexflow's yolov10 to json and compared with the pytorch implementation. Import yolov10 pt2 file, dumped to json compared with pt2 and flexflow's yolov10 json. All match.
This change is