Repository navigation
Conversation
Declare frozen int, float, bool, str, and None inputs as ConstantArgument after lifting graph state. Add save/load regressions for positional and keyword inputs, dynamic shapes, lifted parameters and buffers, and zero-dimensional tensors. Fixes pytorch#4941 Signed-off-by: 王毅 <[email protected]>
|
Hi @970334745! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@cehongwang, could you please review this exporter fix and approve the fork workflow runs when convenient? The Meta CLA check is now successful. For the current head The PR already records the 22 constant-input regression cases plus three existing lifting tests, the ordering constraint after |
Invalidate missing fake metadata by Node on current PyTorch while preserving the older OrderedSet representation. Resolve retained TorchScript implementations without mutating torch.jit, preserving native callable signatures and legacy load/save behavior. Cover both cache contracts and real CPU serialization, and run the regressions in the existing CPU CI lane. Signed-off-by: 王毅 <[email protected]>
Canonicalize only PyTorch-generated GuardsFn nodes while retaining authoritative input ranges and constant guards. Detect ModelOpt quantizers without importing an incompatible optional dependency, including user subclasses. Route legacy TorchScript API fixtures through retained native implementations. Real PyTorch 2.16 CPU suites pass 224 cases plus 27 engine-free export/lift regressions; platform/package exclusions remain unchanged. Signed-off-by: 王毅 <[email protected]>
Retain upstream fake-mode discovery for integer-only inputs together with authoritative input ranges. The exact merged source passed 230 CPU API/compatibility checks and 27 real PyTorch export/lifting component checks on the CI-day nightly. Signed-off-by: 王毅 <[email protected]>
|
@cehongwang, could you approve the fork workflows for |
|
For the current |
Problem and resulting behavior
Fixes #4941.
save(retrace=False)rebuilt frozen Python inputs as tensor arguments, so serializing an exported model withscale=2.0ormask=Nonecould raiseKeyError. PreserveConstantArgumentafter graph-state lifting, including positional and keyword constants, dynamic batches, and constants preceding parameters or buffers.Current PyTorch also changes fake-metadata cache keys, stops re-exporting several TorchScript entry points, and attaches execution guards to unlifted modules. The compatibility changes below let these export/runtime paths use current PyTorch while preserving input validation and the older cache/API contracts.
Changes
OrderedSetrepresentation.script,trace,save, andloadcallables, preferring public exports when present. Original signatures, keyword filtering, extra files, and error propagation remain intact; the globaltorch.jitnamespace is not modified. Legacy API fixtures use the same resolver.GuardsFnmodules when rebuilding a canonicalExportedProgram. Preserve authoritative range constraints and constant specs so the rebuilt program regenerates its input guards, while retaining upstream fake-mode discovery for integer-only inputs. Tests reject out-of-range batches and changed frozen values, and retain user-defined modules/subclasses even when named_guards_fn.AssertionErrorfrom newer native input guards; no new skip guards or numerical tolerance changes are introduced.Validation
Python 3.12.3,
torch==2.16.0.dev20261116+cpu, CMake 4.4.5, pytest 9.2.0:50e8c516, and 12 optional-dependency detection plus 23 export-guard failures on6ec631f0; the repaired cases pass.git diff --checkpass. Ruff reports no new undefined-name/syntax findings; two pre-existing F841 findings in the mutable module are unchanged.Full current-head GPU/build results remain subject to the upstream fork workflow approval process; CPU component checks do not substitute for those jobs.
The released ModelOpt 0.49.0rc0 has a separate import-time
@torch.jit.scriptincompatibility affecting actual quantized execution. The corresponding dependency fix is proposed in NVIDIA/Model-Optimizer#3409; quantized execution needs that fix in the installed dependency. Ordinary model inspection is isolated from that optional failure here; quantized execution still requires the corresponding dependency repair rather than silently changing its behavior.