Conversation
some specifics to work through as apis are updated in compressed tensors Summary Signed-off-by: HDCharles <charlesdavidhernandez@gmail.com>
Summary Signed-off-by: HDCharles <charlesdavidhernandez@gmail.com>
Summary Signed-off-by: HDCharles <charlesdavidhernandez@gmail.com>
|
👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review. Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed. |
Summary of ChangesHello @HDCharles, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
The quality checks have failed. Please run |
There was a problem hiding this comment.
Code Review
This pull request introduces support for distributed data parallel (DDP) execution within the GPTQ quantization modifier. The core changes are in src/llmcompressor/modifiers/quantization/gptq/base.py, where logic is added to handle Hessian matrix accumulation and quantized parameter broadcasting across multiple ranks. To support this, a new test script test_ddp.py and a runner script run.sh are added to facilitate experimentation and validation of the DDP implementation. My review identifies a potential correctness issue in the distributed Hessian calculation, along with several opportunities to improve the robustness and clarity of the new test scripts.
| # dist.reduce(n, op=dist.ReduceOp.SUM, dst=target_rank) # REMOVE? | ||
| # H/=n # REMOVE? |
There was a problem hiding this comment.
The distributed Hessian accumulation logic appears to be incomplete. The commented-out lines for reducing the number of samples (n) and normalizing the Hessian (H) are crucial for correctly calculating the global average Hessian. Without them, the Hessian on the target_rank is a sum of scaled Hessians (sum(H_i * n_i)) rather than a proper average. This will likely lead to incorrect results from quantize_weight. These lines should be re-enabled to ensure correctness.
| ) | ||
| elapsed_time = time.time() - start | ||
| print(f"\nPipeline took {elapsed_time} seconds, rank={dist.get_rank()}") | ||
| peak_memory_gb = torch.cuda.max_memory_allocated() / (1024**3) |
There was a problem hiding this comment.
The call to torch.cuda.max_memory_allocated() will raise an error if the script is executed on a machine without a CUDA-enabled GPU or if PyTorch was built without CUDA support. Since run.sh includes a "cpu" device map configuration, this will cause a crash. You should guard this call with a torch.cuda.is_available() check to ensure the script can run in CPU-only environments.
| peak_memory_gb = torch.cuda.max_memory_allocated() / (1024**3) | |
| peak_memory_gb = torch.cuda.max_memory_allocated() / (1024**3) if torch.cuda.is_available() else 0.0 |
| for MODEL_ID in "${MODEL_IDS[@]}"; do | ||
| for DEVICE_MAP in "${DEVICE_MAPS[@]}"; do | ||
| for NUM_GPUS in "${GPU_COUNTS[@]}"; do | ||
| export SAVE_DIR=$MODEL_ID-$NUM_GPUS-$DEVICE_MAP |
There was a problem hiding this comment.
The MODEL_ID variable can contain slashes (e.g., "TinyLlama/TinyLlama-1.1B-Chat-v1.0"), which will be included in the SAVE_DIR. This results in the creation of nested directories, which might be unintended. It would be cleaner and safer to sanitize the MODEL_ID by replacing slashes with a different character, like a hyphen, to ensure a flat directory structure for saved models.
| export SAVE_DIR=$MODEL_ID-$NUM_GPUS-$DEVICE_MAP | |
| export SAVE_DIR="$(echo "$MODEL_ID" | tr '/' '-')-$NUM_GPUS-$DEVICE_MAP" |
| self._hessians[module]=H | ||
|
|
||
| # delete unneeded info | ||
| self._num_samples.pop(module,None) |
test_ddp.py
Outdated
| args = parser.parse_args() | ||
|
|
||
| ### USER API: torchrun --nproc_per_node=2 test_ddp.py --<args or just leave defaults> | ||
| args = parser.parse_args() |
test_ddp.py
Outdated
| ### USER API: torchrun --nproc_per_node=2 test_ddp.py --<args or just leave defaults> | ||
| args = parser.parse_args() | ||
|
|
||
| from compressed_tensors.offload import offload_model |
|
The quality checks have failed. Please run |
testing against CT