Repository navigation
๐ [i18n-KO] Translated compressed_tensor.md to Korean
#39517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
maximizemaxwell
wants to merge
16
commits into
huggingface:main
from
maximizemaxwell:ko-compressed_tensor.md
Closed
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
55df9d4
feat: nmt draft
maximizemaxwell 9ce0291
fix: improve translation accuracy and natural expressions
maximizemaxwell 513e2e2
fix: applyed grammer check, improved naturaility
maximizemaxwell 457effe
fix: update toctree.yml
maximizemaxwell 42a8e44
fix: revised awkward words
maximizemaxwell eeb2258
fix: revised sentence in line96
maximizemaxwell c38688d
Update compressed_tensors.md
maximizemaxwell 1c98864
Update compressed_tensors.md
maximizemaxwell 8409f24
Update compressed_tensors.md
maximizemaxwell 5bea391
Update compressed_tensors.md
maximizemaxwell c34cf28
Merge branch 'main' into ko-compressed_tensor.md
maximizemaxwell 4037291
compressed_tensors.md ์
๋ฐ์ดํธ
maximizemaxwell cf0a8da
compressed_tensors.md ์
๋ฐ์ดํธ
maximizemaxwell 6b4a97d
compressed_tensors.md ์
๋ฐ์ดํธ
maximizemaxwell dd73f91
fix: toctree from main
maximizemaxwell 5d3a712
fix: update toctree
maximizemaxwell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,190 @@ | ||||||
| <!--Copyright 2024 The HuggingFace Team. All rights reserved. | ||||||
|
|
||||||
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||||||
| the License. You may obtain a copy of the License at | ||||||
|
|
||||||
| http://www.apache.org/licenses/LICENSE-2.0 | ||||||
|
|
||||||
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||||||
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||||||
| specific language governing permissions and limitations under the License. | ||||||
|
|
||||||
| โ ๏ธ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be | ||||||
| rendered properly in your Markdown viewer. | ||||||
|
|
||||||
| --> | ||||||
|
|
||||||
| # compressed-tensors[[compressed-tensors]] | ||||||
|
|
||||||
| [compressed-tensors](https://github.com/neuralmagic/compressed-tensors)๋ [safetensors](https://github.com/huggingface/safetensors) ํ์ผ์ ์์ถ๋ ํ ์ ๋ฐ์ดํฐ ํ์ ์ผ๋ก ํ์ฅํด์, dense, int ์์ํ(int8), float ์์ํ(fp8), pack ์์ํ(int32๋ก ํจํน๋ int4 ๋๋ int8 ๊ฐ์ค์น ์์ํ) ๋ฑ ๋ค์ํ ์์ํยทsparse ํ์์ ํ๋์ ์ฒดํฌํฌ์ธํธ ํ์์ผ๋ก ์ ์ฅํ๊ณ ๋ถ๋ฌ์ฌ ์ ์๊ฒ ํฉ๋๋ค. | ||||||
|
|
||||||
| compressed-tensors๋ [PEFT](https://huggingface.co/docs/peft)๋ฅผ ์ฌ์ฉํ ๋ฏธ์ธ ์กฐ์ ์ ์ง์ํ๋ฉฐ, ๋ค์๊ณผ ๊ฐ์ ๊ธฐ๋ฅ๋ค์ ์ ๊ณตํฉ๋๋ค. | ||||||
|
|
||||||
| - fp8, int4, int8 ๊ฐ์ค์น ๋ฐ ํ์ฑํ ํจ์ ์ถ๋ ฅ ์ ๋ฐ๋. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| - [tensor, channel, group, block, token](https://github.com/neuralmagic/compressed-tensors/blob/83b2e7a969d70606421a76b9a3d112646077c8de/src/compressed_tensors/quantization/quant_args.py#L43-L52) ์์ค์ ์์ํ ์ค์ผ์ผ๊ณผ ์์ ์ ๋ต์ ์ ๊ณตํฉ๋๋ค. | ||||||
|
maximizemaxwell marked this conversation as resolved.
Resolved
|
||||||
| - ํ ํฐ๋ณ ๋์ ํ์ฑํ ํจ์ ๊ธฐ๋ฐ ์์ํ(๋๋ ์ ์ ์ ๋ต)๋ฅผ ์ง์ํฉ๋๋ค. | ||||||
|
maximizemaxwell marked this conversation as resolved.
Resolved
|
||||||
| - ๋น์ ํ ๋๋ 2:4์ ๊ฐ์ ๋ฐ์ ํ ๊ฐ์ค์น ํฌ์์ฑ์ ์์ํ์ ๊ฒฐํฉํ์ฌ ์์ถ๋ฅ ๊ทน๋ํ | ||||||
| - [nn.Linear](https://pytorch.org/docs/stable/generated/torch.nn.Linear.html) ๋ชจ๋๋ฟ๋ง ์๋ ์์์ ๋ชจ๋ ์์ํ | ||||||
| - ๋ชจ๋ ์ด๋ฆ ๋๋ ํด๋์ค๋ณ ์์ํ ๋์์ ์ง์ ํ ์ ์์ต๋๋ค. | ||||||
|
maximizemaxwell marked this conversation as resolved.
Resolved
|
||||||
|
|
||||||
| ์ต์ ์์ ๋ฒ์ ์ [PyPI](https://pypi.org/project/compressed-tensors)์์ ์ค์นํ ์ ์์ต๋๋ค. ์์ ํ๋์ง ์์ ์ต์ ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ ค๋ฉด ์์ค ์ฝ๋๋ฅผ ์ด์ฉํด ์ค์นํ์ค ์ ์์ต๋๋ค. | ||||||
|
|
||||||
| <hfoptions id="install"> | ||||||
| <hfoption id="PyPI"> | ||||||
|
|
||||||
| ```bash | ||||||
| pip install compressed-tensors | ||||||
| ``` | ||||||
|
|
||||||
| </hfoption> | ||||||
| <hfoption id="source code"> | ||||||
|
|
||||||
| ```bash | ||||||
| git clone https://github.com/neuralmagic/compressed-tensors | ||||||
| cd compressed-tensors | ||||||
| pip install -e . | ||||||
| ``` | ||||||
|
|
||||||
| </hfoption> | ||||||
| </hfoptions> | ||||||
|
|
||||||
| compressed-tensors [ํ๊ทธ](https://huggingface.co/models?other=compressed-tensors)๋ฅผ ์ฌ์ฉํ์ฌ Hugging Face Hub์์ ์์ํ๋ ๋ชจ๋ธ์ ์ฐพ์ ์ ์์ต๋๋ค. | ||||||
|
|
||||||
| ํ์ฌ๋ ์ด๋ฏธ ์์ํ๋ ๋ชจ๋ธ๋ง ๋ถ๋ฌ์ฌ ์ ์๊ณ , ๋ถ๋ฌ์จ ๋ชจ๋ธ์ ๋ค์ ์ ์ฅํ ์ ์์ต๋๋ค. compressed-tensors ํ์์ผ๋ก ๋ชจ๋ธ์ ์์ํํ๋ ค๋ฉด [llm-compressor](https://github.com/vllm-project/llm-compressor)๋ฅผ ์ฐธ๊ณ ํด ์ฃผ์ธ์. ๋๋ ๋ชจ๋ธ์ ์ง์ ์์ฑํ๊ณ compressed-tensors ์ค์ ์ผ๋ก ์ง๋ ฌํํ ์๋ ์์ต๋๋ค. | ||||||
|
|
||||||
| ```python | ||||||
| from transformers import AutoModelForCausalLM | ||||||
|
|
||||||
| ct_model = AutoModelForCausalLM.from_pretrained("nm-testing/Meta-Llama-3.1-8B-Instruct-FP8-hf", device_map="auto") | ||||||
|
|
||||||
| # ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋ ์ธก์ ํ๊ธฐ | ||||||
| mem_params = sum([param.nelement()*param.element_size() for param in ct_model.parameters()]) | ||||||
| print(f"{mem_params/2**30:.4f} GB") | ||||||
| # 8.4575 GB | ||||||
| ``` | ||||||
|
|
||||||
| ## ๋ชจ๋ธ ์ฒดํฌํฌ์ธํธ[[model-checkpoint]] | ||||||
|
|
||||||
| compressed-tensor ๋ชจ๋ธ์ ์ค์ ํญ๋ชฉ์ ํตํด ์ ์๋ฉ๋๋ค. ๋ค์ ์์๋ [nm-testing/Meta-Llama-3.1-8B-Instruct-FP8-hf](https://huggingface.co/nm-testing/Meta-Llama-3.1-8B-Instruct-FP8-hf/blob/main/config.json) `config.json` ํ์ผ์์ ๊ฐ์ ธ์จ ๊ฒ์ ๋๋ค. | ||||||
|
maximizemaxwell marked this conversation as resolved.
Resolved
|
||||||
|
|
||||||
| ์์ถ ์ ํ์ ์ ์ฐํ ํํ์ ์ํด ๋ง์ ํญ๋ชฉ์ด ์กด์ฌํ์ง๋ง, ๋ชจ๋ธ ๋ถ๋ฌ์ค๊ธฐ์ ์ถ๋ก ์๋ ํต์ฌ ํญ๋ชฉ ๋ช ๊ฐ์ง๋ง ์์๋ ๋ฉ๋๋ค. | ||||||
|
|
||||||
| ```yaml | ||||||
| "quantization_config": { | ||||||
| "config_groups": { | ||||||
| "group_0": { | ||||||
| "input_activations": { | ||||||
| "num_bits": 8, | ||||||
| "strategy": "tensor", | ||||||
| "type": "float" | ||||||
| }, | ||||||
| "targets": ["Linear"], | ||||||
| "weights": { | ||||||
| "num_bits": 8, | ||||||
| "strategy": "tensor", | ||||||
| "type": "float" | ||||||
| } | ||||||
| } | ||||||
| }, | ||||||
| "format": "naive-quantized", | ||||||
| "ignore": ["lm_head"], | ||||||
| "quant_method": "compressed-tensors", | ||||||
| "quantization_status": "frozen" | ||||||
| }, | ||||||
| ``` | ||||||
|
|
||||||
| ๊ตฌ์ฑ ํ์ผ์ ๊ตฌ์ฑ ๊ทธ๋ฃน(`group_0`)์ ๋ํด ์ ์ per-tensor ์ ๋ต์ผ๋ก ๊ฐ์ค์น์ ํ์ฑํ ํจ์ ๊ธฐ๋ฐ ๊ฐ์ fp8๋ก ์์ํํ๋๋ก ์ง์ ํฉ๋๋ค. `ignore` ํค์ ๋ช ์๋ ๊ฒ์ฒ๋ผ `lm_head` ๋ชจ๋์ ์์ํ๋์ง ์์ต๋๋ค. | ||||||
|
maximizemaxwell marked this conversation as resolved.
Resolved
|
||||||
|
|
||||||
| ๋ชจ๋ธ ๊ฐ์ค์น๋ฅผ ๋ ์์ธํ ๋ณด๋ ค๋ฉด, ๋ชจ๋ธ ์นด๋์ [safetensors ๋ทฐ์ด](https://huggingface.co/nm-testing/Meta-Llama-3.1-8B-Instruct-FP8-hf?show_file_info=model.safetensors.index.json)๋ฅผ ์ฌ์ฉํ์ฌ ๋ชจ๋ [nn.Linear](https://pytorch.org/docs/stable/generated/torch.nn.Linear.html) ๋ชจ๋์ ์์ํ๋ ๊ฐ์ค์น, ์ ๋ ฅ ์ค์ผ์ผ, ๊ฐ์ค์น ์ค์ผ์ผ์ ํ์ธํ ์ ์์ต๋๋ค. | ||||||
|
|
||||||
| | ํ ์ | ํํ | ์ ๋ฐ๋ | | ||||||
| | ------- | ----- | --------- | | ||||||
| model.layers.0.input_layernorm.weight | [4 096] | BF16 | ||||||
| model.layers.0.mlp.down_proj.input_scale | [1] | BF16 | ||||||
| model.layers.0.mlp.down_proj.weight | [4 096, 14 336] | F8_E4M3 | ||||||
| model.layers.0.mlp.down_proj.weight_scale | [1] | BF16 | ||||||
| model.layers.0.mlp.gate_proj.input_scale | [1] | BF16 | ||||||
| model.layers.0.mlp.gate_proj.weight | [14 336, 4 096] | F8_E4M3 | ||||||
| model.layers.0.mlp.gate_proj.weight_scale | [1] | BF16 | ||||||
| model.layers.0.mlp.up_proj.input_scale| [1] |BF16 | ||||||
| model.layers.0.mlp.up_proj.weight | [14 336, 4 096] | F8_E4M3 | ||||||
| model.layers.0.mlp.up_proj.weight_scale | [1] | BF16 | ||||||
| model.layers.0.post_attention_layernorm.weight | [4 096] |BF16 | ||||||
| model.layers.0.self_attn.k_proj.input_scale | [1] | BF16 | ||||||
| model.layers.0.self_attn.k_proj.weight | [1 024, 4 096]| F8_E4M3 | ||||||
| model.layers.0.self_attn.k_proj.weight_scale |[1] | BF16 | ||||||
| model.layers.0.self_attn.o_proj.input_scale | [1] | BF16 | ||||||
| model.layers.0.self_attn.o_proj.weight | [4 096, 4 096] | F8_E4M3 | ||||||
| model.layers.0.self_attn.o_proj.weight_scale | [1] | BF16 | ||||||
| model.layers.0.self_attn.q_proj.input_scale | [1] | BF16 | ||||||
| model.layers.0.self_attn.q_proj.weight | [4 096, 4 096] | F8_E4M3 | ||||||
| model.layers.0.self_attn.q_proj.weight_scale | [1] | BF16 | ||||||
| model.layers.0.self_attn.v_proj.input_scale | [1] | BF16 | ||||||
| model.layers.0.self_attn.v_proj.weight | [1 024, 4 096] | F8_E4M3 | ||||||
| model.layers.0.self_attn.v_proj.weight_scale | [1] | BF16 | ||||||
|
|
||||||
| compressed-tensors ๋ชจ๋ธ์ [`~quantizers.HFQuantizer`] ํตํฉ์ผ๋ก ๋ถ๋ฌ์ค๋ฉด, ์์ํ ์ค์ ์ ์ง์ ๋ ๋ชจ๋ [nn.Linear](https://pytorch.org/docs/stable/generated/torch.nn.Linear.html) ๋ชจ๋์ด [CompressedLinear](https://github.com/neuralmagic/compressed-tensors/blob/975cb223b19fcac2b98a4271d17668462d4d6e1d/src/compressed_tensors/linear/compressed_linear.py#L30) ๋ชจ๋๋ก ๋์ฒด๋์ด ์์ถ ๊ฐ์ค์น์ ์์ ํ๋ฅผ ๊ด๋ฆฌํฉ๋๋ค. `lm_head` ๋ชจ๋์ ์ฌ์ ํ ์์ํ๋์ง ์์ nn.Linear ๋ชจ๋๋ก ์ ์ง๋ฉ๋๋ค. | ||||||
|
|
||||||
| ```python | ||||||
| from transformers import AutoModelForCausalLM | ||||||
|
|
||||||
| ct_model = AutoModelForCausalLM.from_pretrained("nm-testing/Meta-Llama-3.1-8B-Instruct-FP8-hf") | ||||||
| print(ct_model) | ||||||
| """ | ||||||
| LlamaForCausalLM( | ||||||
| (model): LlamaModel( | ||||||
| (embed_tokens): Embedding(128256, 4096) | ||||||
| (layers): ModuleList( | ||||||
| (0-31): 32 x LlamaDecoderLayer( | ||||||
| (self_attn): LlamaSdpaAttention( | ||||||
| (q_proj): CompressedLinear( | ||||||
| in_features=4096, out_features=4096, bias=False | ||||||
| (input_observer): MovingAverageMinMaxObserver() | ||||||
| (weight_observer): MovingAverageMinMaxObserver() | ||||||
| ) | ||||||
| (k_proj): CompressedLinear( | ||||||
| in_features=4096, out_features=1024, bias=False | ||||||
| (input_observer): MovingAverageMinMaxObserver() | ||||||
| (weight_observer): MovingAverageMinMaxObserver() | ||||||
| ) | ||||||
| (v_proj): CompressedLinear( | ||||||
| in_features=4096, out_features=1024, bias=False | ||||||
| (input_observer): MovingAverageMinMaxObserver() | ||||||
| (weight_observer): MovingAverageMinMaxObserver() | ||||||
| ) | ||||||
| (o_proj): CompressedLinear( | ||||||
| in_features=4096, out_features=4096, bias=False | ||||||
| (input_observer): MovingAverageMinMaxObserver() | ||||||
| (weight_observer): MovingAverageMinMaxObserver() | ||||||
| ) | ||||||
| (rotary_emb): LlamaRotaryEmbedding() | ||||||
| ) | ||||||
| (mlp): LlamaMLP( | ||||||
| (gate_proj): CompressedLinear( | ||||||
| in_features=4096, out_features=14336, bias=False | ||||||
| (input_observer): MovingAverageMinMaxObserver() | ||||||
| (weight_observer): MovingAverageMinMaxObserver() | ||||||
| ) | ||||||
| (up_proj): CompressedLinear( | ||||||
| in_features=4096, out_features=14336, bias=False | ||||||
| (input_observer): MovingAverageMinMaxObserver() | ||||||
| (weight_observer): MovingAverageMinMaxObserver() | ||||||
| ) | ||||||
| (down_proj): CompressedLinear( | ||||||
| in_features=14336, out_features=4096, bias=False | ||||||
| (input_observer): MovingAverageMinMaxObserver() | ||||||
| (weight_observer): MovingAverageMinMaxObserver() | ||||||
| ) | ||||||
| (act_fn): SiLU() | ||||||
| ) | ||||||
| (input_layernorm): LlamaRMSNorm((4096,), eps=1e-05) | ||||||
| (post_attention_layernorm): LlamaRMSNorm((4096,), eps=1e-05) | ||||||
| ) | ||||||
| ) | ||||||
| (norm): LlamaRMSNorm((4096,), eps=1e-05) | ||||||
| (rotary_emb): LlamaRotaryEmbedding() | ||||||
| ) | ||||||
| (lm_head): Linear(in_features=4096, out_features=128256, bias=False) | ||||||
| ) | ||||||
| """ | ||||||
| ``` | ||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.