Skip to content

Commit

Permalink
ftest: torch checkpoint test
Browse files Browse the repository at this point in the history
  • Loading branch information
0xE0F committed Jan 7, 2025
1 parent bd08728 commit 25a0511
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/tests/ftest/pytorch/checkpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
(C) Copyright 2025 Google LLC
SPDX-License-Identifier: BSD-2-Clause-Patent
"""
import os
import random

from apricot import TestWithServers
from pydaos.torch import Checkpoint


class PytorchCheckpointTest(TestWithServers):
"""Test Pytorch Checkpoint interface
:avocado: recursive
"""

def test_checkpoint(self):
"""Test Pytorch Checkpoint interface
Test Description: Ensure that wirting and reading a checkpoint works as expected.
:avocado: tags=all,full_regression
:avocado: tags=vm
:avocado: tags=pytorch
:avocado: tags=PytorchCheckpointTest,test_checkpoint
"""
pool = self.get_pool()
container = self.get_container(pool)

writes = self.params.get("writes", "/run/checkpoint/*")
min_size = self.params.get("min_size", "/run/checkpoint/*", 1)
max_size = self.params.get("max_size", "/run/checkpoint/*", 1024 * 1024)

expected = bytearray()
chkp = Checkpoint(pool.identifier, container.identifier)
with chkp.writer('blob') as w:
for _ in range(writes):
content = os.urandom(random.randint(min_size, max_size))

w.write(content)
expected.extend(content)

actual = chkp.reader('blob')
if expected != actual.getvalue():
self.fail("checkpoint did not read back the expected content")
23 changes: 23 additions & 0 deletions src/tests/ftest/pytorch/checkpoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
hosts:
test_servers: 1
test_clients: 1
server_config:
name: daos_server
engines_per_host: 1
engines:
0:
targets: 4
nr_xs_helpers: 0
storage:
0:
class: ram
scm_mount: /mnt/daos
system_ram_reserved: 1
pool:
size: 1G
container:
type: POSIX
control_method: daos

checkpoint:
writes: 100

0 comments on commit 25a0511

Please sign in to comment.