Repository navigation
Conversation
Fixes #3487. Signed-off-by: Reece Palmer <rxp528@student.bham.ac.uk>
|
Fixes #3487. Signed-off-by: Reece Palmer <rxp528@student.bham.ac.uk>
for more information, see https://pre-commit.ci
Fixes #3487. Signed-off-by: Reece Palmer <rxp528@student.bham.ac.uk>
for more information, see https://pre-commit.ci
timmoon10
left a comment
There was a problem hiding this comment.
I don't understand this code very well, but at a glance it looks reasonable aside from some nits.
| _PAD_BETWEEN_SEQS_EAGER_CACHE_LIMIT = 64 | ||
| _pad_between_seqs_eager_cache = {} |
There was a problem hiding this comment.
functools.lru_cache would be simpler and less error-prone than implementing the cache from scratch. That said, we already follow that anti-pattern with _thd_policy_validation_cache, so there's something to be said about maintaining consistency.
| def _key(t): | ||
| if t is None: | ||
| return (0, 0, 0, 0) | ||
| try: | ||
| version = t._version | ||
| except AttributeError: | ||
| version = 0 | ||
| return (t.data_ptr(), tuple(t.shape), t.dtype, version) |
There was a problem hiding this comment.
Is it safe to assume that two tensors with the same buffer will have the same padding requirements? If cu_seqlens_* are not persistent, the same buffers may be reused in different steps or different layers. Perhaps it would be safer to do something like:
return (id(t), version)| cu_seqlens_kv_padded, | ||
| ) | ||
| if cache_key in _pad_between_seqs_eager_cache: | ||
| pad_between_seqs = _pad_between_seqs_eager_cache[cache_key] |
There was a problem hiding this comment.
Noting that the cache is not populated during graph capture. In order to take advantage of the cache, we assume that the cache is populated in the warmup steps.
b36701e to
f958198
Compare
Fixes #3487. Signed-off-by: Reece Palmer <rxp528@student.bham.ac.uk>
|
Thanks for looking. Context: #3487 regressed THD P2P when padded cu_seqlens are value equal but separate objects. Identity only detection forced the padded path. This restores value comparison in eager runs. It reuses that answer during capture with a small id plus version cache. Warmup hits reuse it. Misses use the safe fallback. It also skips tail and padding cleanup when there is nothing to clear. Your nits are addressed in the staged update. |
Signed-off-by: Reece Palmer <rxp528@student.bham.ac.uk>
for more information, see https://pre-commit.ci
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
Fixes #3487.
Signed-off-by: Reece Palmer rxp528@student.bham.ac.uk