Load an older PTD file in the Python reader instead of rejecting it - #22117
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22117
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit b7ae07a with merge base 1afd07f ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
|
@claude review the PR |
|
Claude finished @shoumikhin's task in 49s —— View job PR Review
Verdict: LGTM. The change is small, correct, and well-motivated. It brings the Python reader in line with the append-only schema policy and the C++ runtime's "reject only newer" behavior. Correctness
Minor suggestions (non-blocking)
Nothing blocking. Nice cleanup. |
FlatTensorSerializer.deserialize refused any file whose version did not exactly equal _FLAT_TENSOR_VERSION. That rejects an older file too, which contradicts the append-only schema policy (schema/README.md) and the C++ runtime readers, which accept anything at or below their supported version and only refuse a file newer than they understand. Compare with > instead of !=, so an older or equal file loads and only a newer one is refused, and reword the error to say the file is newer than this reader supports. Two tests cover both directions: a bumped-version file is refused, and a file older than the reader still loads (the case the old != wrongly rejected).
b7ae07a to
26cf683
Compare
|
Thanks @claude. Addressed both actionable notes:
On #3: yes, the C++ |
|
Claude finished @shoumikhin's task in 34s —— View job Follow-up Review
Verdict: LGTM. Both notes are addressed cleanly and the change is ready. Round-trip assertion ✅
|
Summary
The Python
FlatTensorSerializer.deserializerefused any PTD file whoseversiondid not exactly equal_FLAT_TENSOR_VERSION:That rejects an older file too, which contradicts:
schema/README.md(older files stay loadable), and<=their supported version and only refuse a file newer than they understand (Program::load,FlatTensorDataMap::load).This aligns the Python PTD reader with that policy: compare with
>instead of!=, so an older or equal file loads and only a newer one is refused. The error message now says the file is newer than this reader supports.Context
This was called out as a follow-up during review of #22114 (which adds the
<=gate on the C++ side). It keeps the Python export/tooling path consistent so a future non-zero PTD version won't regress it.Test plan
Two tests in
extension/flat_tensor/test/test_serialize.py:test_deserialize_refuses_newer_version— a bumped-version file is refused.test_deserialize_accepts_older_version— a file older than the reader still loads (the case the old!=wrongly rejected).Both are behavior-only; no schema or format change. Version constants are unchanged (still
0), so this is inert for existing files and only changes behavior once a non-zero version is ever stamped.