File size: 12,583 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 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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
#!/usr/bin/env python3
"""
TTRLVR + AZR ํตํฉ ๊ฒ์ฆ ์ค์ํธ
์ ์ฒด ์์คํ
์ ๊ฒ์ฆ์ ์ํ ํตํฉ ์คํฌ๋ฆฝํธ:
1. ํ๊ฒฝ ๊ฒ์ฆ
2. ๋จ์ ํ
์คํธ
3. ๋ฏธ๋ ํตํฉ ํ
์คํธ (1๋ผ์ด๋ ์คํ)
4. ์ฑ๋ฅ ๋ฒค์น๋งํฌ
5. ์ต์ข
๊ฒ์ฆ ๋ณด๊ณ ์ ์์ฑ
"""
import os
import sys
import json
import subprocess
import tempfile
import time
from datetime import datetime
from pathlib import Path
# ๊ฒฝ๋ก ์ค์
sys.path.append('/home/ubuntu/RLVR/TestTime-RLVR-v2')
def run_command(command, description, timeout=300):
"""๋ช
๋ น์ด ์คํ ๋ฐ ๊ฒฐ๊ณผ ๋ฐํ"""
print(f"๐ {description}")
print(f" Command: {command}")
start_time = time.time()
try:
result = subprocess.run(
command,
shell=True,
capture_output=True,
text=True,
timeout=timeout,
cwd='/home/ubuntu/RLVR/TestTime-RLVR-v2'
)
duration = time.time() - start_time
if result.returncode == 0:
print(f"โ
{description} completed ({duration:.1f}s)")
return True, result.stdout, result.stderr
else:
print(f"โ {description} failed ({duration:.1f}s)")
print(f" Error: {result.stderr}")
return False, result.stdout, result.stderr
except subprocess.TimeoutExpired:
print(f"โฐ {description} timed out after {timeout}s")
return False, "", "Timeout"
except Exception as e:
print(f"๐ฅ {description} crashed: {e}")
return False, "", str(e)
def run_environment_validation():
"""ํ๊ฒฝ ๊ฒ์ฆ ์คํ"""
print("\n" + "="*60)
print("1๏ธโฃ ํ๊ฒฝ ๊ฒ์ฆ")
print("="*60)
success, _, _ = run_command(
"cd /home/ubuntu/RLVR/TestTime-RLVR-v2/test && python validate_environment.py",
"Environment validation"
)
return success
def run_unit_tests():
"""๋จ์ ํ
์คํธ ์คํ"""
print("\n" + "="*60)
print("2๏ธโฃ ๋จ์ ํ
์คํธ")
print("="*60)
success, _, _ = run_command(
"cd /home/ubuntu/RLVR/TestTime-RLVR-v2/test && python test_ttrlvr_azr_integration.py",
"Unit tests"
)
return success
def run_mini_integration_test():
"""๋ฏธ๋ ํตํฉ ํ
์คํธ (1๋ฌธ์ , 2๋ผ์ด๋)"""
print("\n" + "="*60)
print("3๏ธโฃ ๋ฏธ๋ ํตํฉ ํ
์คํธ")
print("="*60)
# ์งง์ ํตํฉ ํ
์คํธ ์คํ
success, stdout, stderr = run_command(
"cd /home/ubuntu/RLVR/TestTime-RLVR-v2/test && python train_ttrlvr_azr.py --benchmark mbpp --problems 1 --rounds 2 --debug",
"Mini integration test (1 problem, 2 rounds)",
timeout=1800 # 30๋ถ
)
if success:
print("โ
Mini integration test completed successfully")
# ๊ฒฐ๊ณผ ํ์ผ ํ์ธ
results_dir = Path("/home/ubuntu/RLVR/TestTime-RLVR-v2/test/results/ttrlvr_azr")
if results_dir.exists():
latest_result = max(results_dir.glob("*"), key=os.path.getctime, default=None)
if latest_result:
print(f"๐ Results saved to: {latest_result}")
# ๊ฒฐ๊ณผ ํ์ผ ๋ถ์
result_file = latest_result / "training_results.json"
if result_file.exists():
with open(result_file, 'r') as f:
results = json.load(f)
print(f"๐ Test summary:")
print(f" - Success: {results.get('success', False)}")
print(f" - Completed rounds: {len(results.get('rounds', {}))}")
print(f" - Final model: {results.get('final_model', 'N/A')}")
return success
def check_disk_space():
"""๋์คํฌ ๊ณต๊ฐ ํ์ธ"""
print("\n" + "="*60)
print("4๏ธโฃ ๋์คํฌ ๊ณต๊ฐ ํ์ธ")
print("="*60)
# ์ค์ ๋๋ ํ ๋ฆฌ๋ค์ ๋์คํฌ ์ฌ์ฉ๋ ํ์ธ
paths_to_check = [
"/home/ubuntu/RLVR",
"/data",
"/tmp"
]
all_good = True
for path in paths_to_check:
if os.path.exists(path):
success, stdout, _ = run_command(f"df -h {path}", f"Disk usage for {path}")
if success:
lines = stdout.strip().split('\n')
if len(lines) > 1:
fields = lines[1].split()
if len(fields) >= 5:
used_percent = fields[4].rstrip('%')
if used_percent.isdigit() and int(used_percent) > 90:
print(f"โ ๏ธ Warning: {path} is {used_percent}% full")
all_good = False
else:
print(f"โ
{path}: {used_percent}% used")
else:
print(f"โ ๏ธ Path not found: {path}")
return all_good
def run_performance_benchmark():
"""์ฑ๋ฅ ๋ฒค์น๋งํฌ"""
print("\n" + "="*60)
print("5๏ธโฃ ์ฑ๋ฅ ๋ฒค์น๋งํฌ")
print("="*60)
# GPU ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋ ํ์ธ
print("๐ฅ๏ธ GPU ๋ฉ๋ชจ๋ฆฌ ์ํ:")
gpu_success, gpu_output, _ = run_command("nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits", "GPU memory check")
if gpu_success:
for i, line in enumerate(gpu_output.strip().split('\n')):
if line.strip():
try:
used, total = map(int, line.split(', '))
usage_percent = (used / total) * 100
print(f" GPU {i}: {used}MB / {total}MB ({usage_percent:.1f}%)")
except:
print(f" GPU {i}: {line}")
# ์์คํ
๋ฉ๋ชจ๋ฆฌ ํ์ธ
print("\n๐พ ์์คํ
๋ฉ๋ชจ๋ฆฌ ์ํ:")
mem_success, mem_output, _ = run_command("free -h", "System memory check")
if mem_success:
for line in mem_output.split('\n')[:2]: # ์ฒซ 2์ค๋ง
print(f" {line}")
# CPU ์ฌ์ฉ๋ฅ ํ์ธ
print("\n๐ฅ๏ธ CPU ์ํ:")
cpu_success, cpu_output, _ = run_command("top -bn1 | grep 'Cpu(s)' | head -1", "CPU usage check")
if cpu_success:
print(f" {cpu_output.strip()}")
return gpu_success and mem_success
def generate_validation_report(results):
"""๊ฒ์ฆ ๋ณด๊ณ ์ ์์ฑ"""
print("\n" + "="*60)
print("6๏ธโฃ ๊ฒ์ฆ ๋ณด๊ณ ์ ์์ฑ")
print("="*60)
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
report_file = f"/tmp/ttrlvr_azr_validation_report_{timestamp}.json"
# ๋ณด๊ณ ์ ๋ฐ์ดํฐ
report = {
'timestamp': datetime.now().isoformat(),
'validation_results': results,
'summary': {
'total_tests': len(results),
'passed_tests': sum(1 for result in results.values() if result['success']),
'overall_success': all(result['success'] for result in results.values())
},
'recommendations': []
}
# HTML ๋ณด๊ณ ์ ์์ฑ
html_report = f"/tmp/ttrlvr_azr_validation_report_{timestamp}.html"
html_content = f"""
<!DOCTYPE html>
<html>
<head>
<title>TTRLVR + AZR Validation Report</title>
<style>
body {{ font-family: Arial, sans-serif; margin: 40px; }}
.header {{ background-color: #f0f0f0; padding: 20px; border-radius: 5px; }}
.success {{ color: green; }}
.failure {{ color: red; }}
.test-section {{ margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px; }}
.recommendations {{ background-color: #fff3cd; padding: 15px; border-radius: 5px; }}
</style>
</head>
<body>
<div class="header">
<h1>TTRLVR + AZR Integration Validation Report</h1>
<p>Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}</p>
<p>Overall Status: <span class="{'success' if report['summary']['overall_success'] else 'failure'}">
{'โ
ALL TESTS PASSED' if report['summary']['overall_success'] else 'โ SOME TESTS FAILED'}
</span></p>
<p>Tests: {report['summary']['passed_tests']}/{report['summary']['total_tests']} passed</p>
</div>
<h2>Test Results</h2>
"""
for test_name, result in results.items():
status = "success" if result['success'] else "failure"
icon = "โ
" if result['success'] else "โ"
html_content += f"""
<div class="test-section">
<h3 class="{status}">{icon} {test_name}</h3>
<p><strong>Duration:</strong> {result.get('duration', 'N/A')}</p>
<p><strong>Details:</strong> {result.get('details', 'No details available')}</p>
</div>
"""
if report['recommendations']:
html_content += """
<div class="recommendations">
<h2>Recommendations</h2>
<ul>
"""
for rec in report['recommendations']:
html_content += f"<li>{rec}</li>"
html_content += """
</ul>
</div>
"""
html_content += """
</body>
</html>
"""
# ํ์ผ ์ ์ฅ
with open(report_file, 'w') as f:
json.dump(report, f, indent=2)
with open(html_report, 'w') as f:
f.write(html_content)
print(f"๐ JSON ๋ณด๊ณ ์: {report_file}")
print(f"๐ HTML ๋ณด๊ณ ์: {html_report}")
return report
def main():
"""๋ฉ์ธ ์คํ ํจ์"""
print("๐งช TTRLVR + AZR ํตํฉ ๊ฒ์ฆ ์ค์ํธ ์์")
print("=" * 60)
print(f"์์ ์๊ฐ: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print("=" * 60)
# ๊ฒ์ฆ ๊ฒฐ๊ณผ ์ ์ฅ
results = {}
start_time = time.time()
# 1. ํ๊ฒฝ ๊ฒ์ฆ
test_start = time.time()
success = run_environment_validation()
results['environment_validation'] = {
'success': success,
'duration': f"{time.time() - test_start:.1f}s",
'details': 'Environment setup and dependencies check'
}
# 2. ๋จ์ ํ
์คํธ (ํ๊ฒฝ ๊ฒ์ฆ ์ฑ๊ณต ์์๋ง)
if success:
test_start = time.time()
success = run_unit_tests()
results['unit_tests'] = {
'success': success,
'duration': f"{time.time() - test_start:.1f}s",
'details': 'Component unit tests and integration tests'
}
else:
results['unit_tests'] = {
'success': False,
'duration': '0s',
'details': 'Skipped due to environment validation failure'
}
# 3. ๋ฏธ๋ ํตํฉ ํ
์คํธ (์ด์ ํ
์คํธ๋ค ์ฑ๊ณต ์์๋ง)
if results['unit_tests']['success']:
test_start = time.time()
success = run_mini_integration_test()
results['mini_integration_test'] = {
'success': success,
'duration': f"{time.time() - test_start:.1f}s",
'details': 'End-to-end pipeline test with 1 problem, 2 rounds'
}
else:
results['mini_integration_test'] = {
'success': False,
'duration': '0s',
'details': 'Skipped due to previous test failures'
}
# 4. ๋์คํฌ ๊ณต๊ฐ ํ์ธ (ํญ์ ์คํ)
test_start = time.time()
success = check_disk_space()
results['disk_space_check'] = {
'success': success,
'duration': f"{time.time() - test_start:.1f}s",
'details': 'Available disk space in critical directories'
}
# 5. ์ฑ๋ฅ ๋ฒค์น๋งํฌ (ํญ์ ์คํ)
test_start = time.time()
success = run_performance_benchmark()
results['performance_benchmark'] = {
'success': success,
'duration': f"{time.time() - test_start:.1f}s",
'details': 'System resource usage and performance metrics'
}
# 6. ๋ณด๊ณ ์ ์์ฑ
total_duration = time.time() - start_time
print(f"\nโฑ๏ธ ์ด ์คํ ์๊ฐ: {total_duration:.1f}์ด ({total_duration/60:.1f}๋ถ)")
report = generate_validation_report(results)
# ์ต์ข
๊ฒฐ๊ณผ
print("\n" + "="*60)
print("๐ ๊ฒ์ฆ ์ค์ํธ ์๋ฃ")
print("="*60)
passed = sum(1 for result in results.values() if result['success'])
total = len(results)
print(f"๐ ์ต์ข
๊ฒฐ๊ณผ: {passed}/{total} ํ
์คํธ ํต๊ณผ")
if report['summary']['overall_success']:
print("๐ ๋ชจ๋ ๊ฒ์ฆ ํต๊ณผ! TTRLVR + AZR ์์คํ
์คํ ์ค๋น ์๋ฃ")
return 0
else:
print("โ ๏ธ ์ผ๋ถ ๊ฒ์ฆ ์คํจ. ์์ ๊ฒฐ๊ณผ๋ฅผ ํ์ธํ๊ณ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ธ์.")
return 1
if __name__ == '__main__':
exit_code = main()
sys.exit(exit_code) |