dkappe commited on
Commit
0673dbc
·
verified ·
1 Parent(s): 63cab1e

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -109,13 +109,17 @@ def _load() -> dict:
109
  config = TransformerConfig.from_saved(saved)
110
  raw_params = {k: v for k, v in ckpt["params"].items() if not k.startswith("mtp_")}
111
 
112
- # The published checkpoint is bf16. JAX on this GPU aborts with
113
- # "Unsupported conversion from bf16 to f16 / LLVM ERROR: Unsupported
114
- # rounding mode for conversion."
115
- # so cast everything to float32 up front. NEEDLE_CAST controls this
116
- # ("float32" default, "bfloat16" to keep the original, "none" to skip).
 
 
117
  _cast = os.environ.get("NEEDLE_CAST", "float32").lower()
118
  if _cast in ("float32", "float", "f32"):
 
 
119
  params = {k: (v.astype("float32") if hasattr(v, "astype") else v)
120
  for k, v in raw_params.items()}
121
  else:
 
109
  config = TransformerConfig.from_saved(saved)
110
  raw_params = {k: v for k, v in ckpt["params"].items() if not k.startswith("mtp_")}
111
 
112
+ # The published checkpoint declares dtype=bfloat16, and TransformerConfig builds
113
+ # every layer with that dtype. JAX on this GPU aborts on bf16->f16 conversions:
114
+ # "Unsupported conversion from bf16 to f16 /
115
+ # LLVM ERROR: Unsupported rounding mode for conversion."
116
+ # Casting the PARAMS alone does not help -- the model's own dtype must change too,
117
+ # so set it on the config BEFORE constructing the network.
118
+ # NEEDLE_CAST: "float32" (default) | "bfloat16" (original) | "none"
119
  _cast = os.environ.get("NEEDLE_CAST", "float32").lower()
120
  if _cast in ("float32", "float", "f32"):
121
+ # TransformerConfig is a plain @dataclass (no .replace()), so assign directly.
122
+ config.dtype = "float32"
123
  params = {k: (v.astype("float32") if hasattr(v, "astype") else v)
124
  for k, v in raw_params.items()}
125
  else: