Skip to content

Translate prototype_source/semi_structured_sparse.rst - #889

Merged
hyoyoung merged 1 commit into
PyTorchKR:masterfrom
Dabinishere:sss
Oct 15, 2024
Merged

Translate prototype_source/semi_structured_sparse.rst#889
hyoyoung merged 1 commit into
PyTorchKR:masterfrom
Dabinishere:sss

Conversation

@Dabinishere

Copy link
Copy Markdown
Contributor

๋ผ์ด์„ ์Šค ๋™์˜

๋ณ€๊ฒฝํ•ด์ฃผ์‹œ๋Š” ๋‚ด์šฉ์— BSD 3ํ•ญ ๋ผ์ด์„ ์Šค๊ฐ€ ์ ์šฉ๋จ์„ ๋™์˜ํ•ด์ฃผ์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๋” ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๊ธฐ์—ฌํ•˜๊ธฐ ๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”.

๋™์˜ํ•˜์‹œ๋ฉด ์•„๋ž˜ [ ]๋ฅผ [x]๋กœ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”.

  • ๊ธฐ์—ฌํ•˜๊ธฐ ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์˜€์œผ๋ฉฐ, ๋ณธ PR ๋‚ด์šฉ์— BSD 3ํ•ญ ๋ผ์ด์„ ์Šค๊ฐ€ ์ ์šฉ๋จ์— ๋™์˜ํ•ฉ๋‹ˆ๋‹ค.

๊ด€๋ จ ์ด์Šˆ ๋ฒˆํ˜ธ

์ด Pull Request์™€ ๊ด€๋ จ์žˆ๋Š” ์ด์Šˆ ๋ฒˆํ˜ธ๋ฅผ ์ ์–ด์ฃผ์„ธ์š”.

์ด์Šˆ ๋˜๋Š” PR ๋ฒˆํ˜ธ ์•ž์— #์„ ๋ถ™์ด์‹œ๋ฉด ์ œ๋ชฉ์„ ๋ฐ”๋กœ ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. (์˜ˆ. #999 )

PR ์ข…๋ฅ˜

์ด PR์— ํ•ด๋‹น๋˜๋Š” ์ข…๋ฅ˜ ์•ž์˜ [ ]์„ [x]๋กœ ๋ณ€๊ฒฝํ•ด์ฃผ์„ธ์š”.

  • ์˜คํƒˆ์ž๋ฅผ ์ˆ˜์ •ํ•˜๊ฑฐ๋‚˜ ๋ฒˆ์—ญ์„ ๊ฐœ์„ ํ•˜๋Š” ๊ธฐ์—ฌ
  • ๋ฒˆ์—ญ๋˜์ง€ ์•Š์€ ํŠœํ† ๋ฆฌ์–ผ์„ ๋ฒˆ์—ญํ•˜๋Š” ๊ธฐ์—ฌ
  • ๊ณต์‹ ํŠœํ† ๋ฆฌ์–ผ ๋‚ด์šฉ์„ ๋ฐ˜์˜ํ•˜๋Š” ๊ธฐ์—ฌ
  • ์œ„ ์ข…๋ฅ˜์— ํฌํ•จ๋˜์ง€ ์•Š๋Š” ๊ธฐ์—ฌ

PR ์„ค๋ช…

์ด PR๋กœ ๋ฌด์—‡์ด ๋‹ฌ๋ผ์ง€๋Š”์ง€ ๋Œ€๋žต์ ์œผ๋กœ ์•Œ๋ ค์ฃผ์„ธ์š”.
prototype_source/semi_structured_sparse.rst ๋ฌธ์„œ๋ฅผ ๋ฒˆ์—ญํ•˜์˜€์Šต๋‹ˆ๋‹ค.

Semi-structured sparsity derives its name from its unique sparsity pattern, where n out of every 2n elements are pruned. We most often see n=2, hence 2:4 sparsity
Semi-structured sparsity is particularly interesting because it can be efficiently accelerated on GPUs and doesn't degrade model accuracy as much as other sparsity patterns.
๋ฐ˜๊ตฌ์กฐ์  ํฌ์†Œ์„ฑ์€ 2n๊ฐœ์˜ ์š”์†Œ ์ค‘ n๊ฐœ์˜ ์š”์†Œ๊ฐ€ ์ œ๊ฑฐ๋˜๋Š” ๋…ํŠนํ•œ ํฌ์†Œ์„ฑ ํŒจํ„ด์—์„œ ๊ทธ ์ด๋ฆ„์„ ๋”ฐ์™”์Šต๋‹ˆ๋‹ค. ๊ฐ€์žฅ ์ผ๋ฐ˜์ ์œผ๋กœ n=2๊ฐ€ ์ ์šฉ๋˜๋ฏ€๋กœ 2:4 ํฌ์†Œ์„ฑ์ด๋ผ๊ณ  ๋ถˆ๋ฆฝ๋‹ˆ๋‹ค.
๋ฐ˜๊ตฌ์กฐ์  ํฌ์†Œ์„ฑ์€ ํŠนํžˆ GPU์—์„œ ํšจ์œจ์ ์œผ๋กœ ๊ฐ€์†ํ™”ํ•  ์ˆ˜ ์žˆ๊ณ , ๋‹ค๋ฅธ ํฌ์†Œ์„ฑ ํŒจํ„ด๋ณด๋‹ค ๋ชจ๋ธ์˜ ์ •ํ™•๋„๋ฅผ ๋œ ์ €ํ•˜์‹œํ‚ค๊ธฐ ๋•Œ๋ฌธ์— ํฅ๋ฏธ๋กญ์Šต๋‹ˆ๋‹ค.

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.

"๊ฐ€์†ํ™”๋  ์ˆ˜ ์žˆ๊ณ "๊ฐ€ ์ข€๋” ์ž์—ฐ์Šค๋Ÿฌ์šด ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!
line 84์—์„œ ์ˆ˜๋™ํƒœ๋กœ ์‚ฌ์šฉํ•˜์‹  ๊ฒƒ๊ณผ ํ†ต์ผ์„ฑ๋„ ์ƒ๊ธธ ๊ฒƒ ๊ฐ™์•„์š” ๐Ÿ˜€

answers = []

# Loop through all features associated with that example
# ํ•ด๋‹น ์˜ˆ์ œ์™€ ์—ฐ๊ด€๋œ ๋ชจ๋“  ํ”ผ์ฒ˜ ๋ฐ˜๋ณตํ•˜๊ธฐ

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.

TRANSLATION_GUIDE.md ์— ๋”ฐ๋ผ feature๋Š” ํŠน์ง•์ด๋ผ๊ณ  ๋ฒˆ์—ญํ•˜๋Š” ๊ฒƒ์€ ์–ด๋–จ๊นŒ์š”?

@hyoyoung hyoyoung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

์ „๋ฐ˜์ ์œผ๋กœ ์ž˜๋˜์–ด์žˆ์œผ๋‚˜
๋ช‡๊ฐ€์ง€ ํ™•์ธํ•ด๋ด์•ผํ•  ๋ถ€๋ถ„์ด ์žˆ์Šต๋‹ˆ๋‹ค.
ํ™•์ธํ›„์— ์ˆ˜์ • ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

(ํ”„๋กœํ† ํƒ€์ž…) ๋ฐ˜๊ตฌ์กฐ์  (2:4) ํฌ์†Œ์„ฑ(semi-structured (2:4) sparsity)์„ ์ด์šฉํ•œ BERT ๊ฐ€์†ํ™”ํ•˜๊ธฐ
=================================================================
**Author**: `Jesse Cai <https://github.com/jcaip>`_
**์ €์ž**: `Jesse Cai <https://github.com/jcaip>`_ **๋ฒˆ์—ญ**: `Dabin Kang <https://github.com/dabinishere>`_

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

์ €์ž์™€ ๋ฒˆ์—ญ์€ ์ค„๋‚ด๋ฆผ์„ ํ•ด์„œ 2์ค„๋กœ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”


The natural handoff point between these two problems are zeroed-out dense tensors. Our inference solution is designed to compress and accelerate tensors in this format.
We anticipate many users coming up with custom masking solution, as this is an active area of research.
์ด ๋‘ ๋ฌธ์ œ ์‚ฌ์ด์˜ ์ž์—ฐ์Šค๋Ÿฌ์šด ํ•ธ๋“œ์˜คํ”„(handoff) ํฌ์ธํŠธ๋Š” 0์œผ๋กœ ๋œ ๋ฐ€์ง‘ ํ…์„œ์ž…๋‹ˆ๋‹ค. ์ด ํ˜•์‹์˜ ํ…์„œ๋ฅผ ์••์ถ•ํ•˜๊ณ  ๊ฐ€์†ํ™”ํ•˜๋„๋ก ์ถ”๋ก ์„ ์„ค๊ณ„ํ–ˆ์Šต๋‹ˆ๋‹ค.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

์šฉ์–ด์ง‘์—์„œ tensor๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ๋ฒˆ์—ญํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค

# ํ‰๊ฐ€๋ฅผ ์œ„ํ•ด ๋น„๊ตํ•  ๋ฐฐ์น˜ ํฌ๊ธฐ
batch_sizes = [4, 16, 64, 256]
# 2:4 sparsity require fp16, so we cast here for a fair comparison
# 2:4 ํฌ์†Œ์„ฑ์€ fp16์ด ํ•„์š”ํ•˜๋ฏ€๋กœ ๊ณต์ •ํ•œ ๋น„๊ต๋ฅผ ์œ„ํ•ด ์—ฌ๊ธฐ์„œ ์บ์ŠคํŒ…

@hyoyoung hyoyoung Sep 19, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

์—ฌ๊ธฐ์„œ ์บ์ŠคํŒ…์€ ๋ณ€ํ™˜์ด๋‚˜ ํ˜• ๋ณ€ํ™˜์ด๋ผ๊ณ  ์˜์—ญํ•˜๋Š”๊ฒŒ ์ข‹์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค

๋ฐ˜๊ตฌ์กฐ์  ํฌ์†Œ์„ฑ์€ ํŠนํžˆ GPU์—์„œ ํšจ์œจ์ ์œผ๋กœ ๊ฐ€์†ํ™”ํ•  ์ˆ˜ ์žˆ๊ณ , ๋‹ค๋ฅธ ํฌ์†Œ์„ฑ ํŒจํ„ด๋ณด๋‹ค ๋ชจ๋ธ์˜ ์ •ํ™•๋„๋ฅผ ๋œ ์ €ํ•˜์‹œํ‚ค๊ธฐ ๋•Œ๋ฌธ์— ํฅ๋ฏธ๋กญ์Šต๋‹ˆ๋‹ค.

With the introduction of `semi-structured sparsity support <https://pytorch.org/docs/2.1/sparse.html#sparse-semi-structured-tensors>`_, it is possible to prune and accelerate a semi-structured sparse model without leaving PyTorch.
We will explain this process in this tutorial.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

์œ„ 3๋ฌธ์žฅ์€ ๋ฒˆ์—ญ๋˜์—ˆ๋Š”๋ฐ ๋‚จ์•„์žˆ๋Š” ๊ฒƒ์ผ๊นŒ์š”?


By the end of this tutorial, we will have sparsified a BERT question-answering model to be 2:4 sparse, fine-tuning it to recover nearly all F1 loss (86.92 dense vs 86.48 sparse).
Finally, we will accelerate this 2:4 sparse model for inference, yielding a 1.3x speedup.
์ด ํŠœํ† ๋ฆฌ์–ผ์„ ๋๋‚ด๋ฉด, BERT ์งˆ๋ฌธ-๋‹ต๋ณ€ ๋ชจ๋ธ์„ 2:4 ํฌ์†Œ์„ฑ์œผ๋กœ ๊ฐ€์ง€์น˜๊ธฐํ•˜๊ณ , ๊ฑฐ์˜ ๋ชจ๋“  F1 ์†์‹ค(๋ฐ€์ง‘ 86.92 vs ํฌ์†Œ 86.48)์„ ๋ณต๊ตฌํ•˜๋„๋ก ๋ฏธ์„ธ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

์ด ํŠœํ† ๋ฆฌ์–ผ์„ ๋๋‚ด๋ฉด, ~~ ํ•˜๋Š” ๋ชจ๋ธ์ด ์™„์„ฑ๋ฉ๋‹ˆ๋‹ค. ์ •๋„๋Š” ์–ด๋–จ๊นŒ์š”?

@@ -1,31 +1,31 @@
(prototype) Accelerating BERT with semi-structured (2:4) sparsity
(ํ”„๋กœํ† ํƒ€์ž…) ๋ฐ˜๊ตฌ์กฐ์  (2:4) ํฌ์†Œ์„ฑ(semi-structured (2:4) sparsity)์„ ์ด์šฉํ•œ BERT ๊ฐ€์†ํ™”ํ•˜๊ธฐ

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

semi-structure๊ฐ€ ๋ฐ˜๊ตฌ์กฐ์ธ์ง€ ๋ฐ˜์ •ํ˜•์ธ์ง€, ์กฐ๊ธˆ ๊ฒฐ์ •ํ•˜๊ธฐ ์–ด๋ ค์šด ๋ฌธ์ œ์ธ๋ฐ
DB์šฉ์–ด๋ผ๋ฉด ๋ฐ˜์ •ํ˜•์— ์–ด์šธ๋ฆด๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค
https://ko.wikipedia.org/wiki/%EB%B0%98%EC%A0%95%ED%98%95_%EB%8D%B0%EC%9D%B4%ED%84%B0
์–ด๋–ค๊ฒŒ ๋” ๋‚˜์„๊นŒ์š”?

@jaeseong98 jaeseong98 left a comment

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.

๋ฒˆ์—ญํ•˜์‹œ๋А๋ผ ์ˆ˜๊ณ ๋งŽ์œผ์…จ์Šต๋‹ˆ๋‹ค!

2. At the same time, semi-structured sparsity tends to have a milder impact on model accuracy compared to other sparse formats, especially when accounting for more advanced pruning / fine-tuning methods.
NVIDIA has shown in their `white paper <https://arxiv.org/abs/2104.08378>`_ that a simple paradigm of magnitude pruning once to be 2:4 sparse and then retraining the model yields nearly identical model accuracies.
๊ฐ๊ธฐ ๋‹ค๋ฅธ ์žฅ๋‹จ์ ์„ ๊ฐ€์ง„ ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ํฌ์†Œ์„ฑ ๊ตฌ์กฐ๋“ค์ด ์žˆ์Šต๋‹ˆ๋‹ค. ํŠนํžˆ 2:4 ๋ฐ˜๊ตฌ์กฐ์  ํฌ์†Œ ๋ ˆ์ด์•„์›ƒ์€ ๋‘ ๊ฐ€์ง€ ์ด์œ ๋กœ ํฅ๋ฏธ๋กญ์Šต๋‹ˆ๋‹ค:
1. ์ด์ „์˜ ํฌ์†Œ ํ˜•์‹๊ณผ ๋‹ฌ๋ฆฌ ๋ฐ˜๊ตฌ์กฐ์  ํฌ์†Œ์„ฑ์€ GPU์—์„œ ํšจ์œจ์ ์œผ๋กœ ๊ฐ€์†ํ™”๋˜๋„๋ก ์„ค๊ณ„๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

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.

๊ฐ€์†ํ™”ํ•˜๋‹ค์™€ ๊ฐ€์†ํ™”๋˜๋‹ค๊ฐ€ ์„ž์—ฌ์žˆ๋Š”๊ฒƒ ๊ฐ™์•„์„œ ๋‘˜ ์ค‘ ํ•˜๋‚˜๋กœ ํ†ต์ผ์„ฑ์„ ์ฃผ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

@hyoyoung hyoyoung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good

@hyoyoung
hyoyoung requested a review from 9bow October 6, 2024 10:34
@hyoyoung
hyoyoung merged commit f9ee1fd into PyTorchKR:master Oct 15, 2024
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.

5 participants