Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
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
|
| 113 |
-
#
|
| 114 |
-
#
|
| 115 |
-
#
|
| 116 |
-
#
|
|
|
|
|
|
|
| 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:
|