Skip to content

Conversation

tejapulagam
Copy link
Contributor

What does this PR do?

Refactors thunder/transforms/quantization.py to build the computation trace using TraceSubstitutionProcessor instead of manual bound-symbol rewriting.

Test test_networks.py::test_quantization is still passing.

Copy link
Collaborator

@t-vi t-vi left a comment

Choose a reason for hiding this comment

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

Looks great, thank you @tejapulagam .
I wonder if we can process the additional args a tad more elegantly, other than that it seems great.

if psym.shape != csym.shape or psym.dtype != csym.dtype
}

new_computation_trace = trace_with_replaced_proxy_metadata(computation_trace, computation_proxy_map)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need this btw or could we absorb it into the QuantizationProcessor?

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 think it might be better to keep them separate because the TraceSubstitutionProcessor is only concerned with symbol-by-symbol replacement, i tried to experiment with it and ran into more errors.

)

# Add new compute inputs to the trace args before processing
new_computation_trace.args = (*new_computation_trace.args, *new_compute_inputs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we can do this before the processing and also add the new bindings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

else:
new_computation_trace.bound_symbols.append(bsym.from_bsym())
# Insert the new bindings at the beginning of the trace
new_computation_trace.bound_symbols = new_bindings + new_computation_trace.bound_symbols
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer to keep the order of the bindings aligned with the arg order.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

37b595b

not sure if this is what you had in mind

@tejapulagam tejapulagam requested a review from KaelanDt as a code owner October 1, 2025 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants