mirror of
https://github.com/FlashML-org/FreeToken.git
synced 2026-11-25 21:07:55 +08:00
* feat(qwen3_5_moe): read every checkpoint layout through the QuantConfig NVFP4 dense layers now declare the input_scale their scheme carries, so an FTW written by an older build from an NVFP4 dense checkpoint needs scripts/ftw_hotfix.py before it loads again. * fix(quant): address scheme reader review: hotfix dialect names, gemma4 cross-shard scales, ct block-fp8 experts
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Any, ClassVar
|
|
|
|
from ..names import name_set
|
|
from ..registry import register_dialect
|
|
from ..scheme import QuantKind, QuantScheme
|
|
from ..scheme import mxfp4_scheme
|
|
from .base import QuantConfig, Stored
|
|
|
|
|
|
@register_dialect
|
|
class Mxfp4Config(QuantConfig):
|
|
"""gpt-oss: the stacked ``experts`` containers are MXFP4 with biases, everything else bf16."""
|
|
|
|
dialect = "mxfp4"
|
|
|
|
SCHEME: ClassVar[QuantScheme] = mxfp4_scheme()
|
|
# the experts are stacked per layer (``gate_up_proj_blocks`` / ``_scales``), not per-Linear tensors; gpt_oss reads them itself
|
|
STORAGE: ClassVar[dict[QuantKind, dict[str, str | Stored]]] = {}
|
|
|
|
def __init__(self, q: dict[str, Any], hf_config: Any = None, *, name_map=None, unquantized=()):
|
|
super().__init__(name_map, unquantized)
|
|
self.not_convert = name_set(tuple(q.get("modules_to_not_convert") or ()))
|
|
|
|
def scheme_for_name(self, name: str) -> QuantScheme | None:
|
|
if not name.endswith(".experts") or self.not_convert(name):
|
|
return None
|
|
return self.SCHEME
|