Skip to content

Commit 445d8fd

Browse files
mzzchypytorchmergebot
authored andcommitted
[MemoryZ] Sync changes to internal page (pytorch#153166)
Summary: For MTIA on-demand mode, since we are not using torch Module. The data upload happens in cpp and doesn't support pickle. Thus, we store as JSON at the end and need the update visualizer to support it Test Plan: Check Test plan in D74179606 Differential Revision: D74406209 Pull Request resolved: pytorch#153166 Approved by: https://github.com/sraikund16
1 parent ea3eaf6 commit 445d8fd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

torch/utils/viz/MemoryViz.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,19 @@ function create_settings_view(dst, snapshot, device) {
12941294
}
12951295

12961296
function unpickle(buffer) {
1297+
try {
1298+
const decoder = new TextDecoder();
1299+
const jsonString = decoder.decode(new Uint8Array(buffer));
1300+
const data = JSON.parse(jsonString);
1301+
1302+
return data;
1303+
} catch (e) {
1304+
console.log('Failed to decode the data as JSON, fall back to pickle', e);
1305+
}
1306+
return unpickleData(buffer);
1307+
}
1308+
1309+
function unpickleData(buffer) {
12971310
const bytebuffer = new Uint8Array(buffer);
12981311
const decoder = new TextDecoder();
12991312

0 commit comments

Comments
 (0)