Skip to content

Commit d22fdb6

Browse files
committed
bump this into the constructor of BuilderArgs
1 parent 757b224 commit d22fdb6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

torchchat/cli/builder.py

+4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ def from_args(cls, args: argparse.Namespace) -> "BuilderArgs":
179179
pp = getattr(args, "pp", 1)
180180
tp = getattr(args, "tp", 1)
181181
chpt_from = getattr(args, "chpt_from", "hf")
182+
if args.device == "cpu" and (args.attention_backend == "efficient_attention"
183+
or args.attention_backend == "cudnn_attention"):
184+
print(f"Warning: {args.attention_backend} is not supported on CPU. Using math instead.")
185+
args.attention_backend = "math"
182186
return cls(
183187
checkpoint_dir=checkpoint_dir,
184188
checkpoint_path=checkpoint_path,

torchchat/generate.py

-4
Original file line numberDiff line numberDiff line change
@@ -1179,10 +1179,6 @@ def callback(x, *, done_generating=False):
11791179
prof = torch.profiler.profile()
11801180
t0 = time.perf_counter()
11811181
num_tokens_generated = 0
1182-
if self.builder_args.device == "cpu" and (self.builder_args.attention_backend == "efficient_attention"
1183-
or self.builder_args.attention_backend == "cudnn_attention"):
1184-
print(f"Warning: {self.builder_args.attention_backend} is not supported on CPU. Using math instead.")
1185-
self.builder_args.attention_backend = "math"
11861182
with prof:
11871183
generator_func = self.generate(
11881184
self.model,

0 commit comments

Comments
 (0)