feat(models): harden artifact loading and registry verification - #108
Conversation
Verify registry artifacts by SHA-256, restrict v2 deserialization and model-YAML imports, and preserve explicit trusted loading for legacy .jpt models. Add controlled import-policy overrides for direct local and Hugging Face custom models without weakening registry policy. Signed-off-by: Roman Zubatyuk <rzubatiuk@nvidia.com>
Signed-off-by: Roman Zubatyuk <rzubatiuk@nvidia.com>
Authorize role-specific imports at runtime, validate state dictionaries, and load model weights on CPU without truncating atomic shifts. Recover corrupt cache entries atomically and document the resulting breaking changes and migration steps. Signed-off-by: Roman Zubatyuk <rzubatiuk@nvidia.com>
|
Reviewed the full diff and verified the fleet directly: all 24 registry entries carry valid digests that match the published GCS bytes (and the bundled assets), every registry artifact loads end-to-end under the strict policy with Three compatibility regressions on documented non-registry paths need a decision before merge: 1. HF loader rejects repos that follow its own documented contract ( 2. Load-time metadata rejection removes the calculator's documented override escape ( 3. Also important:
|
|
Any thoughts on the three compatibility items from the review — the sr-coulomb extraction fallback ordering, the load-time metadata rejection vs the calculator's explicit-flag override, and export-side validation? Happy to discuss trade-offs on any of them; the rest of the findings are non-blocking. Would like to get this merged soon since it closes real gaps. |
…into feat/artifact-trust-boundary
Layer metadata validation by source and runtime while preserving strict registry policy. Reconcile HF metadata before weight access and share the source-aware v2 assembly path. Make export canonical and atomic, correct legacy embedded-LR metadata, and add scheduled registry fleet verification with regression coverage. Signed-off-by: Roman Zubatyuk <rzubatiuk@nvidia.com>
|
Thank you for the detailed review. I kept the source-specific security boundaries intact and addressed the three compatibility issues you identified. I also addressed the additional maintainability, CI, legacy-model, and release-policy concerns. 1. Hugging Face
|
Use tempfile.mkstemp for collision-safe sibling temporary files instead of a permissive creation mode. Cover permissive and restrictive umasks while preserving existing destination permissions. Signed-off-by: Roman Zubatyuk <rzubatiuk@nvidia.com>
isayev
left a comment
There was a problem hiding this comment.
All three compatibility regressions from the review are addressed the right way — YAML-derived SRCoulomb metadata before structural validation, the four-level validation split restoring the explicit-flag escape for direct artifacts while keeping registry/export fail-closed, and export-time validation with atomic replacement. The registry-fleet weekly workflow and the consolidated routing predicates close the two structural concerns as well. CI green across the matrix.
AIMNetCentral Pull Request
Description
Secure model loading across official registry, direct v2, legacy TorchScript, and Hugging Face sources. Registry artifacts are now digest-verified before use, v2 artifacts are restricted and schema-validated before construction, and Python references in model YAML are checked against a documented trusted set.
This prevents corrupted or replaced registry artifacts, same-named implicit local files, unsafe pickle fallback, sidecar YAML expansion, and unapproved constructors from bypassing the source-specific trust boundary. Direct custom artifacts retain explicit controls for trusted custom code, while registry policy cannot be weakened by caller options.
Type of Change
Changes Made
./, and../local paths.torch.load(..., weights_only=True), validate their envelope, metadata, tensor-only state dict, and model YAML, and disable sidecar YAML references before model construction..jptfiles explicitly throughtorch.jit.load()as a trusted-code boundary without weakening the existingload_model()compatibility path.ALLOWED_MODEL_IMPORT_PATHSset and keyword-onlymodel_import_pathsandmodel_import_modecontrols for direct local and complete Hugging Face custom artifacts..jptsources on fixed default import settings, including validation before remote weight download or model construction.Compatibility
load_model()continues to accept both v2.ptand legacy.jptfiles;.jptsuffix matching is case-insensitive and now selects the trusted TorchScript loader directly.extend,replace, or explicitunsafebehavior.Testing
Checklist