Skip to content

fix: fix missing assert in embedding.py#6

Open
Hniii98 wants to merge 1 commit intoInfiniTensor:mainfrom
Hniii98:fix-embedding-test
Open

fix: fix missing assert in embedding.py#6
Hniii98 wants to merge 1 commit intoInfiniTensor:mainfrom
Hniii98:fix-embedding-test

Conversation

@Hniii98
Copy link
Copy Markdown

@Hniii98 Hniii98 commented Aug 21, 2025

我在实现embedinng的时候,错误地实现为1D的index数组永远只有一个元素,即只需要取一行。

    size_t offset = idx * weight->strides()[0] * llaisys::utils::dsize(weight->dtype()); // units: byte
    size_t embedding_dim = weight->shape()[1]; 

    if (weight->deviceType() == LLAISYS_DEVICE_CPU) {
        return cpu::embedding(out->data(), weight->data() + offset, weight->dtype(), 
                              embedding_dim); 
    }

运行embeding对应的测试文件

python test/ops/embedding.py 

部分结果如下图:
image

测试程序按预期输出了不同的的部分,但是却意外地仍然输出 “Test passed!”

定位错误在出在函数 test_op_embedding中

    check_equal(out_, out, strict=True)

没有对check_equal的返回值做任何处理,于是程序在测试出错的时候仍然非预期执行最后的输出

   print("\033[92mTest passed!\033[0m\n")

按照其他测试文件的风格,修改如下

    assert check_equal(out_, out, strict=True)

程序按预期断言错误
image

KevinSusan pushed a commit to KevinSusan/llaisys_tt that referenced this pull request Mar 16, 2026
…itance, logging)

- Fix InfiniTensor#1: Replace _session_worker dict with OrderedDict LRU (max_sticky_sessions=10000)
- Fix InfiniTensor#2: Add best-effort TOCTOU comment on KV-aware routing
- Fix InfiniTensor#3: Add logger.debug for tokenize failures, shallow-copy payload in submit()
- Fix InfiniTensor#4: KVCachePool(IKVCachePool), ChatService(IInferenceService) explicit inheritance
- Fix InfiniTensor#5: Merge double lock in request_stop()
- Fix InfiniTensor#6: Clean _prompt_tokens from payload after routing
KevinSusan pushed a commit to KevinSusan/llaisys_tt that referenced this pull request Mar 16, 2026
…itance, logging)

- Fix InfiniTensor#1: Replace _session_worker dict with OrderedDict LRU (max_sticky_sessions=10000)
- Fix InfiniTensor#2: Add best-effort TOCTOU comment on KV-aware routing
- Fix InfiniTensor#3: Add logger.debug for tokenize failures, shallow-copy payload in submit()
- Fix InfiniTensor#4: KVCachePool(IKVCachePool), ChatService(IInferenceService) explicit inheritance
- Fix InfiniTensor#5: Merge double lock in request_stop()
- Fix InfiniTensor#6: Clean _prompt_tokens from payload after routing
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