Skip to content

Add learned spline sweep#834

Open
klei22 wants to merge 4 commits into
ReaLLMASIC:masterfrom
klei22:add-learned-spline-sweep
Open

Add learned spline sweep#834
klei22 wants to merge 4 commits into
ReaLLMASIC:masterfrom
klei22:add-learned-spline-sweep

Conversation

@klei22

@klei22 klei22 commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces a configurable initialization for the learned spline activation function, allowing users to specify which activation function is used to initialize the spline's knot y-values. Previously, the initialization was hardcoded to GELU. The changes span configuration, argument parsing, activation implementation, and experiment setup, and also introduce a new analysis script for visualizing learned splines.

Learned Spline Activation Initialization Improvements:

  • Made the initialization activation for LearnedSplineActivation configurable via the new lsa_init_activation parameter in GPTConfig and command-line arguments. This allows users to select from several activation functions (e.g., "gelu", "mish", "silu", etc.) for initializing the spline knots, rather than always using GELU. It also prevents recursive or invalid selections (e.g., "learned_spline" itself). (gpt_conf.py [1] train_args.py [2] [3] variations/activation_variations.py [4]

Experiment and Analysis Tools:

  • Added a new experiment YAML file, explorations/default_inf_lsa_init_mlp_swiglu.yaml, to sweep over different initialization activations for learned splines in a specific model configuration. (explorations/default_inf_lsa_init_mlp_swiglu.yaml explorations/default_inf_lsa_init_mlp_swiglu.yamlR1-R57)
  • Introduced a new script, analysis/activation_analysis/plot_learned_splines.py, for interactively visualizing learned spline activations from checkpoints. This script reconstructs spline curves from checkpoint parameters and generates an HTML plot with adjustable x-axis controls. (analysis/activation_analysis/plot_learned_splines.py analysis/activation_analysis/plot_learned_splines.pyR1-R250)

Plotting Utility Enhancements:

  • Added a backward-compatible plot_bars_trim function as a wrapper for the multi-metric bar plotting utility, improving usability for single-metric plots. (plot_view.py plot_view.pyR433-R449)

Most important changes:

Learned Spline Activation Initialization:

  • Added lsa_init_activation to GPTConfig and CLI arguments, allowing users to select the activation function for initializing spline knot y-values and ensuring invalid choices are rejected. [1] [2] [3] [4]

Experiment/Analysis Tools:

  • Added explorations/default_inf_lsa_init_mlp_swiglu.yaml to enable sweeps over different spline initialization activations.
  • Introduced analysis/activation_analysis/plot_learned_splines.py for interactive visualization of learned spline activations from checkpoints.

Plotting Utilities:

  • Added plot_bars_trim as a single-metric wrapper for the trimmed multi-bar plotting function.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the initialization of LearnedSplineActivation configurable (instead of hardcoded GELU) by introducing lsa_init_activation across config + CLI parsing, and adds tooling to sweep and visualize learned spline activations.

Changes:

  • Add lsa_init_activation to GPTConfig and train_args.py CLI, with validation to prevent invalid/recursive choices.
  • Update LearnedSplineActivation initialization to use a user-selected activation to initialize spline knot y_vals.
  • Add an experiment sweep YAML and a new Plotly-based analysis script to visualize learned spline curves; add plot_bars_trim wrapper for trimmed single-metric bar plots.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
variations/activation_variations.py Makes learned spline knot initialization activation configurable and validates selection.
train_args.py Adds --lsa_init_activation CLI arg and excludes learned_spline from valid init choices.
gpt_conf.py Adds lsa_init_activation field to GPTConfig.
explorations/default_inf_lsa_init_mlp_swiglu.yaml Adds a sweep over multiple lsa_init_activation values for learned spline runs.
analysis/activation_analysis/plot_learned_splines.py New script to load checkpoints and plot reconstructed spline curves as interactive HTML.
plot_view.py Adds plot_bars_trim wrapper that delegates to the trimmed multi-bar implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plot_view.py
Comment on lines +445 to +447
if not label_cols:
raise ValueError("Need ≥1 label column for bar chart")
plot_multi_bars_trim(rows, y_cols=[y], label_cols=label_cols)
Comment on lines +17 to +18
def _load_state_dict(checkpoint_path: Path):
ckpt = torch.load(checkpoint_path, map_location="cpu", weights_only=False)
Comment on lines +20 to +27
# Common checkpoint layouts in this repo:
# 1) {'model': state_dict, ...}
# 2) raw state_dict
if isinstance(ckpt, dict) and "model" in ckpt and isinstance(ckpt["model"], dict):
return ckpt["model"]
if isinstance(ckpt, dict):
return ckpt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants