Skip to content

Add ServerlessLLM Support#1

Merged
future-xy merged 8 commits intomainfrom
xly/checkpoint
Aug 9, 2024
Merged

Add ServerlessLLM Support#1
future-xy merged 8 commits intomainfrom
xly/checkpoint

Conversation

@drunkcoding
Copy link
Collaborator

@drunkcoding drunkcoding commented Jul 3, 2024

This PR creates new loader to use ServerlessLLM interface

@drunkcoding drunkcoding requested a review from future-xy July 3, 2024 09:29
Copy link
Member

Choose a reason for hiding this comment

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

Can we call save models instead of save_tensors?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are executing save/load state dict, not model, need to use save tensors directly

model = _initialize_model(model_config, self.load_config,
lora_config, vision_language_config,
cache_config)
state_dict = self._filter_subtensors(model.state_dict())
Copy link
Member

Choose a reason for hiding this comment

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

Will this create another copy of model parameters?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

copy exactly from vllm implementation, we inherit the save behaviour

Copy link
Member

Choose a reason for hiding this comment

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

Essentially, we have one unique rank, right? so why do we need this rank here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

used in with get_cuda_memory_handles API

Copy link
Member

Choose a reason for hiding this comment

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

What is this 0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

every tensor has its own base address, so GPU offset is always 0

@future-xy future-xy requested a review from SiyangShao July 4, 2024 03:18
Copy link
Member

@SiyangShao SiyangShao Jul 4, 2024

Choose a reason for hiding this comment

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

Could the save_serverless_llm_state method be copied into normal GPUExecutor so that for single GPU, user do not need to specify backend?

Copy link
Member

Choose a reason for hiding this comment

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

I think both our save and load method do not rely on specific executor, right?

Copy link
Member

Choose a reason for hiding this comment

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

client here is not defined yet

Copy link
Member

Choose a reason for hiding this comment

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

local path seems different compared with load part. I guess it should be os.path.join(path, f"rank_{rank}")?

@SiyangShao

This comment was marked as resolved.

with open(os.path.join(rank_path, "tensor_index.json"), "w") as f:
json.dump(tensor_index, f)

save_dict(state_dict, os.path.join(path, f"rank_{rank}"))
Copy link
Member

Choose a reason for hiding this comment

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

I didn't found the save dict function under serverless_llm_store, where can I build the latest version with save_dict function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

use latest xly/fix-docker-build from serverlessllm

# move all tensors to CPU
for key, tensor in state_dict.items():
state_dict[key] = tensor.cpu().contiguous()

Copy link
Member

Choose a reason for hiding this comment

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

We may need to add

os.makedirs(os.path.join(path, f"rank_{rank}"), exist_ok=True)

here or it may have failed to open file error

Failed to open file ./models/opt-125m/rank_0/tensor.data_0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments