Skip to content

Conversation

jlamypoirier
Copy link
Collaborator

@jlamypoirier jlamypoirier commented Jan 13, 2023

  • Add GPU profiling
  • Ultra-fast model creation so we can benchmark/profile quickly. The model is created in ~300 ms (create and init weights directly on GPU) instead of 20-30 s loading + several minutes on the first time. On the downside, we no longer benchmark the loading time and can't use custom weights but that could be added easily (and it would be much faster than before).
  • Rewrite the benchmarking code and pipeline initialization to support the new features.
  • Use the logging module instead of plain prints and add timestamps so we can more easily track the progress
  • Add some safety checks on arguments
  • Improve performance metrics and add several more
  • Simplify device placement (with arg instead of separate class) and data types
  • Move ds/hf common code to the Pipeline class
  • Lots of refactoring and cleanup
@jlamypoirier jlamypoirier changed the title [WIP] Profiling [WIP] Profiling and misc Jan 13, 2023
@jlamypoirier jlamypoirier changed the title [WIP] Profiling and misc Profiling and misc Jan 13, 2023
Base automatically changed from dockerfile to main January 14, 2023 01:52
Copy link
Collaborator

@mayank31398 mayank31398 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few changes. Most of it looks good to me :)

input_tokens[t] = input_tokens[t].to(self.device)

t1 = time.perf_counter()
with torch.no_grad():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?
The generate method already runs in torch.no_grad context by default

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably useless but a bit of extra safety can't hurt. Same with the model.eval() in __init__.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use inference_mode()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know about this one, thanks for pointing it out. I will leave it for future work though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#12

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'm not sure of the context here but it should be a harmless replacement ... it includes everything no_grad does.

# BLOOM AliBi
hf-1b-bloom-fp32:
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class BLOOM --dtype float32 --batch_size ${batch_size}
python3 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_Pipeline --model_class BLOOM --dtype float32 --batch_size ${batch_size}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mayank31398 I don't see why we should have it as a module. It's a script and not installed as a package.

return config, tokenizer, model_class
return sum(p.numel() for p in self.model.parameters())

def aggregate_and_format_metrics(self, metrics: List[Dict[str, Any]]):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mayank31398 It's better to leave this encapsulated with the class that generates these metrics.

@jlamypoirier jlamypoirier merged commit 4be387d into main Jan 30, 2023
jlamypoirier added a commit that referenced this pull request Jan 30, 2023
@jlamypoirier jlamypoirier deleted the profiling branch January 30, 2023 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants