Skip to content

vllm.models.mistral.mistral_large4.amd.specialized_decode.mono.geometry_config

ML4's own geometry, and the widths its kernel is built for.

The vocabulary these are expressed in -- LayerConfig, MoeMode, the weight and cache layouts -- is model-free and lives in vllm.models.mistral.mistral_large4.amd.specialized_decode.mono.common.weights.config; what is ML4's alone is here. The shared names are re-exported, so a kernel source taking both from one place need not care which is which.

Functions:

ml4_kernel_samples(samples, query_length)

Choose an LDS-safe request-aligned launch width.

Source code in vllm/models/mistral/mistral_large4/amd/specialized_decode/mono/geometry_config.py
def ml4_kernel_samples(samples: int, query_length: int) -> int:
    """Choose an LDS-safe request-aligned launch width."""
    if query_length not in ML4_QUERY_LENGTHS or samples % query_length:
        raise ValueError(
            f"unsupported ML4 decode shape samples={samples}, query_length={query_length}"
        )
    for chunk in reversed(ML4_KERNEL_SAMPLES):
        if chunk % query_length == 0 and samples % chunk == 0:
            return chunk
    raise ValueError(
        f"no ML4 kernel chunk for samples={samples}, query_length={query_length}"
    )

ml4_tp_config(tp_size)

Return the one ML4 shard geometry for tp_size.

Source code in vllm/models/mistral/mistral_large4/amd/specialized_decode/mono/geometry_config.py
def ml4_tp_config(tp_size: int) -> LayerConfig:
    """Return the one ML4 shard geometry for `tp_size`."""
    if tp_size not in ML4_TP_SIZES:
        raise ValueError(
            f"ML4 tensor parallel size must be one of {ML4_TP_SIZES}, got {tp_size}"
        )
    return replace(
        ML4_CONFIG,
        local_heads=ML4_GLOBAL_HEADS // tp_size,
        inter=ML4_GLOBAL_INTER // tp_size,
    )

validate_shard(samples, heads, rank, npes, sparse_attention_topk, model_config=ML4_CONFIG, supported_samples=SUPPORTED_SAMPLES, expected_heads=None)

Validate one model profile before allocating GPU buffers.

Source code in vllm/models/mistral/mistral_large4/amd/specialized_decode/mono/geometry_config.py
def validate_shard(
    samples: int,
    heads: int,
    rank: int,
    npes: int,
    sparse_attention_topk: int,
    model_config: LayerConfig | str = ML4_CONFIG,
    supported_samples=SUPPORTED_SAMPLES,
    expected_heads: int | None = None,
) -> None:
    """Validate one model profile before allocating GPU buffers."""
    config = as_layer_config(model_config)
    if samples not in supported_samples:
        raise ValueError(f"samples must be one of {supported_samples}, got {samples}")
    expected_heads = config.local_heads if expected_heads is None else expected_heads
    if heads != expected_heads:
        raise ValueError(
            f"{config.name} requires {expected_heads} local heads, got {heads}"
        )
    if npes not in SUPPORTED_PEERS:
        raise ValueError(f"npes must be one of {SUPPORTED_PEERS}, got {npes}")
    if not 0 <= rank < npes:
        raise ValueError(f"rank must be in [0, {npes}), got {rank}")
    if sparse_attention_topk <= 0 or sparse_attention_topk % 64:
        raise ValueError(
            "sparse_attention_topk must be a positive multiple of 64, "
            f"got {sparse_attention_topk}"
        )