Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add prestartup script #1136
base: main
Are you sure you want to change the base?
Add prestartup script #1136
Changes from 2 commits
c55c8c2
b92151e
a93150f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
🛠️ Refactor suggestion
Improve error handling and imports
Several improvements needed in the NPU availability check:
except
clause is too broad and could mask important errorstransfer_to_npu
import is unusedApply this diff:
📝 Committable suggestion
🧰 Tools
🪛 Ruff
4-4:
torch_npu.contrib.transfer_to_npu
imported but unusedRemove unused import:
torch_npu.contrib.transfer_to_npu
(F401)
7-7: Do not use bare
except
(E722)
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.
💡 Codebase verification
Critical: Implement proper NPU memory management
The review comment is correct. The code currently uses a hardcoded 48GB memory value instead of properly calculating available NPU memory. The suggested fix in the review comment is appropriate because:
torch.npu.memory_stats()
andtorch.npu.mem_get_info()
APIstorch_npu
and has NPU-specific implementationsThe proposed diff correctly:
max(0, ...)
to prevent negative memory values🔗 Analysis chain
Critical: Replace hardcoded memory value
The function has several issues:
Please implement proper memory calculation:
Let me generate additional scripts to gather more context about the memory management implementation.
The first command will help us understand the original implementation that this patch is trying to override, and the second command will help identify any memory-related configurations or constants that might be relevant to this implementation.
Let me try one more search to find any NPU-specific memory management code or configurations.
This will help us understand if there are any NPU-specific memory management patterns or if the hardcoded value is used elsewhere in the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 4097
Script:
Length of output: 1017
Script:
Length of output: 2176