Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store/Load CIFAR from local/offline #6390

Merged
merged 11 commits into from
Aug 28, 2024
23 changes: 18 additions & 5 deletions tests/unit/alexnet_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,24 @@ def cifar_trainset(fp16=False):
if local_rank != 0:
dist.barrier()

data_root = os.getenv("TEST_DATA_DIR", "/tmp/")
trainset = torchvision.datasets.CIFAR10(root=os.path.join(data_root, "cifar10-data"),
train=True,
download=True,
transform=transform)
if os.getenv("CIFAR10_OFFLINE", default=None):
loadams marked this conversation as resolved.
Show resolved Hide resolved
if os.getenv("CIFAR10_DATASET_PATH", default=None):
trainset = torchvision.datasets.CIFAR10(root=os.getenv("CIFAR10_DATASET_PATH", default=None),
train=True,
download=False,
transform=transform)
elif os.getenv("STORE_CIFAR10", default=None):
if os.getenv("CIFAR10_DATASET_PATH", default=None):
trainset = torchvision.datasets.CIFAR10(root=os.getenv("CIFAR10_DATASET_PATH", default=None),
train=True,
download=True,
transform=transform)
else:
data_root = os.getenv("TEST_DATA_DIR", "/tmp/")
trainset = torchvision.datasets.CIFAR10(root=os.path.join(data_root, "cifar10-data"),
train=True,
download=True,
transform=transform)
if local_rank == 0:
dist.barrier()
return trainset
Expand Down
12 changes: 10 additions & 2 deletions tests/unit/inference/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,14 @@ def verify_injection(module):
verify_injection(model)


# Used to Get Device name
def getDeviceId(local_rank):
device = local_rank
if get_accelerator().device_name() != 'cuda':
tjruwase marked this conversation as resolved.
Show resolved Hide resolved
device = torch.device(f"{get_accelerator().device_name()}")
return device


# Verify that test is valid
def validate_test(model_w_task, dtype, enable_cuda_graph, enable_triton):
model, task = model_w_task
Expand Down Expand Up @@ -484,8 +492,8 @@ def test(
pytest.skip(f"Acceleraor {get_accelerator().device_name()} does not support {dtype}.")

local_rank = int(os.getenv("LOCAL_RANK", "0"))

pipe = pipeline(task, model=model, model_kwargs={"low_cpu_mem_usage": True}, device=local_rank, framework="pt")
device = getDeviceId(local_rank)
pipe = pipeline(task, model=model, model_kwargs={"low_cpu_mem_usage": True}, device=device, framework="pt")
bs_output = pipe(query, **inf_kwargs)
pipe.model = deepspeed.init_inference(pipe.model,
mp_size=self.world_size,
Expand Down