Skip to content

Add The Pertensor Quant And Fix some BUGs#458

Open
Michael20070814 wants to merge 8 commits intoModelTC:mainfrom
Michael20070814:main
Open

Add The Pertensor Quant And Fix some BUGs#458
Michael20070814 wants to merge 8 commits intoModelTC:mainfrom
Michael20070814:main

Conversation

@Michael20070814
Copy link
Copy Markdown
Contributor

No description provided.

type: model_type
path: model path
type: Qwen3
path: /home/michael/Project/models/Qwen3-0.6B
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not use hardcode path and models, revert to the original content

download: False
path: calib data path
path: /home/michael/Project/calib/pileval
n_sample: 128
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here use n_samples

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not add the n_sample, here will emerge some problems.
[rank0]: AttributeError: 'EasyDict' object has no attribute 'n_sample'. Did you mean: 'n_samples'?
Just like this.
It seems that some spelling mistake had happened. Let me check it!

seed: *seed
eval:
eval_pos: [transformed, fake_quant, fake_quant_wo_kv] #long_ppl eval not support pretrain eval pos
eval_pos: [] #long_ppl eval not support pretrain eval pos
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use original content

act_static_cfg.update(self.config.calib.bs)
# KV cache 构造函数接收的是 num_samples / bsz,
# 这里把校准配置里的字段名映射成它实际需要的参数名。
act_static_cfg['num_samples'] = self.config.calib.n_sample
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use self.config.calib.n_samples

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the problem what causes that I must set the n_sample.


# 按 LightLLM 的 kv_cache_calib.json 结构导出校准结果,
# 目前只支持它已经接入的 per_tensor / per_head 两种 KV 格式。
def collect_calib_json(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The process of exporting calibration json file strictly relates with LightLLM. It's better to move this part to the utils folder.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I will make it more moduled

llmc/__main__.py Outdated
# 动态分配模型
model = MODEL_REGISTRY[config.model.type](config)

# 打印模型和tokenizer
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this types of comment. And avoid using chinese.

llmc/__main__.py Outdated
eval_model(model, blockwise_opts, eval_list, eval_pos='transformed')
# 只有rank 0继续做保存和导出
if int(os.environ['RANK']) == 0:
if 'save' in config and config.save.get('save_calib_json', False):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

save_calib_json is not a clear config option. modify it after discussion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed the config to make the export target explicit:
save_calib_json -> save_lightllm_kv_cache_calib
calib_json_name -> lightllm_kv_cache_calib_name

This export is specifically for LightLLM KV cache calibration, so the new naming is more precise.

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