File size: 4,213 Bytes
24c2665 |
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 |
#!/usr/bin/env python3
"""
AZR Integration Test Script
AZR REINFORCE++ νμ΅ ν΅ν©μ΄ μ λλ‘ μλνλμ§ ν
μ€νΈ
"""
import os
import sys
import pandas as pd
import torch
# κ²½λ‘ μ€μ
sys.path.append('/home/ubuntu/RLVR/TestTime-RLVR-v2')
sys.path.append('/home/ubuntu/RLVR/TestTime-RLVR-v2/test')
from utils.azr_trainer_integration import AZRTrainerIntegration
from absolute_zero_reasoner.testtime.logger import TestTimeLogger
def test_data_loading():
"""Parquet λ°μ΄ν° λ‘λ© ν
μ€νΈ"""
print("=== Testing Data Loading ===")
# μ€μ λ°μ΄ν° κ²½λ‘
data_path = "/home/ubuntu/RLVR/TestTime-RLVR-v2/tmp/batch_results/ttrlvr_azr_20250729_141828/humaneval/HumanEval_1/round_5/azr_training_data"
# κ° νμΌ νμΈ
for task_type in ['induction', 'deduction', 'abduction']:
file_path = os.path.join(data_path, f"{task_type}.parquet")
if os.path.exists(file_path):
df = pd.read_parquet(file_path)
print(f"β
{task_type}: {len(df)} rows")
# 첫 λ²μ§Έ νμ reward νμΈ
if len(df) > 0:
first_reward = df.iloc[0]['basic_accuracy']
print(f" First row reward: {first_reward}")
else:
print(f"β {task_type}: File not found")
print()
def test_azr_trainer_init():
"""AZR Trainer μ΄κΈ°ν ν
μ€νΈ"""
print("=== Testing AZR Trainer Initialization ===")
try:
# λλ―Έ ν ν¬λμ΄μ
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-7B")
# λ‘κ±°
logger = TestTimeLogger(log_dir="/tmp/test_logs")
# AZR Trainer μ΄κΈ°ν
trainer = AZRTrainerIntegration(
model_path="Qwen/Qwen2.5-7B",
tokenizer=tokenizer,
logger=logger,
gpu_id=0,
num_cpus=8
)
print("β
AZR Trainer initialized successfully")
# μ€μ μμ± ν
μ€νΈ
config = trainer.create_azr_config(round_num=1, batch_size=24)
print(f"β
Config created: {config.trainer.experiment_name}")
# μ 리
trainer.cleanup()
print("β
Cleanup completed")
except Exception as e:
print(f"β Error: {e}")
import traceback
traceback.print_exc()
print()
def test_data_conversion():
"""λ°μ΄ν° λ³ν ν
μ€νΈ"""
print("=== Testing Data Conversion ===")
try:
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-7B")
logger = TestTimeLogger(log_dir="/tmp/test_logs")
trainer = AZRTrainerIntegration(
model_path="Qwen/Qwen2.5-7B",
tokenizer=tokenizer,
logger=logger,
gpu_id=0,
num_cpus=8
)
# λ°μ΄ν° λ‘λ λ° λ³ν
data_path = "/home/ubuntu/RLVR/TestTime-RLVR-v2/tmp/batch_results/ttrlvr_azr_20250729_141828/humaneval/HumanEval_1/round_5/azr_training_data"
data_protos, stats = trainer.load_and_prepare_data(data_path)
print(f"β
Loaded {len(data_protos)} data protos")
print(f" Stats: {dict(stats)}")
# λ°°μΉ μμ± ν
μ€νΈ
if data_protos:
batches = trainer.prepare_batches(data_protos, batch_size=24)
print(f"β
Created {len(batches)} batches")
if batches:
first_batch_size = len(batches[0])
print(f" First batch size: {first_batch_size}")
trainer.cleanup()
except Exception as e:
print(f"β Error: {e}")
import traceback
traceback.print_exc()
print()
def main():
"""λ©μΈ ν
μ€νΈ ν¨μ"""
print("π§ͺ Starting AZR Integration Tests")
print("=" * 60)
# νκ²½ μ€μ
os.environ['CUDA_VISIBLE_DEVICES'] = '4'
# ν
μ€νΈ μ€ν
test_data_loading()
test_azr_trainer_init()
test_data_conversion()
print("β
Tests completed!")
if __name__ == '__main__':
main() |