Repository navigation
[1/12] Replace legacy DLA helpers with an IR foundation - #3181
mgohil-png wants to merge 3 commits into
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
@coderabbitai full review |
Action performed
|
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3181 +/- ##
==========================================
- Coverage 82.11% 81.58% -0.54%
==========================================
Files 727 734 +7
Lines 82173 82138 -35
==========================================
- Hits 67480 67012 -468
- Misses 14693 15126 +433
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Closed all the old PRs since we have moved to new method of applying tranformations |
|
AI Agent Comments:
|
Signed-off-by: mgohil <[email protected]>
Signed-off-by: mgohil <[email protected]>
Signed-off-by: mgohil <[email protected]>
26f90ef to
983cee0
Compare
|
Addressed points 2 and 3 from your review. PR #3181 now accepts standard opsets 17 through 21 and includes direct tests for input version validation and Q/DQ schema upgrades. The pipeline validates at entry before the optional FP16 upgrade. PR #3192 also exercises models authored directly at opset 19. On the rebased stack, all 33 graph-surgery tests passed for this PR and all 227 passed at the stack tip. |
| for existing in bucket: | ||
| if all( | ||
| left == right | ||
| for left, right in zip_longest( |
There was a problem hiding this comment.
A large transposed weight and its contiguous copy can have identical bytes, but NumPy can split those bytes into different-sized chunks. Comparing chunks in pairs keeps both weights in the model. Could you compare the bytes across chunk boundaries and add a test that checks only one copy remains?
There was a problem hiding this comment.
The pairwise comparison would miss a duplicate if the byte streams were split at different offsets. In this path, _tensor_chunks() uses buffered np.nditer in logical C order, so the transposed view and its contiguous copy produced the same chunk boundaries.
What does this PR do?
Type of change: new feature
Adds the internal graph context, typed initializer helpers, input/opset validation and cleanup primitives used by the DLA transforms. Cleanup preserves public names and merges immutable initializers by exact dtype, shape and contents with bounded-memory hashing and collision checks.
Removes the legacy DLA helpers from
graph_surgery/utils/graph_utils.pyand their corresponding DLA-specific tests. The IR model already records graph connectivity, and the SDK owns node replacement, cleanup and ordering:GraphCache,get_constant_by_name,get_node_attr_iandset_node_attr_igive way to IR initializer/value access,producer()/uses()links and node attributes.batch_replace_nodesandinsert_nodes_at_positionare replaced by SDK pattern rewriting and IR node APIs, withRemoveUnusedNodesPassandTopologicalSortPassfor cleanup and ordering.add_unique_initializersis replaced by the context's shared initializer naming helper and final exact-content deduplication.resolve_reshape_shape,pad4d,axes_for_rank,check_to_apply_transpose,is_const_dq_input,calculate_clip_rangeandparse_qdq_quantized_dtype_listmove to the owning IR layout, operator or preprocessing checks introduced by this series.graph_utils.infer_shapeswrapper is retired; the final entry point uses upstream inference and ONNX checking.This retires the obsolete DLA machinery from PR #2831 without reverting that PR's shared initializer/dtype fixes. The IR replaces duplicate graph state and manual DLA graph editing. The shared
graph_utils.pymodule and helpers still used by GQA replacement and encoder cross-KV surgery remain. These removals are separate from the helpers inmodelopt.onnx.utils.Usage
Internal foundation for later slices; the public DLA operation arrives in PR 12. Rules receive one per-run
DlaGraphand create constants through its shared initializer helper.The removed names are exported helper APIs introduced in the current unreleased cycle. Callers using those APIs from
mainmust migrate to the IR-backed DLA workflow delivered by this stack. Existing non-DLA graph-surgery entry points retain their helpers and contracts.Testing
CI readiness check (2026-11-05): latest unit tests, code quality, and documentation workflows passed for this head.
Focus: Cleanup, shared/public initializer ownership, exact payload distinctions and hash-collision handling. The existing storage test gains seven cases covering packed INT4/UINT4, odd padding, chunk boundaries, mixed representations and collisions. Remove tests for retired DLA helpers while retaining coverage for the shared utilities that remain.
Slice validation: 21 tests passed on this slice using
python -m pytest tests/unit/onnx/graph_surgery/dla_transforms tests/unit/onnx/graph_surgery/test_graph_utils.py -o addopts= -q -p no:cacheprovider --strict-markers.Minimum-version compatibility: all 13 cleanup tests passed with
onnx_ir==0.1.16.Packed-tensor memory probe (16 MiB packed payload, traced peak temporary memory): 100,800,067 bytes before versus 628,813 bytes after; elapsed time 0.118 s versus 0.245 s. Hashing and collision comparisons use bounded chunks and ignore padding bits.
Repository checks: Ruff, formatting, license, security, whitespace and applicable repository hooks passed. Mypy reports the preexisting Windows
os.sched_getaffinityerror; it was excluded from commit hooks after confirming the same unrelated error.Added source lines against this PR's base: 522 added Python source lines; tests and documentation excluded.
Before your PR is "Ready for review"
Follow the Contributor guidelines and Security Coding Practices. Commits are signed and signed off.
CONTRIBUTING.md?: N/A - uses existing dependencies; no external source copied.Additional Information
Base:
main. Merge this PR first.Merge order is 1 through 12. Review against the immediate base so earlier slices are excluded from this diff. Series: 1/12, 2/12, 3/12, 4/12, 5/12, 6/12, 7/12, 8/12, 9/12, 10/12, 11/12, 12/12
Layout lifecycle methods arrive with the layout passes in PR 2. The Q/DQ opset-upgrade helper is defined here and activated by the final entry point.
Summary by CodeRabbit