[Dynamo][Logging]Fix regression on stack adding to latest bytecode by… (#165946)

… adding verbose check (#165926)

[ghstack-poisoned]

Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/165946
Approved by: https://github.com/williamwen42
This commit is contained in:
Xiao 2025-10-24 20:36:50 +00:00 committed by PyTorch MergeBot
parent 2c851c16e5
commit 6038e476e8

View File

@ -1363,14 +1363,15 @@ class InstructionTranslatorBase(
# Store the latest 20 bytecode execution for the process,
# Used repr for byte processing and limiting the length to 2048
try:
stack_repr = repr(self.stack)
except ValueError:
# Handle large integers that exceed sys.int_info.str_digits_check_threshold
stack_repr = "<self.stack repr truncated due to large integer>"
self.latest_bytecode_queue.append(
f"TRACE {inst.opname} {repr(inst.argval)} {stack_repr}"
)
if config.verbose:
try:
stack_repr = repr(self.stack)
except ValueError:
# Handle large integers that exceed sys.int_info.str_digits_check_threshold
stack_repr = "<self.stack repr truncated due to large integer>"
self.latest_bytecode_queue.append(
f"TRACE {inst.opname} {repr(inst.argval)} {stack_repr}"
)
self.update_block_stack(inst)