-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[https://nvbugs/5429636][feat] Configurable kv_transfer_timeout_ms for failed transfer memory leaks #7575
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
Conversation
|
I will be trying to work on this since TRTLLM is open-source. If another engineer picks it up instead due to it being a higher priority, please let me know here so we don't duplicate efforts! |
|
Once PR6587 lands I will pick this back up. |
|
I see that #8114 has been merged. @pcastonguay do we still want this feature? If so, I will pick this back up and target taking this out of draft next week. |
Yes we still need this. If you have cycles to look into it early next week, please do so. If not I will pick up on Monday. |
pcastonguay
left a comment
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.
Is there a way we could test this in a unit test? I.e. send a context-only request to a server, get the response but never send a request to the gen server. Then we could query the KV cache stats to make sure blocks have been freed.
| requests_to_terminate.append(request) | ||
| continue | ||
|
|
||
| # Check if generation request needs cleanup due to KV cache transfer timeout |
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.
Is it possible for a ctx request to ever enter this code path here? If not, should we move this inside the if request.is_generation_only_requests to make it clearer?
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.
No, I don't think a ctx request should be able to enter this code path since it loops over the generation requests in self.active_requests. But my understanding was that is_generation_only_request was for gen-only server requests? And if we had the ctx-gen disagg servers separate, we would never go down that code path in that case? I may be misunderstanding the is_generation_only_request case. Either way, I will test it.
I can certainly try and look into it. I agree there needs to be some way to test this feature. |
I should have cycles so I will work on it and keep you updated in this PR thread. |
Signed-off-by: raayandhar <[email protected]>
814c810 to
0574624
Compare
|
A few notes:
|
Thanks Raayan, I will pick it up from here and will let you know if I have any questions. |
If you're busy I can still make headway. In fact I can certainly try to make some progress today. Just that certain testing may be difficult on my side is all. |
Yeah, I have a lot on my plate, so feel free to continue making headway. I also realize that you're limited in what you can test. |
|
Also been busy but will make some progress Fri. and through the weekend. Ideally you can pick it up for whatever remains of testing early next week. |
Signed-off-by: raayandhar <[email protected]>
Signed-off-by: raayandhar <[email protected]>
Signed-off-by: raayandhar <[email protected]>
|
It now compiles with pybind and nanobind. I am working on testing. There are some permission issues with the machines I use, so I e.g. can't update CUDA etc so PyTorch won't work. I can let you know by tomorrow if this is the farthest I can go. |
|
@pcastonguay unfortunately I can't really test these changes. I'm not able to update the NVIDIA drivers on the machines I use. I know it compiles with both pybind and nanobind now after some fixes. So hopefully the changes, if any, are minimal. For testing I described how I tested in the PR description, I would apply some of the changes in 814c810 to test. |
Thanks Raayan, I will pick this up tomorrow. |
|
@raayandhar could you take a look at recent commit from #8459. I will close this PR and take over. |
Description
This is an approach to tackle the problem in issue 5820 where failed requests cause a memory leak. Requests would fail, not transfer, and still consume KV cache resources. Sometimes, on synchronous checks via
check_context_transfer_status, we would also hang.This PR aims to add the support for a ctx/gen configurable
kv_transfer_timeout_ms, static across all requests such that if a request has existed on ctx/gen servers longer than the timeout, it would be removed and its resources freed.Notes
This is largely implemented. However, in its current state, there is still a probabilistic hang. Despite
_terminate_requestfor timed-out requests and it being removed fromself.ctx_in_transmission_requests, we may hang inself.check_context_transfer_status(0)inside_send_disagg_ctx_cachemuch later.This is because the future for the request still exists, and it will block on a future
future.get(). If we never create the future, we never hang.To test, checkout the first commit, use
export FAIL_ONLY=2049(or some other request id(s)) to fail a request on context side. I have added a path to skip creating a future for request2049in order to verify that this prevents the hang. I recommendexport TLLM_LOG_LEVEL=debugin order to see the detailed logs for the behavior.In order to further implement this feature to completion, it should integrate the
cancelRequestchanges in PR 6587 with the addition of failing the promise through i.e. something likemPromise.set_exception.This PR is largely based on changes from #6801, please see this PR for earlier discussion.
Test Coverage
Test coverage needs to be added to this PR. Looking for feedback here.
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...Provide a user friendly way for developers to interact with a Jenkins server.
Run
/bot [-h|--help]to print this help message.See details below for each supported subcommand.
run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]Launch build/test pipelines. All previously running jobs will be killed.
--reuse-test (optional)pipeline-id(OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.--disable-reuse-test(OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.--disable-fail-fast(OPTIONAL) : Disable fail fast on build/tests/infra failures.--skip-test(OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.--stage-list "A10-PyTorch-1, xxx"(OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.--gpu-type "A30, H100_PCIe"(OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.--test-backend "pytorch, cpp"(OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.--only-multi-gpu-test(OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.--disable-multi-gpu-test(OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.--add-multi-gpu-test(OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.--post-merge(OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx"(OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".--detailed-log(OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.--debug(OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in thestage-listparameter to access the appropriate container environment. Note: Does NOT update GitHub check status.For guidance on mapping tests to stage names, see
docs/source/reference/ci-overview.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip testing for latest commit on pull request.
--comment "Reason for skipping build/test"is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.reuse-pipeline
reuse-pipelineReuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.