luxfer / runtime /training /readout_cpu.py
mdxss's picture
Publish Luxfer early beta with runnable weights and language metadata
7b6f2cc verified
Raw History Blame Contribute Delete
713 Bytes
"""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()