Skip to content

Commit 773388d

Browse files
committed
clean code fix
1 parent dd56f7b commit 773388d

9 files changed

Lines changed: 20 additions & 19 deletions

File tree

ucm/integration/vllm/ucm_connector.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,8 +2900,6 @@ def __init__(
29002900
self.connector = UCMHybridLinearAttentionConnector(
29012901
vllm_config, role, kv_cache_config
29022902
)
2903-
# elif use_hma:
2904-
# self.connector = UCMHMAConnector(vllm_config, role, kv_cache_config)
29052903
else:
29062904
self.connector = UCMDirectConnector(vllm_config, role, kv_cache_config)
29072905

ucm/sandbox/sparse/retake/retake/longvideo_cache.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,10 @@ def update(
485485

486486
position_ids = cache_kwargs.pop("position_ids", None)
487487
compression_ratio = self.budget_allocation(layer_idx)
488+
no_compression = math.isclose(compression_ratio, 1.0, rel_tol=1e-9)
488489
# print('compression_ratio of layer %d: %.4f' % (layer_idx, compression_ratio))
489490

490-
if (
491-
self.kvcache_compression
492-
and self.compression_ratio < 1.0
493-
and compression_ratio == 1.0
494-
):
491+
if (self.kvcache_compression and self.compression_ratio < 1.0 and no_compression):
495492
# Truncate the prompts directly when no compression
496493
key_states = key_states[:, :, : -self.prompt_length]
497494
value_states = value_states[:, :, : -self.prompt_length]
@@ -503,7 +500,7 @@ def update(
503500
)
504501

505502
if (
506-
self.kvcache_compression and compression_ratio < 1.0
503+
self.kvcache_compression and compression_ratio < 1.0 and not no_compression
507504
): # when compression is enabled
508505
query_states = cache_kwargs.pop("query_states")
509506
rotary_emb_fn = cache_kwargs.pop("rotary_emb")

ucm/shared/trans/cuda/gdr/gdr_copy.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ void GdrCopyLib::RegisterHostBuffer(void* host, size_t size)
742742
try {
743743
channel.RegisterHostBuffer(reinterpret_cast<uint64_t>(host), size);
744744
} catch (...) {
745+
// Ignore registration failure on existing channels, as the new registration will be
746+
// picked up later.
745747
}
746748
});
747749
}

ucm/sparse/esa/retrieval/cpy/retrieval_backend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class RetrievalWorkerBackend {
9292
for (size_t i = 0; i < n_requests; ++i) {
9393
for (size_t j = 0; j < max_index_number; ++j) {
9494
int index = idx_ptr[i * max_index_number + j];
95-
if (index != -1) idxvec[i].push_back(index);
95+
if (index != -1) { idxvec[i].push_back(index); }
9696
}
9797
}
9898

ucm/sparse/gsa_on_device/csrc/cuda/hash_retrieval/cpy/hash_retrieval_backend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class HashRetrievalWorkerBackend {
241241
for (size_t i = 0; i < n_requests; ++i) {
242242
for (size_t j = 0; j < max_index_number; ++j) {
243243
int index = idx_ptr[i * max_index_number + j];
244-
if (index != -1) idxvec[i].push_back(index);
244+
if (index != -1) { idxvec[i].push_back(index); }
245245
}
246246
}
247247

ucm/store/cache/cc/trans_buffer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ class SharedBufferStrategy : public BufferStrategy {
427427

428428
class SharedBufferWatcherStrategy : public SharedBufferStrategy {
429429
public:
430-
SharedBufferWatcherStrategy(const std::string& uuid) : SharedBufferStrategy(uuid, -1, 0, 0, 0)
430+
explicit SharedBufferWatcherStrategy(const std::string& uuid)
431+
: SharedBufferStrategy(uuid, -1, 0, 0, 0)
431432
{
432433
}
433434
Status Setup() override

ucm/store/nfsstore/cc/domain/space/space_shard_layout.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,17 @@ struct SpaceShardLayout::DataIterator : public SpaceLayout::DataIterator {
6464
this->stk.pop();
6565
}
6666
}
67-
Status Setup(const SpaceLayout* layout, const std::string& root) {
68-
this->layout = layout;
69-
this->root = root;
70-
auto dir = OpenDir(root);
67+
Status Setup(const SpaceLayout* newLayout, const std::string& newRoot)
68+
{
69+
this->layout = newLayout;
70+
this->root = newRoot;
71+
auto dir = OpenDir(newRoot);
7172
if (!dir) { return Status::OsApiError(); }
72-
this->stk.emplace(dir, root);
73+
this->stk.emplace(dir, newRoot);
7374
return Status::OK();
7475
}
75-
Status Next() {
76+
Status Next()
77+
{
7678
this->current.clear();
7779
while (!this->stk.empty()) {
7880
auto entry = ::readdir64(this->stk.top().first);

ucm/store/pipeline/connector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ def _build_cache_compress_posix_pipeline(
197197
if config.get("device_id", -1) >= 0:
198198
if (posix_config["block_size"] % posix_config["shard_size"]) != 0:
199199
print(
200-
f'_build_cache_compress_posix_pipeline: error paraments {posix_config["block_size"]} {posix_config["shard_size"]}'
200+
"_build_cache_compress_posix_pipeline: error paraments "
201+
f"{posix_config['block_size']} {posix_config['shard_size']}"
201202
)
202203
return
203204
layers = posix_config["block_size"] // posix_config["shard_size"]

ucm/store/posix/cc/io_engine_aio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class IoEngineAio : public Detail::TaskWrapper<TransTask, Detail::TaskHandle> {
8383
{
8484
const auto last = shard.index + 1 == nShardPerBlock_;
8585
const auto& id = shard.owner;
86-
auto handleFailure = [&](int32_t fd) {
86+
auto handleFailure = [this, tid, w, last, id](int32_t fd) {
8787
failureSet_.Insert(tid);
8888
if (fd >= 0) { ::close(fd); }
8989
if constexpr (dump) {

0 commit comments

Comments
 (0)