Skip to content

Commit

Permalink
Fix (brevitas_examples/llm): equalized module + fx compatibility (#1164)
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe5 authored Jan 21, 2025
1 parent 41ace8a commit f2236d1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/brevitas_examples/llm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,13 @@ def quantize_llm(args):
input_quant_format=args.input_quant_format,
quantize_embedding=False)
if not args.quantize_last_layer:
# Dynamo tracing changes the name of the modules, thus we need this workaround to pick
# up the last module.
if require_fx:
last_node = [node for node in model.graph.nodes if node.op == 'call_module'][-1]
last_module = get_module(model, last_node.target)
# In case we have layerwise rotation/equalization, we need to pick the wrapped module
last_module = last_module.layer if hasattr(last_module, 'layer') else last_module
last_layer_kwargs = layer_map[type(last_module)][1]
prev_weight_quant = deepcopy(last_layer_kwargs['weight_quant'])
prev_input_quant = deepcopy(last_layer_kwargs['input_quant'])
Expand Down

0 comments on commit f2236d1

Please sign in to comment.