wf_sweep Module

Sweep management: configuration builder, sweep registration, and agents. Builder for a wandb sweep configuration.

Build the configuration with the type-bound procedures, then pass it directly to wandb_sweep or call to_json() for the raw string.

Example

type(wandb_sweep_config_type) :: cfg

call cfg%set_method("bayes")
call cfg%set_metric("val_loss", "minimize")

call cfg%add_param_range("learning_rate", 1e-5_real64, 1e-2_real64, &
                          distribution="log_uniform_values")
call cfg%add_param_values("hidden_size", [32, 64, 128, 256])
call cfg%add_param_values("activation", ["relu   ", "tanh   ", "sigmoid"])

call wandb_sweep(cfg, project="my-project", sweep_id=id)

Register a sweep — accepts either a raw JSON string or a wandb_sweep_config_type built with the helper API.



Interfaces

public interface wandb_sweep

  • private subroutine wandb_sweep_json_str(config_json, project, sweep_id, entity)

    Register a hyperparameter sweep with wandb.

                    parameters).
    

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: config_json

    JSON string describing the sweep (method, metric,

    character(len=*), intent(in) :: project

    wandb project name.

    character(len=*), intent(out) :: sweep_id

    Output: the sweep ID string assigned by wandb.

    character(len=*), intent(in), optional :: entity

    Optional wandb entity/team.

  • private subroutine wandb_sweep_cfg_obj(config, project, sweep_id, entity)

    Register a sweep from a wandb_sweep_config_type builder object.

    Arguments

    Type IntentOptional Attributes Name
    type(wandb_sweep_config_type), intent(in) :: config
    character(len=*), intent(in) :: project
    character(len=*), intent(out) :: sweep_id
    character(len=*), intent(in), optional :: entity

Derived Types

type, public ::  wandb_sweep_config_type

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: method_str
character(len=:), public, allocatable :: metric_goal_str
character(len=:), public, allocatable :: metric_name_str
integer, public :: num_params = 0
character(len=:), public, allocatable :: params_buf

Type-Bound Procedures

generic, public :: add_param_range => add_range_r32, add_range_r64
generic, public :: add_param_values => add_vals_int, add_vals_r32, add_vals_r64, add_vals_str
procedure, public :: set_method => swcfg_set_method
procedure, public :: set_metric => swcfg_set_metric
procedure, public :: to_json => swcfg_to_json

Subroutines

public subroutine wandb_agent(sweep_id, project, count, entity)

Run a wandb sweep agent.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: sweep_id

Sweep ID returned by wandb_sweep.

character(len=*), intent(in) :: project

wandb project name.

integer, intent(in), optional :: count

Number of runs to execute (0 = until sweep is done).

character(len=*), intent(in), optional :: entity

Optional wandb entity/team.

public subroutine wandb_sweep_next_params(params_json, timeout_s)

Block until the sweep agent has started the next run and populated wandb.config with the sweep-sampled hyperparameters.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(out) :: params_json

Receives the sampled hyperparameters as a JSON

real(kind=c_double), intent(in), optional :: timeout_s

Seconds to wait before giving up (default: 120.0).

public subroutine wandb_sweep_run_done()

Signal that the current sweep run's training is finished.

Read more…

Arguments

None

public subroutine wandb_sweep_start_agent(sweep_id, project, count, entity)

Start a wandb sweep agent in a background Python thread.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: sweep_id
character(len=*), intent(in) :: project
integer, intent(in) :: count
character(len=*), intent(in), optional :: entity