Skip to content

delete invalid line - #381

Merged
shijieliu merged 1 commit into
NVIDIA:mainfrom
ShaobinChen-AH:fix/dead-expr-strip-cached-tokens
May 11, 2026
Merged

shijieliu merged 1 commit into
NVIDIA:mainfrom
ShaobinChen-AH:fix/dead-expr-strip-cached-tokens

Conversation

@ShaobinChen-AH

Copy link
Copy Markdown
Contributor

Description

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

find a code snippet in
examples/hstu/modules/async_kvcache_manager.py that does not work.

@greptile-apps

greptile-apps Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes a single dead-code statement in strip_cached_tokens of AsyncHSTUKVCacheManager. The deleted line item_offset + batch.batch_size was a pure arithmetic expression whose result was never assigned to a variable or passed anywhere, making it a no-op with no effect on program state.

  • Dead code removed: item_offset + batch.batch_size was a floating expression that Python evaluates and immediately discards; removing it has no impact on any downstream logic in strip_cached_tokens.
  • No missing assignment detected: Inspecting the rest of the function confirms no variable relies on item_offset + batch.batch_size; the only related index used later is item_offset + 2 * batch.batch_size (already present on line 299).

Confidence Score: 5/5

Safe to merge — the change removes a single dead-code expression that had no effect on program state.

The deleted line item_offset + batch.batch_size is a pure arithmetic expression whose result is never stored or used; Python discards it silently. No variable in the function depends on this value, and all downstream tensor indexing is unchanged. The removal is purely cosmetic with zero risk of behavioral change.

No files require special attention.

Important Files Changed

Filename Overview
examples/hstu/modules/async_kvcache_manager.py Removed a no-op expression item_offset + batch.batch_size that computed a value but never assigned or used it — safe dead-code removal.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["strip_cached_tokens(batch, origin_num_cached)"] --> B["Compute num_cached, num_hist_cached"]
    B --> C["Fetch old_offsets, old_lengths from batch.features"]
    C --> D["item_offset = num_context * batch.batch_size"]
    D --> E["~~item_offset + batch.batch_size~~ removed — was a no-op"]
    D --> F["Build new_lengths tensor"]
    F --> G["Compute startpos / endpos using item_offset + 2 * batch_size"]
    G --> H["Slice old_values into new_hist_value and new_context_value"]
    H --> I["Reconstruct batch features and return"]
Loading

Reviews (1): Last reviewed commit: "delete invalid line" | Re-trigger Greptile

@shijieliu
shijieliu merged commit e7f1d4c into NVIDIA:main May 11, 2026
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