Takt API

Core transformation engine for applying PEFT adapters to models.

class taktiny.takt.Takt[source]

Bases: Generic

Apply adapter objects to existing Taktiny models.

classmethod apply_adapter(model, adapter)[source]

Inject adapter into all of its matching modules in model.

Existing model parameters are frozen. Parameters created by adapter modules remain trainable, so the trainer only needs to honor the normal Parameter.trainable flag. Adapter objects are retained as static model metadata for optional post-step updates.

Return type:

TypeVar(M)

Parameters:
  • model (M)

  • adapter (AdapterBase)

classmethod update_adapters(model, **kwargs)[source]

Run each applied adapter’s optional post-step update hook.

This is independent of any trainer. A trainer may call this method after its normal optimizer update and provide the context required by an adapter such as AdaLoRA.

Return type:

tuple[Any, ...]

Parameters:
  • model (M)

  • kwargs (Any)