AbstractPhil commited on
Commit
b1bc58e
·
verified ·
1 Parent(s): 5ccb8de

mini-beatrix-3 served in bfloat16: built fp32 and cast, because the orthogonal init calls QR and there is no bfloat16 CPU kernel for it (measured on a 4090, which also says bf16 halves peak VRAM 1.60 -> 0.80 GB at the same 6 bytes/s, and changes greedy output on some prompts where the top two bytes are near-tied - the panel says so)

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -517,16 +517,15 @@ class Craft:
517
  # two-craft build comes up in 60 seconds. Building straight into
518
  # the target dtype (rather than fp32-then-cast) also keeps the
519
  # transient copy out of the boot's peak.
 
 
 
 
 
520
  self.dtype = getattr(torch, spec.get("dtype", "float32"))
521
- if self.dtype is torch.float32:
522
- self.model = AlephLM(self.cfg)
523
- else:
524
- _prev = torch.get_default_dtype()
525
- torch.set_default_dtype(self.dtype)
526
- try:
527
- self.model = AlephLM(self.cfg)
528
- finally:
529
- torch.set_default_dtype(_prev)
530
  self.model.load_state_dict(sd)
531
  self.model.eval()
532
  self.core_params = self.model.param_count()
 
517
  # two-craft build comes up in 60 seconds. Building straight into
518
  # the target dtype (rather than fp32-then-cast) also keeps the
519
  # transient copy out of the boot's peak.
520
+ # Built fp32 and cast, NOT constructed in the target dtype:
521
+ # every q/k frame is orthogonal-initialized and torch.linalg.qr
522
+ # has no bfloat16 CPU kernel ("geqrf_cpu not implemented for
523
+ # BFloat16"), so setting the default dtype first raises at the
524
+ # first constellation. Measured on the 4090, not guessed.
525
  self.dtype = getattr(torch, spec.get("dtype", "float32"))
526
+ self.model = AlephLM(self.cfg)
527
+ if self.dtype is not torch.float32:
528
+ self.model = self.model.to(self.dtype)
 
 
 
 
 
 
529
  self.model.load_state_dict(sd)
530
  self.model.eval()
531
  self.core_params = self.model.param_count()