Cache optimization - #3
ShashankFC wants to merge 2 commits into
Conversation
Entelligence AI Vulnerability ScannerStatus: No security vulnerabilities found Your code passed our comprehensive security analysis. Analyzed 1 files in total |
Review Summary🏷️ Draft Comments (1)
|
WalkthroughThis PR introduces performance optimizations to the PyTorch autograd profiler by adding caching mechanisms to two classes. The Changes
Sequence DiagramThis diagram shows the interactions between components: sequenceDiagram
participant Client
participant DuplicateChecker
participant KinetoProfile as _KinetoProfile
participant Kineto as _kineto_step()
Note over DuplicateChecker,KinetoProfile: New caching mechanism added
rect rgb(220, 240, 255)
Note over DuplicateChecker: Duplicate Detection with Cache
Client->>DuplicateChecker: see(key)
alt key in cache
DuplicateChecker-->>Client: return cached True
else key in seen set
DuplicateChecker-->>Client: raise RuntimeError (duplicate)
else new key
DuplicateChecker->>DuplicateChecker: add to seen set
DuplicateChecker->>DuplicateChecker: cache[key] = True
DuplicateChecker-->>Client: return True
end
end
rect rgb(240, 255, 240)
Note over KinetoProfile,Kineto: Step Increment with Caching
Client->>KinetoProfile: increment_step(requester)
alt requester in cache
KinetoProfile-->>Client: return cached step
else requester not initialized
KinetoProfile->>KinetoProfile: init_step_count(requester)
KinetoProfile->>KinetoProfile: _step_dict[requester] += 1
KinetoProfile->>KinetoProfile: calculate new_step = max(values)
alt new_step > current_step
loop delta times
KinetoProfile->>Kineto: _kineto_step()
end
KinetoProfile->>KinetoProfile: update _current_step
end
KinetoProfile->>KinetoProfile: cache[requester] = _current_step
KinetoProfile-->>Client: return _current_step
end
end
rect rgb(255, 240, 240)
Note over KinetoProfile: Cache Invalidation
Client->>KinetoProfile: remove_requester(requester)
KinetoProfile->>KinetoProfile: pop from _step_dict
Note over KinetoProfile: Cache entry remains until next increment
KinetoProfile-->>Client: return success
end
🔗 Cross-Repository Impact AnalysisEnable automatic detection of breaking changes across your dependent repositories. → Set up now Learn more about Cross-Repository AnalysisWhat It Does
How to Enable
Benefits
Note for WindsurfPlease change the default marketplace provider to the following in the windsurf settings:Marketplace Extension Gallery Service URL: https://marketplace.visualstudio.com/_apis/public/gallery Marketplace Gallery Item URL: https://marketplace.visualstudio.com/items Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts belowEmoji Descriptions:
Interact with the Bot:
Also you can trigger various commands with the bot by doing The current supported commands are
More commands to be added soon. |
EntelligenceAI PR Summary
This PR optimizes the PyTorch autograd profiler by adding caching mechanisms to improve performance in key tracking classes.
_cachedictionary toEnforceUniqueclass for memoizing previously seen keys with early return for cached results_cachedictionary inKinetoStepTrackerto store step counts per requester with early return inincrement_step()_step_dictfromdefaultdict(int)to regular dict with explicit initialization inKinetoStepTracker_step_dictwhen calculatingmax()valueserase_step_count()method to store result in variable before returning