Polygraphy rebuild drops model opset_imports, functions, and metadata

Đang mở Phù hợp với người mới
#4,948 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 6 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
77/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
machine-learning

Hướng nghiên cứu

Đọc tools/Polygraphy/polygraphy/tools/sparse.py quanh build_new_model (dòng 374–410), được gọi thông qua polygraphy surgeon prune, và kiểm tra cách tạo ModelProto mới. Giữ lại các phần nhập opset, hàm và trường siêu dữ liệu được liệt kê của mô hình nguồn. Hoàn thành khi việc cắt tỉa mô hình có toán tử thuộc miền tùy chỉnh hoặc hàm cục bộ vẫn giữ lại các trường đó và vượt qua onnx.checker.check_model(full_check=True).

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Module:Polygraphy

Bug Description

In tools/Polygraphy/polygraphy/tools/sparse.py:374-410 (build_new_model called via polygraphy surgeon prune), when sparsity pruning replaces at least one eligible weight tensor, the pruned output ModelProto is rebuilt from scratch:

attrs = {
    "ir_version": m.ir_version,
    "producer_name": "polygraphy surgeon prune",
    "opset_imports": [m.opset_import[0]],
}

This rebuild drops critical model-level metadata and attributes:

  1. All opset_import entries past index 0 (e.g. custom domain imports or default domain imports if a custom domain was listed first).
  2. Model-local function definitions (ModelProto.functions).
  3. Model metadata: producer_version, domain, model_version, doc_string, metadata_props.

If the pruned model utilizes custom domain operators or model-local functions, the resulting ONNX model fails onnx.checker.check_model(full_check=True) with:

ValidationError: No opset import for domain '<domain>'
Proposed Solution

Preserve all opset_import entries, functions, and model metadata on the reconstructed ModelProto in sparse.py:

--- a/tools/Polygraphy/polygraphy/tools/sparse.py
+++ b/tools/Polygraphy/polygraphy/tools/sparse.py
@@ -402,3 +402,3 @@ def build_new_model(m, tensors):
         "ir_version": m.ir_version,
         "producer_name": "polygraphy surgeon prune",
-        "opset_imports": [m.opset_import[0]],
+        "opset_imports": list(m.opset_import),
     }

And copy functions, metadata_props, doc_string, and domain from the source model m onto the output model.

Ngôn ngữ chính
C++
Star
13.5k
Fork
2.4k
Merge trung bình
6 ngày 21 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NVIDIA/TensorRT

Tất cả issue của NVIDIA/TensorRT

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.