p-doom/crowd-code-dataset-0.2 huggingface dataset:
[tab] plot.ipynb (python)
# --- 5. PROCESS AND PLOT DATA ---
plt.style.use('seaborn-v0_8-whitegrid')
fig, ax = plt.subplots(figsize=(12, 8))

all_plot_data = []

# Filter to only include the specific runs you want
target_runs = [
    "dynamics-batch-size-scaling-1-node-3335740",
    "dynamics-batch-size-scaling-2-node-3335741", 
    "dynamics-batch-size-scaling-16-node-3335739",
    "dynamics-batch-size-scaling-4-node-3335742",
    "dynamics-batch-size-scaling-8-node-3335743"
]

runs_with_data = []
for run in runs:
    if run.name in target_runs:
        try:
            history = list(run.scan_history())
            if history:  # Only include runs with history data
                runs_with_data.append(run)
        except:
            continue

print(f"Found {len(runs_with_data)} target runs with actual data")

for run in runs_with_data:
    # Get run history (the metrics over time) as a pandas DataFrame
    history = run.scan_history(keys=["step", METRIC_NAME])
    history_df = pd.DataFrame(history)

    # Get hyperparameters from the run's config
    config = run.config

    # --- THE CORE NORMALIZATION STEP ---
    # Calculate total tokens seen at each step
    history_df['tokens_seen'] = history_df['step'] * config['batch_size'] * config['seq_len'] * 900

    # Clean up data: drop rows where the metric might be NaN
    history_df.dropna(subset=[METRIC_NAME, 'tokens_seen'], inplace=True)
    
    # Store data for plotting
    all_plot_data.append({
        'x': history_df['tokens_seen'],
        'y': history_df[METRIC_NAME],
        'label': f"BS={config['batch_size']}" # Create a nice label for the legend
    })
    
    print(f"Processed run: {run.name} (Batch Size: {config['batch_size']})")

# Sort the plots by batch size for a cleaner legend
all_plot_data.sort(key=lambda d: int(d['label'].split('=')[1]))

for data in all_plot_data:
    ax.plot(data['x'], data['y'], label=data['label'])

# --- 6. FORMAT THE PLOT ---
ax.set_title("Token-Normalized Loss vs. Batch Size", fontsize=16)
ax.set_xlabel("Total Tokens Seen", fontsize=12)
ax.set_ylabel(METRIC_NAME, fontsize=12)
ax.set_yscale('log')  # Loss is often best viewed on a log scale
ax.legend(title="Batch Size")
ax.grid(True, which="both", linestyle='--', linewidth=0.5)

# Use scientific notation for the x-axis for better readability
formatter = mticker.ScalarFormatter(useMathText=True)
formatter.set_powerlimits((-1, 6))
ax.xaxis.set_major_formatter(formatter)

plt.tight_layout()
plt.savefig("token_normalized_loss_plot.png", dpi=300)
plt.show()

print("
Plot saved as token_normalized_loss_plot.png")
[terminal_command] TERMINAL ()
salloc --nodes=2 --ntasks-per-node=4 --gres=gpu:4 --cpus-per-task=8 --time=9:00:00 --partition=accelerated --account=hk-project-p0023960salloc: Granted job allocation 3359184salloc: Waiting for resource configurationsalloc: Nodes hkn[0430-0431] are ready for job[tum_dbd0378@hkn0430 jafar]$ salloc: Job 3359184 has exceeded its time limit and its allocation has been revoked.                                 srun: Job step aborted: Waiting up to 32 seconds for job step to finish.slurmstepd: error: *** STEP 3359184.interactive ON hkn0430 CANCELLED AT 2025-07-19T19:06:27 DUE TO TIME LIMIT ***srun: error: hkn0430: task 0: Killed