Dsxir.Optimizer.MIPROv2.Candidates (dsxir v0.2.0)

Copy Markdown

Builds the categorical search space for MIPROv2 and the lookup table that maps {predictor_name, dim, index} back to the actual instruction string or demo bundle.

Each predictor contributes two categorical dimensions:

  • {name, :instruction} ranging over indices 0..N, where index 0 is the current instruction (possibly nil) and indices 1..N are proposed instruction strings.
  • {name, :demos} ranging over indices 0..M, where index 0 is an empty demo bundle ([]) and indices 1..M are candidate demo bundles.

Summary

Functions

Build the space and lookup from per-predictor proposed instruction lists and demo bundle lists.

Resolve a sampled config into a map of predictor_name => %{instruction: string | nil, demos: [demo]} using the lookup table built by build/3.

Types

lookup()

@type lookup() :: %{
  required({atom(), :instruction}) => %{
    required(non_neg_integer()) => String.t() | nil
  },
  required({atom(), :demos}) => %{
    required(non_neg_integer()) => [Dsxir.Demo.t()]
  }
}

t()

@type t() :: %Dsxir.Optimizer.MIPROv2.Candidates{
  lookup: lookup(),
  space: Dsxir.Optimizer.Search.Sampler.space()
}

Functions

build(current_instructions, proposed_instructions, demo_bundles)

@spec build(
  current_instructions :: %{required(atom()) => String.t() | nil},
  proposed_instructions :: %{required(atom()) => [String.t()]},
  demo_bundles :: %{required(atom()) => [[Dsxir.Demo.t()]]}
) :: t()

Build the space and lookup from per-predictor proposed instruction lists and demo bundle lists.

current_instructions%{predictor_name => current_instruction | nil}. proposed_instructions%{predictor_name => [proposed_instruction]}. demo_bundles%{predictor_name => [bundle]} where each bundle is a list of Dsxir.Demo.t().

The current instruction (nil if not set) is prepended at index 0 of each predictor's instruction list; an empty demo bundle ([]) is prepended at index 0 of each predictor's demo list.

resolve(candidates, config)

@spec resolve(t(), Dsxir.Optimizer.Search.Sampler.config()) :: %{
  required(atom()) => %{instruction: String.t() | nil, demos: [Dsxir.Demo.t()]}
}

Resolve a sampled config into a map of predictor_name => %{instruction: string | nil, demos: [demo]} using the lookup table built by build/3.