mstar.model.command_a_plus.components.vision#

Command A+’s image encoder: a SigLIP tower, a pixel shuffle and a SwiGLU projector.

Tiles are all image_size square, so they batch as plain [tiles, patches, width].

Classes

CommandAPlusProjector(config, text_hidden_size)

Merges each downsample_factor-square block of patches into one LLM token.

CommandAPlusVisionEncoder(config, ...)

Image tiles in, one LLM-width embedding per <|IMG_PATCH|> token out.

SiglipAttention(config)

SiglipEmbeddings(config)

SiglipLayer(config)

SiglipMLP(config)

class mstar.model.command_a_plus.components.vision.CommandAPlusProjector(config, text_hidden_size)[source]#

Bases: Module

Merges each downsample_factor-square block of patches into one LLM token.

Parameters:
forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:

x (Tensor)

Return type:

Tensor

pixel_shuffle(x)[source]#
Parameters:

x (Tensor)

Return type:

Tensor

class mstar.model.command_a_plus.components.vision.CommandAPlusVisionEncoder(config, text_hidden_size)[source]#

Bases: Module

Image tiles in, one LLM-width embedding per <|IMG_PATCH|> token out.

Parameters:
forward(pixel_values)[source]#

[tiles, 3, size, size] to [tiles * tokens_per_tile, text_hidden], tile-major.

Parameters:

pixel_values (Tensor)

Return type:

Tensor

load_weights(weights)[source]#

Strict: a missing, unexpected or misshaped weight fails.

Parameters:

weights (Iterable[tuple[str, Tensor]])

Return type:

None

class mstar.model.command_a_plus.components.vision.SiglipAttention(config)[source]#

Bases: Module

Parameters:

config (CommandAPlusVisionConfig)

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:

x (Tensor)

Return type:

Tensor

class mstar.model.command_a_plus.components.vision.SiglipEmbeddings(config)[source]#

Bases: Module

Parameters:

config (CommandAPlusVisionConfig)

forward(pixel_values)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:

pixel_values (Tensor)

Return type:

Tensor

class mstar.model.command_a_plus.components.vision.SiglipLayer(config)[source]#

Bases: Module

Parameters:

config (CommandAPlusVisionConfig)

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:

x (Tensor)

Return type:

Tensor

class mstar.model.command_a_plus.components.vision.SiglipMLP(config)[source]#

Bases: Module

Parameters:

config (CommandAPlusVisionConfig)

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:

x (Tensor)

Return type:

Tensor