02-loss-scaling fixed one specific failure mode (gradients underflowing during backward), but it didn't answer a more basic question: should EVERY operation in a model actually run in float16? 01-fp16-bf16-representable-range already showed float16 has real numerical hazards — running every single op at reduced precision would hit those hazards constantly, especially in operations that sum many values or exponentiate a wide range of numbers.
Implement should_run_in_fp16(op_name), which classifies a named operation as safe for float16 or requiring float32, and autocast_dtype_for(op_name), which turns that classification directly into a dtype string.
should_run_in_fp16 returns True for matmul-family ops (matmul, linear, conv2d, relu), False for reduction/normalization ops (softmax, log_softmax, layer_norm, batch_norm, cross_entropy, sum, mean, exp, log).ValueError.autocast_dtype_for returns "float16" or "float32" directly, built on should_run_in_fp16.Open one at a time. Each gives away a little more than the last.
Two fixed sets of known op names is all the "classification" here really is — no clever heuristic, just a lookup against two explicit lists.
Check the _FP32_REQUIRED_OPS set first: if an op is in neither set, it's genuinely unknown and should raise, not silently default to one side or the other.
No results yet
Run your code to check it against the examples, or submit to run every test.