Skip to content

fix(flow_de): remove dead code and fix stale NaN debug prints#21

Open
invo-coder19 wants to merge 1 commit into
ML4SCI:mainfrom
invo-coder19:fix/flow-de-dead-code-nan-guard
Open

fix(flow_de): remove dead code and fix stale NaN debug prints#21
invo-coder19 wants to merge 1 commit into
ML4SCI:mainfrom
invo-coder19:fix/flow-de-dead-code-nan-guard

Conversation

@invo-coder19
Copy link
Copy Markdown

The logsumexp refactor (replacing the old torch.where clamp approach) was completed earlier but left behind two issues:

  1. Dead commented-out block (old implementation, ~33 lines) The original numerically-unstable implementation that used orch.where(v2 < 207, v2, 207) and intermediate variables pt, ptsum, pt_sum was left as a triple-quoted string comment. This added noise and confusion for contributors. Removed entirely and replaced with a short comment explaining why the logsumexp approach was chosen.

  2. Latent NameError in the NaN debug guard After the refactor, pt and pt_sum no longer exist in scope, but the NaN guard block still attempted to print them:
    print(pt) # -> NameError: name 'pt' is not defined
    print(pt_sum) # -> NameError: name 'pt_sum' is not defined
    If NaN was ever triggered, this would raise a NameError before
    the actual ValueError, masking the real bug entirely.
    Fixed to print the live intermediates that are in scope:
    �2, log_weights, and wt.

No functional changes — behaviour is identical for all valid inputs.

The logsumexp refactor (replacing the old torch.where clamp approach)
was completed earlier but left behind two issues:

1. Dead commented-out block (old implementation, ~33 lines)
   The original numerically-unstable implementation that used
   	orch.where(v2 < 207, v2, 207) and intermediate variables
   pt, ptsum, pt_sum was left as a triple-quoted string
   comment. This added noise and confusion for contributors.
   Removed entirely and replaced with a short comment explaining
   *why* the logsumexp approach was chosen.

2. Latent NameError in the NaN debug guard
   After the refactor, pt and pt_sum no longer exist in scope,
   but the NaN guard block still attempted to print them:
       print(pt)      # -> NameError: name 'pt' is not defined
       print(pt_sum)  # -> NameError: name 'pt_sum' is not defined
   If NaN was ever triggered, this would raise a NameError *before*
   the actual ValueError, masking the real bug entirely.
   Fixed to print the live intermediates that are in scope:
   �2, log_weights, and wt.

No functional changes — behaviour is identical for all valid inputs.
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.

1 participant