Skip to content
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

Revert "Small fixes for torchao quant" #2493

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions python/sglang/srt/layers/torchao_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ def apply_torchao_config_to_model(
quantize_,
)
from torchao.quantization.observer import PerRow, PerTensor
from torchao.quantization.quant_api import _is_linear

if filter_fn is None:

def filter_fn(module, fqn):
return _is_linear(module) and "proj" in fqn
return "proj" in fqn
Copy link
Contributor

Choose a reason for hiding this comment

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

@merrymercy this change? or the reordering of apply_torchao_config_to_model only works for torch native llama?

Copy link
Contributor Author

@merrymercy merrymercy Dec 17, 2024

Choose a reason for hiding this comment

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

I think it is this change. I reverted the whole change to make the CI passes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I picked the correct change in this PR #2495.
Please follow up with the correct fix for _is_linear.


if torchao_config == "" or torchao_config is None:
return model
Expand Down
8 changes: 4 additions & 4 deletions python/sglang/srt/model_executor/model_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ def __init__(
self.sampler = Sampler()
self.load_model()

apply_torchao_config_to_model(
self.model, global_server_args_dict["torchao_config"]
)

# Apply torch TP if the model supports it
supports_torch_tp = getattr(self.model, "supports_torch_tp", False)
if self.tp_size > 1 and supports_torch_tp:
Expand All @@ -169,6 +165,10 @@ def __init__(
else:
self.torch_tp_applied = False

apply_torchao_config_to_model(
self.model, global_server_args_dict["torchao_config"]
)

# Init memory pool and attention backends
if server_args.lora_paths is not None:
self.init_lora_manager()
Expand Down
Loading