neural-mesh-v2 / test /test_azr_integration.py
hjkim00's picture
Restore all essential files - code, configs, and MBPP/HumanEval data
24c2665 verified
raw
history blame
4.21 kB
#!/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()