Per-entry seed in XNNPACK weights cache for XNNPACK-upgrade invalidation (#20170)#20170
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20170
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 139 PendingAs of commit 995383f with merge base e257a71 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@doggeral has exported this pull request. If you are a Meta employee, you can view the originating Diff in D108082431. |
This PR needs a
|
e362f91 to
3f12b29
Compare
…ion (pytorch#20170) Summary: XNNPACK exposes `xnn_weights_cache_look_up_key.seed` — a per-ukernel value that XNNPACK guarantees is consistent across runs of the same ukernel and changes whenever a ukernel implementation changes. Store this seed per cache entry so a stale cached packing produced by an old XNNPACK ukernel is rejected after upgrade, instead of being handed back to a newer ukernel that expects a different layout. Changes: - `PackedDataMeta` gains `uint32_t seed{0}`. - `look_up` rejects (returns `SIZE_MAX`) when a name hit has a stored seed that doesn't match `cache_key->seed`. This forces `look_up_or_insert` to re-pack with the current ukernel and avoids the slow `memcmp` path catching it later. - `look_up_or_insert` records `cache_key->seed` on insert. - On-disk index entry layout extended to `[name_len:u32][name][file_offset:u64][data_size:u64][seed:u32]` (was 16 bytes after the name, now 20). - `load_packed_cache` reads the per-entry seed and bumps the trailing bytes bound check accordingly. - `kCacheVersion` bumped 1 → 2 so existing v1 files (which carry no seed) are rejected at load instead of being loaded with `seed=0` and mismatching every fresh `look_up`. Cleanup of orphaned in-memory and on-disk entries left by an invalidated look-up is a follow-up — this diff only adds the detection. Reviewed By: GregoryComer Differential Revision: D108082431
…ion (pytorch#20170) Summary: XNNPACK exposes `xnn_weights_cache_look_up_key.seed` — a per-ukernel value that XNNPACK guarantees is consistent across runs of the same ukernel and changes whenever a ukernel implementation changes. Store this seed per cache entry so a stale cached packing produced by an old XNNPACK ukernel is rejected after upgrade, instead of being handed back to a newer ukernel that expects a different layout. Changes: - `PackedDataMeta` gains `uint32_t seed{0}`. - `look_up` rejects (returns `SIZE_MAX`) when a name hit has a stored seed that doesn't match `cache_key->seed`. This forces `look_up_or_insert` to re-pack with the current ukernel and avoids the slow `memcmp` path catching it later. - `look_up_or_insert` records `cache_key->seed` on insert. - On-disk index entry layout extended to `[name_len:u32][name][file_offset:u64][data_size:u64][seed:u32]` (was 16 bytes after the name, now 20). - `load_packed_cache` reads the per-entry seed and bumps the trailing bytes bound check accordingly. - `kCacheVersion` bumped 1 → 2 so existing v1 files (which carry no seed) are rejected at load instead of being loaded with `seed=0` and mismatching every fresh `look_up`. Cleanup of orphaned in-memory and on-disk entries left by an invalidated look-up is a follow-up — this diff only adds the detection. Reviewed By: GregoryComer Differential Revision: D108082431
3f12b29 to
96feb41
Compare
…ion (pytorch#20170) Summary: XNNPACK exposes `xnn_weights_cache_look_up_key.seed` — a per-ukernel value that XNNPACK guarantees is consistent across runs of the same ukernel and changes whenever a ukernel implementation changes. Store this seed per cache entry so a stale cached packing produced by an old XNNPACK ukernel is rejected after upgrade, instead of being handed back to a newer ukernel that expects a different layout. Changes: - `PackedDataMeta` gains `uint32_t seed{0}`. - `look_up` rejects (returns `SIZE_MAX`) when a name hit has a stored seed that doesn't match `cache_key->seed`. This forces `look_up_or_insert` to re-pack with the current ukernel and avoids the slow `memcmp` path catching it later. - `look_up_or_insert` records `cache_key->seed` on insert. - On-disk index entry layout extended to `[name_len:u32][name][file_offset:u64][data_size:u64][seed:u32]` (was 16 bytes after the name, now 20). - `load_packed_cache` reads the per-entry seed and bumps the trailing bytes bound check accordingly. - `kCacheVersion` bumped 1 → 2 so existing v1 files (which carry no seed) are rejected at load instead of being loaded with `seed=0` and mismatching every fresh `look_up`. Cleanup of orphaned in-memory and on-disk entries left by an invalidated look-up is a follow-up — this diff only adds the detection. Reviewed By: GregoryComer Differential Revision: D108082431
ac645d4 to
2aba836
Compare
…ion (pytorch#20170) Summary: XNNPACK exposes `xnn_weights_cache_look_up_key.seed` — a per-ukernel value that XNNPACK guarantees is consistent across runs of the same ukernel and changes whenever a ukernel implementation changes. Store this seed per cache entry so a stale cached packing produced by an old XNNPACK ukernel is rejected after upgrade, instead of being handed back to a newer ukernel that expects a different layout. Changes: - `PackedDataMeta` gains `uint32_t seed{0}`. - `look_up` rejects (returns `SIZE_MAX`) when a name hit has a stored seed that doesn't match `cache_key->seed`. This forces `look_up_or_insert` to re-pack with the current ukernel and avoids the slow `memcmp` path catching it later. - `look_up_or_insert` records `cache_key->seed` on insert. - On-disk index entry layout extended to `[name_len:u32][name][file_offset:u64][data_size:u64][seed:u32]` (was 16 bytes after the name, now 20). - `load_packed_cache` reads the per-entry seed and bumps the trailing bytes bound check accordingly. - `kCacheVersion` bumped 1 → 2 so existing v1 files (which carry no seed) are rejected at load instead of being loaded with `seed=0` and mismatching every fresh `look_up`. Cleanup of orphaned in-memory and on-disk entries left by an invalidated look-up is a follow-up — this diff only adds the detection. Reviewed By: GregoryComer Differential Revision: D108082431
2aba836 to
2b2b91f
Compare
…ion (pytorch#20170) Summary: XNNPACK exposes `xnn_weights_cache_look_up_key.seed` — a per-ukernel value that XNNPACK guarantees is consistent across runs of the same ukernel and changes whenever a ukernel implementation changes. Store this seed per cache entry so a stale cached packing produced by an old XNNPACK ukernel is rejected after upgrade, instead of being handed back to a newer ukernel that expects a different layout. Changes: - `PackedDataMeta` gains `uint32_t seed{0}`. - `look_up` rejects (returns `SIZE_MAX`) when a name hit has a stored seed that doesn't match `cache_key->seed`. This forces `look_up_or_insert` to re-pack with the current ukernel and avoids the slow `memcmp` path catching it later. - `look_up_or_insert` records `cache_key->seed` on insert. - On-disk index entry layout extended to `[name_len:u32][name][file_offset:u64][data_size:u64][seed:u32]` (was 16 bytes after the name, now 20). - `load_packed_cache` reads the per-entry seed and bumps the trailing bytes bound check accordingly. - `kCacheVersion` bumped 1 → 2 so existing v1 files (which carry no seed) are rejected at load instead of being loaded with `seed=0` and mismatching every fresh `look_up`. Cleanup of orphaned in-memory and on-disk entries left by an invalidated look-up is a follow-up — this diff only adds the detection. Reviewed By: GregoryComer Differential Revision: D108082431
2b2b91f to
995383f
Compare
Summary:
XNNPACK exposes
xnn_weights_cache_look_up_key.seed— a per-ukernel value that XNNPACK guarantees is consistent across runs of the same ukernel and changes whenever a ukernel implementation changes. Store this seed per cache entry so a stale cached packing produced by an old XNNPACK ukernel is rejected after upgrade, instead of being handed back to a newer ukernel that expects a different layout.Changes:
PackedDataMetagainsuint32_t seed{0}.look_uprejects (returnsSIZE_MAX) when a name hit has a stored seed that doesn't matchcache_key->seed. This forceslook_up_or_insertto re-pack with the current ukernel and avoids the slowmemcmppath catching it later.look_up_or_insertrecordscache_key->seedon insert.[name_len:u32][name][file_offset:u64][data_size:u64][seed:u32](was 16 bytes after the name, now 20).load_packed_cachereads the per-entry seed and bumps the trailing bytes bound check accordingly.kCacheVersionbumped 1 → 2 so existing v1 files (which carry no seed) are rejected at load instead of being loaded withseed=0and mismatching every freshlook_up.Cleanup of orphaned in-memory and on-disk entries left by an invalidated look-up is a follow-up — this diff only adds the detection.
Reviewed By: GregoryComer
Differential Revision: D108082431