Commit 2b7db68
committed
qwen2/3vl: memoize HF processor _merge_kwargs by call signature
ProcessorMixin._merge_kwargs (transformers) is pure but runs on every
processor call. When all requests pass the same kwargs (the common
deployment case), caching by signature converts a per-call merge into
an O(1) lookup after the first call.
Implemented as a wrapper installed on the processor instance at
construction time, so it doesn't require any change to transformers.
Cache key is the repr of sorted kwargs items; values are deep-copied
on get and put because callers mutate the returned dict.
Signed-off-by: Aswin Visva <31215515+aswinvisva@users.noreply.github.com>1 parent 50acdb5 commit 2b7db68
1 file changed
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
80 | 115 | | |
81 | 116 | | |
82 | 117 | | |
| |||
186 | 221 | | |
187 | 222 | | |
188 | 223 | | |
| 224 | + | |
189 | 225 | | |
190 | 226 | | |
191 | 227 | | |
| |||
0 commit comments