performance_tuning ================== .. py:module:: performance_tuning .. autoapi-nested-parse:: Quick performance benchmark for GFlowNet training. Runs per-iteration timing across environments (HyperGrid, DiffusionSampling, DiscreteEBM), losses (TB, SubTB, ModifiedDB), debug on/off, and torch.compile on/off (compiling the standard sampling loop when possible). Produces a bar plot saved to ~/performance_tuning.png. Attributes ---------- .. autoapisummary:: performance_tuning.LR performance_tuning.LR_LOGF performance_tuning.LR_LOGZ Classes ------- .. autoapisummary:: performance_tuning.BenchmarkConfig performance_tuning.BenchmarkResult performance_tuning.BenchmarkSettings Functions --------- .. autoapisummary:: performance_tuning.build_components performance_tuning.main performance_tuning.make_step_fn performance_tuning.maybe_compile performance_tuning.plot_results performance_tuning.resolve_device performance_tuning.run_benchmark performance_tuning.run_benchmarks performance_tuning.synchronize performance_tuning.time_iterations Module Contents --------------- .. py:class:: BenchmarkConfig .. py:attribute:: debug :type: bool .. py:attribute:: env_name :type: str .. py:property:: label :type: str .. py:attribute:: loss_name :type: str .. py:attribute:: use_compile :type: bool .. py:class:: BenchmarkResult .. py:attribute:: compiled :type: bool .. py:attribute:: config :type: BenchmarkConfig .. py:attribute:: elapsed :type: float .. py:attribute:: env_name :type: str .. py:attribute:: mean_iter_ms :type: float .. py:attribute:: reason :type: str | None :value: None .. py:attribute:: skipped :type: bool .. py:attribute:: std_iter_ms :type: float .. py:class:: BenchmarkSettings .. py:attribute:: batch_size :type: int :value: 32 .. py:attribute:: deterministic_mode :type: bool :value: False .. py:attribute:: device :type: str :value: 'cpu' .. py:attribute:: n_iters :type: int :value: 200 .. py:attribute:: output_path :type: pathlib.Path | None .. py:attribute:: warmup_iters :type: int :value: 50 .. py:data:: LR :value: 0.001 .. py:data:: LR_LOGF :value: 0.001 .. py:data:: LR_LOGZ :value: 0.1 .. py:function:: build_components(env_name, loss_name, debug, device) Create env, gflownet, optimizer for a given setup. .. py:function:: main() .. py:function:: make_step_fn(env, gflownet, optimizer, batch_size, device) .. py:function:: maybe_compile(fn) .. py:function:: plot_results(results, output_path = None, return_fig = False) .. py:function:: resolve_device(requested = 'auto') .. py:function:: run_benchmark(config, device, settings) .. py:function:: run_benchmarks(settings, *, return_fig = False, verbose = False) .. py:function:: synchronize(device) .. py:function:: time_iterations(step_fn, device, warmup, n_iters)