IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Python class

WeightTransform

WeightTransform​

class max.pipelines.lib.WeightTransform(rules)

source

Bases: object

Maps a checkpoint’s weights onto the names and dtypes a graph loads.

Each checkpoint weight goes through the rules in order, and each rule sees the name the rules before it produced. An Ignore drops the weight and ends its rules. A weight that no rule touches keeps its name. No rule copies data: the adapted weights are views of the checkpoint’s.

A transform holds only patterns and plain values, so it serializes to plain data and back. Patterns stay within the syntax Python’s re shares with Rust’s regex crate, so Mach can apply the same rules: look-around and back-references are refused.

Parameters:

rules (Sequence[WeightRenaming | Bitcast | Ignore]) – The rules, in the order they apply.

apply_data()​

apply_data(weights)

source

Applies the rules to already materialized checkpoint weights.

This lets config finalization inspect original checkpoint names before the same serializable transform prepares module weights.

Parameters:

weights (Mapping[str, WeightData])

Return type:

dict[str, WeightData]

rules​

rules: Sequence[WeightRenaming | Bitcast | Ignore]

source

The rules, in the order they apply.