Skip to content

Commit

Permalink
bump this into the constructor of BuilderArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
yanbing-j committed Jan 16, 2025
1 parent 757b224 commit d22fdb6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 4 additions & 0 deletions torchchat/cli/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ def from_args(cls, args: argparse.Namespace) -> "BuilderArgs":
pp = getattr(args, "pp", 1)
tp = getattr(args, "tp", 1)
chpt_from = getattr(args, "chpt_from", "hf")
if args.device == "cpu" and (args.attention_backend == "efficient_attention"
or args.attention_backend == "cudnn_attention"):
print(f"Warning: {args.attention_backend} is not supported on CPU. Using math instead.")
args.attention_backend = "math"
return cls(
checkpoint_dir=checkpoint_dir,
checkpoint_path=checkpoint_path,
Expand Down
4 changes: 0 additions & 4 deletions torchchat/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,10 +1179,6 @@ def callback(x, *, done_generating=False):
prof = torch.profiler.profile()
t0 = time.perf_counter()
num_tokens_generated = 0
if self.builder_args.device == "cpu" and (self.builder_args.attention_backend == "efficient_attention"
or self.builder_args.attention_backend == "cudnn_attention"):
print(f"Warning: {self.builder_args.attention_backend} is not supported on CPU. Using math instead.")
self.builder_args.attention_backend = "math"
with prof:
generator_func = self.generate(
self.model,
Expand Down

0 comments on commit d22fdb6

Please sign in to comment.