Skip to content

Commit 34d4935

Browse files
author
Han Wang
committed
fix(pt_expt): clean up md_file in spin LAMMPS tests, add ZIP comment
Add md_file cleanup to teardown_module in spin pt2 LAMMPS tests. Add inline comment documenting PyTorch ZIP STORED assumption.
1 parent 48703dc commit 34d4935

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

source/api_cc/src/commonPTExpt.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,12 @@ inline std::string read_zip_entry(const std::string& zip_path,
421421
uint16_t local_extra_len = read_u16(local_header_offset + 28);
422422
size_t data_offset =
423423
local_header_offset + 30 + local_name_len + local_extra_len;
424+
// PyTorch archives (.pth, .pte, .pt2) always use ZIP STORED (compression
425+
// method 0) for every entry. PyTorch needs to mmap tensor data directly
426+
// from the archive without decompression, so its C++ writer
427+
// (caffe2::serialize::PyTorchStreamWriter) and torch.export.save both
428+
// write uncompressed entries with 64-byte alignment. No decompression is
429+
// needed.
424430
return content.substr(data_offset, uncompressed_size);
425431
}
426432

source/lmp/tests/test_lammps_spin_nopbc_pt2.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def setup_module() -> None:
9090

9191
def teardown_module() -> None:
9292
os.remove(data_file)
93+
if md_file.exists():
94+
os.remove(md_file)
9395

9496

9597
def _lammps(data_file, units="metal") -> PyLammps:

source/lmp/tests/test_lammps_spin_pt2.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ def setup_module() -> None:
140140

141141
def teardown_module() -> None:
142142
os.remove(data_file)
143+
if md_file.exists():
144+
os.remove(md_file)
143145

144146

145147
def _lammps(data_file, units="metal") -> PyLammps:

0 commit comments

Comments
 (0)