""" Resume script for Qwen3 variance analysis. Only runs the 2 experiments interrupted by job 2033368: nr128_blTrue, nr128_blFalse Then merges with the 10 completed results from the killed run and saves/plots. """ import json import os import sys # Reuse everything from the original script sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from qwen3_variance_analysis_auto import ( ROLLOUT_NUMS, OUTPUT_DIR, worker_init, run_single_experiment, plot_results, ) import torch.multiprocessing as mp # Results already completed in job 2033368 (extracted from log) COMPLETED_RESULTS = { "nr4_blFalse": {"mean": 2.453292e-01, "std": 8.433693e-02}, "nr4_blTrue": {"mean": 1.544762e-01, "std": 5.542017e-02}, "nr8_blTrue": {"mean": 1.679264e-01, "std": 5.820824e-02}, "nr8_blFalse": {"mean": 2.190761e-01, "std": 7.012213e-02}, "nr16_blFalse": {"mean": 2.448343e-01, "std": 7.550860e-02}, "nr16_blTrue": {"mean": 2.075920e-01, "std": 6.842490e-02}, "nr32_blTrue": {"mean": 1.788574e-01, "std": 5.623576e-02}, "nr32_blFalse": {"mean": 2.002312e-01, "std": 5.805813e-02}, "nr64_blFalse": {"mean": 1.702958e-01, "std": 5.899355e-02}, "nr64_blTrue": {"mean": 1.592376e-01, "std": 5.725100e-02}, } # Only need to run these 2 REMAINING_TASKS = [ (128, True), # nr128_blTrue (128, False), # nr128_blFalse ] def main(): os.makedirs(OUTPUT_DIR, exist_ok=True) print(f"Resuming: {len(REMAINING_TASKS)} experiments on 2 GPUs") gpu_queue = mp.Queue() for gid in [0, 1]: gpu_queue.put(gid) with mp.Pool( processes=2, initializer=worker_init, initargs=(gpu_queue,), ) as pool: new_results_list = pool.map(run_single_experiment, REMAINING_TASKS) # Merge results = dict(COMPLETED_RESULTS) results.update(dict(new_results_list)) # Save results_path = os.path.join(OUTPUT_DIR, "results.json") with open(results_path, "w") as f: json.dump(results, f, indent=2) print(f"Results saved to {results_path}") # Plot plot_results(results, OUTPUT_DIR) print("All done!") if __name__ == "__main__": mp.set_start_method("spawn") main()