Repository navigation
Commit 89e6f90
authored
Qualcomm: stop an expired bundle from making the backend cache stale (pytorch#21944)
QnnBackendUnifiedRegistry caches backend bundles as weak_ptr keyed on
backend type,
and CleanupExpired() only runs in the registry destructor. When a
bundle's last
owner goes away, the dead weak_ptr stays in the map. The next request
finds the
entry, fails to lock it, builds a fresh bundle, and then calls emplace()
— which is
a no-op because the key already exists. The corpse is never replaced, so
every
subsequent lowering rebuilds the backend and device instead of sharing
them.
insert_or_assign replaces the expired entry. CleanupExpired() can't be
used here
because it takes mutex_, which is already held.
Single-lowering processes never reach this, which is why it has been
invisible. It
shows up once a process does two or more lowerings: with the fix the
second
lowering reuses the cached bundle instead of creating a second one,
which also
avoids repeated device configuration.
Test: test_backend_bundle_cache_survives_an_expired_entry asserts two
creations
plus at least one reuse, and fails on unmodified main.
cc @cbilgin1 parent 66a0fec commit 89e6f90
2 files changed
Lines changed: 57 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
171 | 175 | | |
172 | 176 | | |
173 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
795 | 795 | | |
796 | 796 | | |
797 | 797 | | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
798 | 850 | | |
799 | 851 | | |
800 | 852 | | |
0 commit comments