Add learned spline sweep#834
Open
klei22 wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
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_activationtoGPTConfigandtrain_args.pyCLI, with validation to prevent invalid/recursive choices. - Update
LearnedSplineActivationinitialization to use a user-selected activation to initialize spline knoty_vals. - Add an experiment sweep YAML and a new Plotly-based analysis script to visualize learned spline curves; add
plot_bars_trimwrapper 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 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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
LearnedSplineActivationconfigurable via the newlsa_init_activationparameter inGPTConfigand 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:
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.yamlexplorations/default_inf_lsa_init_mlp_swiglu.yamlR1-R57)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.pyanalysis/activation_analysis/plot_learned_splines.pyR1-R250)Plotting Utility Enhancements:
plot_bars_trimfunction as a wrapper for the multi-metric bar plotting utility, improving usability for single-metric plots. (plot_view.pyplot_view.pyR433-R449)Most important changes:
Learned Spline Activation Initialization:
lsa_init_activationtoGPTConfigand 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:
explorations/default_inf_lsa_init_mlp_swiglu.yamlto enable sweeps over different spline initialization activations.analysis/activation_analysis/plot_learned_splines.pyfor interactive visualization of learned spline activations from checkpoints.Plotting Utilities:
plot_bars_trimas a single-metric wrapper for the trimmed multi-bar plotting function.