Commit 3c4f2cc
authored
Re-enable one step ahead
The `_prefectch_numpy_iterator` feature in the JAX trainer had been disabled based on the idea that many dataset implementations already support prefectching. However, this came from a misundestanding of what `_prefetch_numpy_iterator` does, probably because of the misleading name.
`_prefetch_numpy_iterator` triggers `device_put` for all the arrays of a batch of data to transfer arrays from CPU to the accelerator (GPU or TPU). `device_put` is asynchronous. By triggering `device_put` one step ahead. we parallelize the transfer of the next batch of data with the running of the model with the current batch of data. Without this, the batch of data is immediately used after called `device_put`, which causes a wait until `device_put` is complete.
Prefetching happens only on CPU and is independent.
- Removed the `builtin_prefetch` property, which now does not serve any purpose anymore.
- Renamed `_prefetch_numpy_iterator` to `_one_batch_ahead_iterator`, which more accurately describes its purpose.device_put of data from datasets on JAX. (#22353)1 parent 549b476 commit 3c4f2cc
File tree
8 files changed
+19
-81
lines changed- keras/src
- backend/jax
- trainers/data_adapters
8 files changed
+19
-81
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
1088 | 1087 | | |
1089 | 1088 | | |
1090 | 1089 | | |
1091 | | - | |
1092 | | - | |
1093 | 1090 | | |
1094 | | - | |
| 1091 | + | |
1095 | 1092 | | |
1096 | 1093 | | |
1097 | 1094 | | |
| |||
1108 | 1105 | | |
1109 | 1106 | | |
1110 | 1107 | | |
1111 | | - | |
1112 | | - | |
| 1108 | + | |
| 1109 | + | |
1113 | 1110 | | |
1114 | | - | |
1115 | | - | |
1116 | | - | |
1117 | | - | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
1121 | 1115 | | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
1128 | | - | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
1133 | | - | |
1134 | | - | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | 49 | | |
65 | 50 | | |
66 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | 204 | | |
209 | 205 | | |
210 | 206 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | 188 | | |
194 | 189 | | |
195 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | 65 | | |
70 | 66 | | |
71 | 67 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | 87 | | |
93 | 88 | | |
94 | 89 | | |
| |||
Lines changed: 0 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | 68 | | |
77 | 69 | | |
78 | 70 | | |
| |||
Lines changed: 0 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
0 commit comments