File size: 5,700 Bytes
6534252 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
#!/usr/bin/env python3
"""
Simple test script to verify GLEN environment is ready for The Vault dataset
"""
import os
import sys
import torch
import pandas as pd
from pathlib import Path
def test_dependencies():
"""Test if all required dependencies are installed"""
print("Testing dependencies...")
try:
import transformers
print(f"β
transformers: {transformers.__version__}")
except ImportError:
print("β transformers not found")
return False
try:
import torch
print(f"β
torch: {torch.__version__}")
print(f"β
CUDA available: {torch.cuda.is_available()}")
if torch.cuda.is_available():
print(f"β
GPU: {torch.cuda.get_device_name(0)}")
except ImportError:
print("β torch not found")
return False
try:
import pandas
print(f"β
pandas: {pandas.__version__}")
except ImportError:
print("β pandas not found")
return False
try:
import wandb
print(f"β
wandb: {wandb.__version__}")
except ImportError:
print("β wandb not found")
return False
return True
def test_data_files():
"""Test if required data files exist"""
print("\nTesting data files...")
data_dir = Path("data/the_vault")
required_files = [
"DOC_VAULT_train.tsv",
"GTQ_VAULT_train.tsv",
"ID_VAULT_t5_bm25_truncate_3.tsv",
"DOC_VAULT_validate.tsv",
"GTQ_VAULT_dev.tsv"
]
all_found = True
for file_name in required_files:
file_path = data_dir / file_name
if file_path.exists():
size = file_path.stat().st_size / 1024 # KB
print(f"β
{file_name} ({size:.1f} KB)")
else:
print(f"β {file_name} not found")
all_found = False
return all_found
def test_tevatron_imports():
"""Test if tevatron modules can be imported"""
print("\nTesting tevatron imports...")
try:
from tevatron.arguments import (
GLENP1ModelArguments,
GLENP1DataArguments,
GLENP1TrainingArguments
)
print("β
Phase 1 arguments imported")
except ImportError as e:
print(f"β Phase 1 arguments import failed: {e}")
return False
try:
from tevatron.utils.gpu_monitor import GPUMemoryMonitor
print("β
GPU monitor imported")
except ImportError as e:
print(f"β GPU monitor import failed: {e}")
return False
return True
def test_gpu_monitor():
"""Test GPU memory monitor functionality"""
print("\nTesting GPU monitor...")
try:
from tevatron.utils.gpu_monitor import GPUMemoryMonitor
monitor = GPUMemoryMonitor(memory_threshold=0.8, check_interval=10)
stats = monitor.get_memory_stats()
if stats["enabled"]:
print(f"β
GPU monitor enabled")
print(f" - Total GPU memory: {stats['total_gb']:.2f} GB")
print(f" - Current usage: {stats['usage_ratio']:.1%}")
# Test memory check
can_continue = monitor.check_memory()
print(f" - Memory check passed: {can_continue}")
else:
print("β οΈ GPU monitor disabled (no CUDA)")
return True
except Exception as e:
print(f"β GPU monitor test failed: {e}")
return False
def test_data_loading():
"""Test loading a sample of data"""
print("\nTesting data loading...")
try:
train_doc_path = "data/the_vault/DOC_VAULT_train.tsv"
if os.path.exists(train_doc_path):
df = pd.read_csv(train_doc_path, sep='\t', nrows=5)
print(f"β
Loaded {len(df)} sample documents")
print(f" - Columns: {list(df.columns)}")
# Check if content looks reasonable
if 'doc_content' in df.columns and len(df['doc_content'].iloc[0]) > 50:
print("β
Document content looks valid")
else:
print("β οΈ Document content might be too short")
return True
except Exception as e:
print(f"β Data loading test failed: {e}")
return False
def main():
print("π§ͺ GLEN Environment Test for The Vault Dataset")
print("=" * 50)
tests = [
("Dependencies", test_dependencies),
("Data Files", test_data_files),
("Tevatron Imports", test_tevatron_imports),
("GPU Monitor", test_gpu_monitor),
("Data Loading", test_data_loading)
]
passed = 0
total = len(tests)
for test_name, test_func in tests:
print(f"\nπ {test_name}")
print("-" * 30)
if test_func():
passed += 1
print(f"β
{test_name} PASSED")
else:
print(f"β {test_name} FAILED")
print("\n" + "=" * 50)
print(f"π― Test Results: {passed}/{total} tests passed")
if passed == total:
print("π Environment is ready for GLEN training!")
print("\nNext steps:")
print("1. Run full preprocessing if needed:")
print(" python scripts/preprocess_vault_dataset.py --input_dir the_vault_dataset/ --output_dir data/the_vault/")
print("2. Start training:")
print(" bash scripts/train_glen_p1_vault.sh")
return True
else:
print("β οΈ Some tests failed. Please fix the issues above.")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1) |