Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

refactor tests into separate dir #10

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
float8_playground/__pycache__/*
finetune/__pycache__/*
tests/__pycache__/*
tmp/*
5 changes: 5 additions & 0 deletions tests/context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# https://docs.python-guide.org/writing/structure/#test-suite

import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../float8_playground')))
3 changes: 3 additions & 0 deletions float8_playground/test.py → tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import torch
import torch.nn as nn

# set up float8 path
import context

from float8_utils import (
compute_error,
tensor_to_scale,
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions float8_playground/test_fsdp.sh → tests/test_fsdp.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash

# generate the test data
python float8_playground/test_fsdp.py --mode generate
python tests/test_fsdp.py --mode generate

# generate single GPU model output and updated state dict
python float8_playground/test_fsdp.py --mode single_gpu
python tests/test_fsdp.py --mode single_gpu

# generate FSDP model output and updated state dict
# the NCCL_DEBUG setting is to avoid log spew
# the CUDA_VISIBLE_DEVICES setting is for easy debugging
NCCL_DEBUG=WARN CUDA_VISIBLE_DEVICES=0,1 python float8_playground/test_fsdp.py --mode fsdp
NCCL_DEBUG=WARN CUDA_VISIBLE_DEVICES=0,1 python tests/test_fsdp.py --mode fsdp

# compare the outputs and state dicts and verify equivalence
python float8_playground/test_fsdp.py --mode analyze
python tests/test_fsdp.py --mode analyze
3 changes: 3 additions & 0 deletions float8_playground/test_sam.py → tests/test_sam.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

from transformers import SamModel

# set up float8 path
import context

from float8_linear import swap_linear_with_float8_linear
from float8_utils import compute_error

Expand Down