File size: 713 Bytes
7b6f2cc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | """Frozen CPU projection profiles for the native Portuguese readout trainer."""
from inference.mixed_precision import FP32Linear
PROFILES = ("checkpoint", "fp32-head-and-8-mlps")
def configure_cpu_projections(model, profile, check_resources):
if profile == "checkpoint":
return
blocks = [getattr(layer, "base", layer) for layer in model.model.layers.layers]
model.lm_head.base = FP32Linear(model.lm_head.base)
check_resources()
for index, block in enumerate(blocks):
if index < 6 or index >= len(blocks) - 2:
block.mlp.gate_up_proj = FP32Linear(block.mlp.gate_up_proj)
block.mlp.down_proj = FP32Linear(block.mlp.down_proj)
check_resources()
|