Swordnael commited on
Commit
1ffab97
·
verified ·
1 Parent(s): 0727dc5

Require native BF16 capability in structural smoke

Browse files
training/run_fable_router_structural_smoke.py CHANGED
@@ -142,14 +142,21 @@ def gpu_facts(minimum_vram_gib: float) -> dict[str, Any]:
142
  total_gib = properties.total_memory / 2**30
143
  if total_gib < minimum_vram_gib:
144
  raise RuntimeError(f"GPU has {total_gib:.2f} GiB, requires at least {minimum_vram_gib:.2f} GiB")
 
 
145
  return {
146
  "name": properties.name,
147
  "totalVramGiB": total_gib,
148
- "capability": list(torch.cuda.get_device_capability(0)),
149
- "bf16Supported": bool(torch.cuda.is_bf16_supported()),
 
150
  }
151
 
152
 
 
 
 
 
153
  def upload_evidence(output: Path, repo_id: str, token: str) -> dict[str, Any]:
154
  api = HfApi(token=token)
155
  api.create_repo(repo_id, repo_type="dataset", private=True, exist_ok=True)
@@ -245,7 +252,7 @@ def run(args: argparse.Namespace, result: dict[str, Any]) -> None:
245
  }
246
 
247
  device = torch.device("cuda:0")
248
- dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16
249
  torch.cuda.reset_peak_memory_stats(device)
250
  load_started = time.perf_counter()
251
  model = AutoModelForCausalLM.from_pretrained(
 
142
  total_gib = properties.total_memory / 2**30
143
  if total_gib < minimum_vram_gib:
144
  raise RuntimeError(f"GPU has {total_gib:.2f} GiB, requires at least {minimum_vram_gib:.2f} GiB")
145
+ capability = torch.cuda.get_device_capability(0)
146
+ native_bf16 = capability[0] >= 8 and bool(torch.cuda.is_bf16_supported())
147
  return {
148
  "name": properties.name,
149
  "totalVramGiB": total_gib,
150
+ "capability": list(capability),
151
+ "torchBf16Reported": bool(torch.cuda.is_bf16_supported()),
152
+ "nativeBf16Admitted": native_bf16,
153
  }
154
 
155
 
156
+ def compute_dtype(gpu: dict[str, Any]) -> torch.dtype:
157
+ return torch.bfloat16 if gpu["nativeBf16Admitted"] else torch.float16
158
+
159
+
160
  def upload_evidence(output: Path, repo_id: str, token: str) -> dict[str, Any]:
161
  api = HfApi(token=token)
162
  api.create_repo(repo_id, repo_type="dataset", private=True, exist_ok=True)
 
252
  }
253
 
254
  device = torch.device("cuda:0")
255
+ dtype = compute_dtype(result["gpu"])
256
  torch.cuda.reset_peak_memory_stats(device)
257
  load_started = time.perf_counter()
258
  model = AutoModelForCausalLM.from_pretrained(