-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[rollout] fix: apply copy_to_local before init hf config #3204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
3f65317
426db98
c94568f
f39dd18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,17 +82,20 @@ def __post_init__(self): | |
| if self.tokenizer_path is None: | ||
| self.tokenizer_path = self.path | ||
|
|
||
| # constuct tokenizer | ||
| self.local_path = copy_to_local(self.path, use_shm=self.use_shm) | ||
| self.tokenizer = hf_tokenizer(self.local_path, trust_remote_code=self.trust_remote_code) | ||
| self.processor = hf_processor(self.local_path, trust_remote_code=self.trust_remote_code) | ||
|
|
||
| self.generation_config = get_generation_config(self.hf_config_path, trust_remote_code=self.trust_remote_code) | ||
| # constuct tokenizer | ||
| local_tokenizer_path = copy_to_local(self.tokenizer_path, use_shm=self.use_shm) | ||
| self.tokenizer = hf_tokenizer(local_tokenizer_path, trust_remote_code=self.trust_remote_code) | ||
| self.processor = hf_processor(local_tokenizer_path, trust_remote_code=self.trust_remote_code) | ||
|
|
||
| local_hf_config_path = copy_to_local(self.hf_config_path, use_shm=self.use_shm) | ||
| self.generation_config = get_generation_config(local_hf_config_path, trust_remote_code=self.trust_remote_code) | ||
|
|
||
| # constuct hf_config | ||
| attn_implementation = self.override_config.get("attn_implementation", "flash_attention_2") | ||
| self.hf_config = AutoConfig.from_pretrained( | ||
| self.hf_config_path, trust_remote_code=self.trust_remote_code, attn_implementation=attn_implementation | ||
| local_hf_config_path, trust_remote_code=self.trust_remote_code, attn_implementation=attn_implementation | ||
| ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While the fix is correct in using Although To avoid this redundancy and improve startup performance, you can collect all unique paths and copy each one only once. # Efficiently copy remote paths to local, avoiding redundant copies.
remote_paths = {self.path, self.tokenizer_path, self.hf_config_path}
local_path_map = {p: copy_to_local(p, use_shm=self.use_shm) for p in remote_paths}
self.local_path = local_path_map[self.path]
# constuct tokenizer
local_tokenizer_path = local_path_map[self.tokenizer_path]
self.tokenizer = hf_tokenizer(local_tokenizer_path, trust_remote_code=self.trust_remote_code)
self.processor = hf_processor(local_tokenizer_path, trust_remote_code=self.trust_remote_code)
local_hf_config_path = local_path_map[self.hf_config_path]
self.generation_config = get_generation_config(local_hf_config_path, trust_remote_code=self.trust_remote_code)
# constuct hf_config
attn_implementation = self.override_config.get("attn_implementation", "flash_attention_2")
self.hf_config = AutoConfig.from_pretrained(
local_hf_config_path, trust_remote_code=self.trust_remote_code, attn_implementation=attn_implementation
) |
||
|
|
||
| override_config_kwargs = { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you assign a variable to self? e.g., self. local_tokenizer_path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, plz check if I'm doing right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to add to _mutable_fields as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vermouth1992 Done