Skip to content

Slimmable interface and SlimmableContainer#242

Open
jfsantos wants to merge 2 commits intosdatkinson:mainfrom
jfsantos:feature/slimmable-interface
Open

Slimmable interface and SlimmableContainer#242
jfsantos wants to merge 2 commits intosdatkinson:mainfrom
jfsantos:feature/slimmable-interface

Conversation

@jfsantos
Copy link
Contributor

@jfsantos jfsantos commented Mar 9, 2026

  1. Slimmable interface on DSP base class (NAM/dsp.h)

Added virtual void SetSlimmableSize(const double val) to DSP. Default is a no-op. val ranges from 0.0 (minimum size) to 1.0 (maximum size).
Subclasses override this to reduce computational cost in a model-specific way.

  1. ContainerModel (NAM/container.h, NAM/container.cpp)

A new ContainerModel class that uses the slimmable interface to switch between multiple complete DSP models at different quality tiers.

  • Submodel selection: SetSlimmableSize(val) picks the first submodel whose max_value >= val, then always calls ResetAndPrewarm() on it so it's
    immediately ready for process().
  • Delegation: process() forwards to the active submodel. Reset() resets all submodels. prewarm() prewarms all submodels.
  • Validation (constructor): submodels must be non-empty, sorted by ascending max_value, the last must cover 1.0, and all must agree on sample rate.
  • Registration: auto-registered as "SlimmableContainer" architecture via ConfigParserHelper.

The NAM file format nests full model specs inside config.submodels[].model, with an empty top-level weights array.

  1. Example file (example_models/slimmable_container.nam)

A 3-tier container using lstm.nam (small, max_value=0.33), wavenet.nam (medium, max_value=0.66), and nano_relu.nam (large, max_value=1.0).

  1. Tests (tools/test/test_container.cpp, wired into tools/run_tests.cpp)

10 tests covering:

  • Loading from JSON and from .nam file
  • Audio processing produces finite output
  • SetSlimmableSize selects different submodels (verified by differing output)
  • Boundary value selection (exact max_value thresholds)
  • Default active model is the largest (max size)
  • Error cases: empty submodels, last max_value < 1.0, unsorted submodels, sample rate mismatch

Developed with support and sponsorship from TONE3000

@jfsantos jfsantos force-pushed the feature/slimmable-interface branch from 3650ca5 to 91efeb0 Compare March 9, 2026 18:10
@jfsantos
Copy link
Contributor Author

jfsantos commented Mar 9, 2026

Integration tests failed for some reason but that seems to be unrelated to anything I implemented here. Investigating.

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.

1 participant