File size: 2,370 Bytes
4484246 |
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 |
#!/usr/bin/env python3
"""
Query submissions by user/problem or by submission ID.
Usage:
python query_submissions.py # Show all submission IDs for gau.nernst on gemv
python query_submissions.py --id 187476 # Show code for specific submission ID
python query_submissions.py --user gau.nernst --problem nvfp4_gemm
"""
import argparse
import pandas as pd
from pathlib import Path
df = pd.read_parquet(Path(__file__).parent.parent.parent / 'nvidia_nvfp4_submissions.parquet')
parser = argparse.ArgumentParser()
parser.add_argument('--id', type=int, help='Submission ID to query')
parser.add_argument('--user', default='gau.nernst', help='Username to filter')
parser.add_argument('--problem', default='nvfp4_gemv', help='Problem name to filter')
args = parser.parse_args()
if args.id:
# Query specific submission
sub = df[df['submission_id'] == args.id]
if sub.empty:
print(f"Submission {args.id} not found")
else:
row = sub.iloc[0]
score_us = row['score'] * 1_000_000 if pd.notna(row['score']) else 'N/A'
print(f"ID: {row['submission_id']}")
print(f"User: {row['user_name']}")
print(f"Problem: {row['problem_name']}")
print(f"Score: {score_us:.2f} µs" if isinstance(score_us, float) else f"Score: {score_us}")
print(f"\n=== CODE ===\n")
print(row['code'])
else:
# List all submission IDs for user/problem
subs = df[(df['user_name'] == args.user) & (df['problem_name'] == args.problem)]
subs = subs.sort_values('score')
ids = subs['submission_id'].tolist()
scores = [(row['submission_id'], row['score'] * 1_000_000 if pd.notna(row['score']) else None)
for _, row in subs.iterrows()]
print(f"User: {args.user} | Problem: {args.problem} | Count: {len(ids)}")
print(f"\nSubmission IDs (sorted by score, fastest first):")
print(ids)
# Get fastest/slowest with valid scores
valid_scores = [(sid, sc) for sid, sc in scores if sc is not None]
if valid_scores:
print(f"\nFastest: {valid_scores[0][0]} ({valid_scores[0][1]:.2f} µs)")
print(f"Slowest: {valid_scores[-1][0]} ({valid_scores[-1][1]:.2f} µs)")
print(f"\nQuery a specific submission: python query_submissions.py --id {valid_scores[0][0]}")
else:
print("\nNo submissions with scores found")
|