|
|
|
""" |
|
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") |
|
|
|
|
|
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") |
|
|
|
|
|
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() |