Fix modelopt FP8 create weights (#18447)
Signed-off-by: root <dafrimi@nvidia.com>
This commit is contained in:
@@ -461,6 +461,8 @@ class ModelOptFp8LinearMethod(LinearMethodBase):
|
|||||||
layer: torch.nn.Module,
|
layer: torch.nn.Module,
|
||||||
input_size_per_partition: int,
|
input_size_per_partition: int,
|
||||||
output_partition_sizes: List[int],
|
output_partition_sizes: List[int],
|
||||||
|
input_size: Optional[int],
|
||||||
|
output_size: Optional[int],
|
||||||
params_dtype: torch.dtype,
|
params_dtype: torch.dtype,
|
||||||
**extra_weight_attrs,
|
**extra_weight_attrs,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|||||||
@@ -633,7 +633,12 @@ class NemotronHForCausalLM(nn.Module):
|
|||||||
}
|
}
|
||||||
|
|
||||||
remap_prefix = {"backbone": "model"}
|
remap_prefix = {"backbone": "model"}
|
||||||
remap_substr = {"A_log": "A", "embeddings": "embed_tokens"}
|
remap_substr = {
|
||||||
|
"A_log": "A",
|
||||||
|
"embeddings": "embed_tokens",
|
||||||
|
"k_proj.k_scale": "attn.k_scale",
|
||||||
|
"v_proj.v_scale": "attn.v_scale",
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -645,6 +650,7 @@ class NemotronHForCausalLM(nn.Module):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
lora_config = None
|
lora_config = None
|
||||||
self.config = config
|
self.config = config
|
||||||
|
self.quant_config = quant_config
|
||||||
self.model = self._init_model(
|
self.model = self._init_model(
|
||||||
config=config, quant_config=quant_config, prefix=prefix
|
config=config, quant_config=quant_config, prefix=prefix
|
||||||
)
|
)
|
||||||
@@ -776,9 +782,10 @@ class NemotronHForCausalLM(nn.Module):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if "scale" in name:
|
if "scale" in name:
|
||||||
name = maybe_remap_kv_scale_name(name, params_dict)
|
if name not in params_dict:
|
||||||
if name is None:
|
name = maybe_remap_kv_scale_name(name, params_dict)
|
||||||
continue
|
if name is None:
|
||||||
|
continue
|
||||||
|
|
||||||
layer_id = get_layer_id(name)
|
layer_id = get_layer_id(name)
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user