Typos
#81
by
iandanforth
- opened
- .gitattributes +0 -1
- The_Ultra-Scale_Playbook_Training_LLMs_on_GPU_Clusters.pdf +0 -3
- assets/images/256px-PDF.png +0 -3
- dist/assets/images/256px-PDF.png +0 -3
- dist/assets/images/memorycoalescing.png +2 -2
- dist/bibliography.bib +1 -10
- dist/distill.bundle.js +1 -1
- dist/distill.bundle.js.map +0 -0
- dist/index.html +0 -0
- dist/main.bundle.js +0 -119
- dist/main.bundle.js.map +0 -0
- package.json +1 -1
- src/bibliography.bib +1 -10
- src/distill.js +0 -6
- src/index.html +0 -0
- src/index.js +0 -2
- src/syncHFSpacesURLHash.js +0 -124
- webpack.config.js +3 -8
.gitattributes
CHANGED
@@ -18,7 +18,6 @@
|
|
18 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
19 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
20 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pdf filter=lfs diff=lfs merge=lfs -text
|
22 |
*.pickle filter=lfs diff=lfs merge=lfs -text
|
23 |
*.pkl filter=lfs diff=lfs merge=lfs -text
|
24 |
*.png filter=lfs diff=lfs merge=lfs -text
|
|
|
18 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
19 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
20 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
|
|
21 |
*.pickle filter=lfs diff=lfs merge=lfs -text
|
22 |
*.pkl filter=lfs diff=lfs merge=lfs -text
|
23 |
*.png filter=lfs diff=lfs merge=lfs -text
|
The_Ultra-Scale_Playbook_Training_LLMs_on_GPU_Clusters.pdf
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:274a19a2577ed220cd3a102b4469c44310e4a7c8e8f8ebc36842d907cb51e127
|
3 |
-
size 14059172
|
|
|
|
|
|
|
|
assets/images/256px-PDF.png
DELETED
Git LFS Details
|
dist/assets/images/256px-PDF.png
DELETED
Git LFS Details
|
dist/assets/images/memorycoalescing.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
dist/bibliography.bib
CHANGED
@@ -316,15 +316,6 @@ url = {https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md}
|
|
316 |
archivePrefix={arXiv},
|
317 |
primaryClass={cs.AI}
|
318 |
}
|
319 |
-
@misc{liu2023ringattentionblockwisetransformers,
|
320 |
-
title={Ring Attention with Blockwise Transformers for Near-Infinite Context},
|
321 |
-
author={Hao Liu and Matei Zaharia and Pieter Abbeel},
|
322 |
-
year={2023},
|
323 |
-
eprint={2310.01889},
|
324 |
-
archivePrefix={arXiv},
|
325 |
-
primaryClass={cs.CL},
|
326 |
-
url={https://arxiv.org/abs/2310.01889},
|
327 |
-
}
|
328 |
@misc{hendrycks2021measuring,
|
329 |
title={Measuring Massive Multitask Language Understanding},
|
330 |
author={Dan Hendrycks and Collin Burns and Steven Basart and Andy Zou and Mantas Mazeika and Dawn Song and Jacob Steinhardt},
|
@@ -497,7 +488,7 @@ url = {https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md}
|
|
497 |
@software{torchao,
|
498 |
title = {torchao: PyTorch native quantization and sparsity for training and inference},
|
499 |
author = {torchao maintainers and contributors},
|
500 |
-
url = {https://github.com/pytorch/
|
501 |
license = {BSD-3-Clause},
|
502 |
month = oct,
|
503 |
year = {2024}
|
|
|
316 |
archivePrefix={arXiv},
|
317 |
primaryClass={cs.AI}
|
318 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
@misc{hendrycks2021measuring,
|
320 |
title={Measuring Massive Multitask Language Understanding},
|
321 |
author={Dan Hendrycks and Collin Burns and Steven Basart and Andy Zou and Mantas Mazeika and Dawn Song and Jacob Steinhardt},
|
|
|
488 |
@software{torchao,
|
489 |
title = {torchao: PyTorch native quantization and sparsity for training and inference},
|
490 |
author = {torchao maintainers and contributors},
|
491 |
+
url = {https://github.com/pytorch/torchao},
|
492 |
license = {BSD-3-Clause},
|
493 |
month = oct,
|
494 |
year = {2024}
|
dist/distill.bundle.js
CHANGED
@@ -2146,7 +2146,7 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
2146 |
function bylineTemplate(frontMatter) {
|
2147 |
return "\n <div class=\"byline grid\">\n <div>\n <h3>Authors</h3>\n <div>\n ".concat(frontMatter.authors.map(function (author, i) {
|
2148 |
return "\n <span class=\"author\">\n ".concat(author.personalURL ? "\n <a class=\"name\" href=\"".concat(author.personalURL, "\">").concat(author.name) + (i + 1 < frontMatter.authors.length ? "," : "") + "</a>" : "\n <span class=\"name\">".concat(author.name) + (i + 1 < frontMatter.authors.length ? "," : "") + "</span>", "\n </span>\n ");
|
2149 |
-
}).join(''), "\n </div>\n </div>\n <div >\n <h3>Affiliation</h3>\n <div><a href=\"https://huggingface.co/\">Hugging Face</a>\n </div>\n </div>\n <div >\n <h3>Published</h3>\n <div>Feb 19, 2025</div>\n </div>\n </div>\n
|
2150 |
}
|
2151 |
var Byline = /*#__PURE__*/function (_HTMLElement4) {
|
2152 |
function Byline() {
|
|
|
2146 |
function bylineTemplate(frontMatter) {
|
2147 |
return "\n <div class=\"byline grid\">\n <div>\n <h3>Authors</h3>\n <div>\n ".concat(frontMatter.authors.map(function (author, i) {
|
2148 |
return "\n <span class=\"author\">\n ".concat(author.personalURL ? "\n <a class=\"name\" href=\"".concat(author.personalURL, "\">").concat(author.name) + (i + 1 < frontMatter.authors.length ? "," : "") + "</a>" : "\n <span class=\"name\">".concat(author.name) + (i + 1 < frontMatter.authors.length ? "," : "") + "</span>", "\n </span>\n ");
|
2149 |
+
}).join(''), "\n </div>\n </div>\n <div >\n <h3>Affiliation</h3>\n <div><a href=\"https://huggingface.co/\">Hugging Face</a>\n </div>\n </div>\n <div >\n <h3>Published</h3>\n <div>Feb 19, 2025</div>\n </div>\n </div>\n");
|
2150 |
}
|
2151 |
var Byline = /*#__PURE__*/function (_HTMLElement4) {
|
2152 |
function Byline() {
|
dist/distill.bundle.js.map
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
dist/index.html
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
dist/main.bundle.js
CHANGED
@@ -5544,133 +5544,14 @@ function _loadFragments() {
|
|
5544 |
return _loadFragments.apply(this, arguments);
|
5545 |
}
|
5546 |
|
5547 |
-
;// ./src/syncHFSpacesURLHash.js
|
5548 |
-
var queryArg = "section";
|
5549 |
-
function syncHFSpacesURLHash() {
|
5550 |
-
// Handle explicit section requests (don't update hash automatically on load)
|
5551 |
-
var hasExplicitRequest = handleExplicitSectionRequest();
|
5552 |
-
|
5553 |
-
// Set up hash change monitoring
|
5554 |
-
updateHashBasedOnHashChange();
|
5555 |
-
|
5556 |
-
// Always set up scroll monitoring to update hash during scrolling
|
5557 |
-
setupScrollMonitoring();
|
5558 |
-
|
5559 |
-
// If no explicit request, we don't update the hash on initial load
|
5560 |
-
// The hash will only start updating when the user scrolls
|
5561 |
-
}
|
5562 |
-
function handleExplicitSectionRequest() {
|
5563 |
-
// Check for section parameter in URL
|
5564 |
-
var urlParams = new URLSearchParams(window.location.search);
|
5565 |
-
var sectionId = urlParams.get(queryArg);
|
5566 |
-
|
5567 |
-
// If we have an explicit section request
|
5568 |
-
if (sectionId) {
|
5569 |
-
var targetElement = document.getElementById(sectionId);
|
5570 |
-
if (targetElement) {
|
5571 |
-
// Slight delay to ensure the browser doesn't try to do its own scrolling first
|
5572 |
-
setTimeout(function () {
|
5573 |
-
targetElement.scrollIntoView();
|
5574 |
-
history.replaceState(null, null, "#".concat(sectionId));
|
5575 |
-
}, 100);
|
5576 |
-
}
|
5577 |
-
return true;
|
5578 |
-
}
|
5579 |
-
|
5580 |
-
// No explicit section parameter found
|
5581 |
-
return false;
|
5582 |
-
}
|
5583 |
-
function setupScrollMonitoring() {
|
5584 |
-
// Variables to manage throttling
|
5585 |
-
var isScrolling = false;
|
5586 |
-
var lastKnownScrollPosition = 0;
|
5587 |
-
var initialScroll = true;
|
5588 |
-
|
5589 |
-
// Add the scroll event listener
|
5590 |
-
window.addEventListener('scroll', function () {
|
5591 |
-
lastKnownScrollPosition = window.scrollY;
|
5592 |
-
if (!isScrolling) {
|
5593 |
-
window.requestAnimationFrame(function () {
|
5594 |
-
// Skip the first scroll event which might be browser's automatic scroll
|
5595 |
-
// to a hash on page load
|
5596 |
-
if (initialScroll) {
|
5597 |
-
initialScroll = false;
|
5598 |
-
} else {
|
5599 |
-
updateHashBasedOnScroll(lastKnownScrollPosition);
|
5600 |
-
}
|
5601 |
-
isScrolling = false;
|
5602 |
-
});
|
5603 |
-
}
|
5604 |
-
isScrolling = true;
|
5605 |
-
});
|
5606 |
-
}
|
5607 |
-
|
5608 |
-
// Function to update the URL hash based on scroll position
|
5609 |
-
function updateHashBasedOnScroll(scrollPosition) {
|
5610 |
-
var closestHeading = findClosestHeading(scrollPosition);
|
5611 |
-
|
5612 |
-
// Update the URL hash if we found a closest element
|
5613 |
-
if (closestHeading && closestHeading.id) {
|
5614 |
-
// Only update if the hash is different to avoid unnecessary operations
|
5615 |
-
if (window.location.hash !== "#".concat(closestHeading.id)) {
|
5616 |
-
silentlyUpdateHash(closestHeading.id);
|
5617 |
-
postMessageToHFSpaces(closestHeading.id);
|
5618 |
-
}
|
5619 |
-
}
|
5620 |
-
}
|
5621 |
-
|
5622 |
-
// Find the closest heading to the current scroll position
|
5623 |
-
function findClosestHeading(scrollPosition) {
|
5624 |
-
// Get only heading elements with IDs that we want to track
|
5625 |
-
var headingsWithIds = Array.from(document.querySelectorAll('h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]'));
|
5626 |
-
|
5627 |
-
// Skip if there are no headings with IDs
|
5628 |
-
if (headingsWithIds.length === 0) return null;
|
5629 |
-
|
5630 |
-
// Find the element closest to the middle of the viewport
|
5631 |
-
var closestHeading = null;
|
5632 |
-
var closestDistance = Infinity;
|
5633 |
-
var viewportMiddle = scrollPosition + window.innerHeight / 2;
|
5634 |
-
|
5635 |
-
// Iterate through all headings to find the closest one
|
5636 |
-
headingsWithIds.forEach(function (heading) {
|
5637 |
-
var headingTop = heading.getBoundingClientRect().top + scrollPosition;
|
5638 |
-
var distance = Math.abs(headingTop - viewportMiddle);
|
5639 |
-
if (distance < closestDistance) {
|
5640 |
-
closestDistance = distance;
|
5641 |
-
closestHeading = heading;
|
5642 |
-
}
|
5643 |
-
});
|
5644 |
-
return closestHeading;
|
5645 |
-
}
|
5646 |
-
|
5647 |
-
// Update hash without triggering scroll or other side effects
|
5648 |
-
function silentlyUpdateHash(id) {
|
5649 |
-
history.replaceState(null, null, "#".concat(id));
|
5650 |
-
}
|
5651 |
-
function updateHashBasedOnHashChange() {
|
5652 |
-
window.addEventListener('hashchange', function () {
|
5653 |
-
var elementId = window.location.hash.slice(1);
|
5654 |
-
postMessageToHFSpaces(elementId);
|
5655 |
-
});
|
5656 |
-
}
|
5657 |
-
function postMessageToHFSpaces(elementId) {
|
5658 |
-
var parentOrigin = "https://huggingface.co";
|
5659 |
-
window.parent.postMessage({
|
5660 |
-
queryString: "".concat(queryArg, "=").concat(elementId)
|
5661 |
-
}, parentOrigin);
|
5662 |
-
}
|
5663 |
-
|
5664 |
;// ./src/index.js
|
5665 |
// import { plotClusters } from './clusters'
|
5666 |
|
5667 |
|
5668 |
-
|
5669 |
document.addEventListener("DOMContentLoaded", function () {
|
5670 |
console.log("DOMContentLoaded");
|
5671 |
loadFragments();
|
5672 |
init_memory_plot();
|
5673 |
-
syncHFSpacesURLHash();
|
5674 |
}, {
|
5675 |
once: true
|
5676 |
});
|
|
|
5544 |
return _loadFragments.apply(this, arguments);
|
5545 |
}
|
5546 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5547 |
;// ./src/index.js
|
5548 |
// import { plotClusters } from './clusters'
|
5549 |
|
5550 |
|
|
|
5551 |
document.addEventListener("DOMContentLoaded", function () {
|
5552 |
console.log("DOMContentLoaded");
|
5553 |
loadFragments();
|
5554 |
init_memory_plot();
|
|
|
5555 |
}, {
|
5556 |
once: true
|
5557 |
});
|
dist/main.bundle.js.map
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
"description": "--- title: \"The Nanotron Gigablogpost\" emoji: π· colorFrom: pink colorTo: red sdk: static pinned: false header: mini ---",
|
12 |
"main": "index.js",
|
13 |
"scripts": {
|
14 |
-
"dev": "webpack serve --open
|
15 |
"build": "NODE_ENV=production webpack"
|
16 |
},
|
17 |
"author": "",
|
|
|
11 |
"description": "--- title: \"The Nanotron Gigablogpost\" emoji: π· colorFrom: pink colorTo: red sdk: static pinned: false header: mini ---",
|
12 |
"main": "index.js",
|
13 |
"scripts": {
|
14 |
+
"dev": "webpack serve --open",
|
15 |
"build": "NODE_ENV=production webpack"
|
16 |
},
|
17 |
"author": "",
|
src/bibliography.bib
CHANGED
@@ -316,15 +316,6 @@ url = {https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md}
|
|
316 |
archivePrefix={arXiv},
|
317 |
primaryClass={cs.AI}
|
318 |
}
|
319 |
-
@misc{liu2023ringattentionblockwisetransformers,
|
320 |
-
title={Ring Attention with Blockwise Transformers for Near-Infinite Context},
|
321 |
-
author={Hao Liu and Matei Zaharia and Pieter Abbeel},
|
322 |
-
year={2023},
|
323 |
-
eprint={2310.01889},
|
324 |
-
archivePrefix={arXiv},
|
325 |
-
primaryClass={cs.CL},
|
326 |
-
url={https://arxiv.org/abs/2310.01889},
|
327 |
-
}
|
328 |
@misc{hendrycks2021measuring,
|
329 |
title={Measuring Massive Multitask Language Understanding},
|
330 |
author={Dan Hendrycks and Collin Burns and Steven Basart and Andy Zou and Mantas Mazeika and Dawn Song and Jacob Steinhardt},
|
@@ -497,7 +488,7 @@ url = {https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md}
|
|
497 |
@software{torchao,
|
498 |
title = {torchao: PyTorch native quantization and sparsity for training and inference},
|
499 |
author = {torchao maintainers and contributors},
|
500 |
-
url = {https://github.com/pytorch/
|
501 |
license = {BSD-3-Clause},
|
502 |
month = oct,
|
503 |
year = {2024}
|
|
|
316 |
archivePrefix={arXiv},
|
317 |
primaryClass={cs.AI}
|
318 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
@misc{hendrycks2021measuring,
|
320 |
title={Measuring Massive Multitask Language Understanding},
|
321 |
author={Dan Hendrycks and Collin Burns and Steven Basart and Andy Zou and Mantas Mazeika and Dawn Song and Jacob Steinhardt},
|
|
|
488 |
@software{torchao,
|
489 |
title = {torchao: PyTorch native quantization and sparsity for training and inference},
|
490 |
author = {torchao maintainers and contributors},
|
491 |
+
url = {https://github.com/pytorch/torchao},
|
492 |
license = {BSD-3-Clause},
|
493 |
month = oct,
|
494 |
year = {2024}
|
src/distill.js
CHANGED
@@ -2105,12 +2105,6 @@ d-appendix > distill-appendix {
|
|
2105 |
<div>Feb 19, 2025</div>
|
2106 |
</div>
|
2107 |
</div>
|
2108 |
-
<div class="side pdf-download">
|
2109 |
-
<a href="https://huggingface.co/spaces/nanotron/ultrascale-playbook/resolve/main/The_Ultra-Scale_Playbook_Training_LLMs_on_GPU_Clusters.pdf">Download PDF
|
2110 |
-
<br>
|
2111 |
-
<img style="width: 32px;" src="../assets/images/256px-PDF.png" alt="PDF"></a>
|
2112 |
-
|
2113 |
-
</div>
|
2114 |
`;
|
2115 |
}
|
2116 |
|
|
|
2105 |
<div>Feb 19, 2025</div>
|
2106 |
</div>
|
2107 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
2108 |
`;
|
2109 |
}
|
2110 |
|
src/index.html
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
src/index.js
CHANGED
@@ -1,11 +1,9 @@
|
|
1 |
// import { plotClusters } from './clusters'
|
2 |
import { init_memory_plot } from './memory'
|
3 |
import { loadFragments } from './fragmentLoader'
|
4 |
-
import { syncHFSpacesURLHash } from './syncHFSpacesURLHash'
|
5 |
|
6 |
document.addEventListener("DOMContentLoaded", () => {
|
7 |
console.log("DOMContentLoaded");
|
8 |
loadFragments();
|
9 |
init_memory_plot();
|
10 |
-
syncHFSpacesURLHash();
|
11 |
}, { once: true });
|
|
|
1 |
// import { plotClusters } from './clusters'
|
2 |
import { init_memory_plot } from './memory'
|
3 |
import { loadFragments } from './fragmentLoader'
|
|
|
4 |
|
5 |
document.addEventListener("DOMContentLoaded", () => {
|
6 |
console.log("DOMContentLoaded");
|
7 |
loadFragments();
|
8 |
init_memory_plot();
|
|
|
9 |
}, { once: true });
|
src/syncHFSpacesURLHash.js
DELETED
@@ -1,124 +0,0 @@
|
|
1 |
-
const queryArg = "section";
|
2 |
-
|
3 |
-
function syncHFSpacesURLHash() {
|
4 |
-
// Handle explicit section requests (don't update hash automatically on load)
|
5 |
-
const hasExplicitRequest = handleExplicitSectionRequest();
|
6 |
-
|
7 |
-
// Set up hash change monitoring
|
8 |
-
updateHashBasedOnHashChange();
|
9 |
-
|
10 |
-
// Always set up scroll monitoring to update hash during scrolling
|
11 |
-
setupScrollMonitoring();
|
12 |
-
|
13 |
-
// If no explicit request, we don't update the hash on initial load
|
14 |
-
// The hash will only start updating when the user scrolls
|
15 |
-
}
|
16 |
-
|
17 |
-
function handleExplicitSectionRequest() {
|
18 |
-
// Check for section parameter in URL
|
19 |
-
const urlParams = new URLSearchParams(window.location.search);
|
20 |
-
const sectionId = urlParams.get(queryArg);
|
21 |
-
|
22 |
-
// If we have an explicit section request
|
23 |
-
if (sectionId) {
|
24 |
-
const targetElement = document.getElementById(sectionId);
|
25 |
-
if (targetElement) {
|
26 |
-
// Slight delay to ensure the browser doesn't try to do its own scrolling first
|
27 |
-
setTimeout(() => {
|
28 |
-
targetElement.scrollIntoView();
|
29 |
-
history.replaceState(null, null, `#${sectionId}`);
|
30 |
-
}, 100);
|
31 |
-
}
|
32 |
-
return true;
|
33 |
-
}
|
34 |
-
|
35 |
-
// No explicit section parameter found
|
36 |
-
return false;
|
37 |
-
}
|
38 |
-
|
39 |
-
function setupScrollMonitoring() {
|
40 |
-
// Variables to manage throttling
|
41 |
-
let isScrolling = false;
|
42 |
-
let lastKnownScrollPosition = 0;
|
43 |
-
let initialScroll = true;
|
44 |
-
|
45 |
-
// Add the scroll event listener
|
46 |
-
window.addEventListener('scroll', function() {
|
47 |
-
lastKnownScrollPosition = window.scrollY;
|
48 |
-
|
49 |
-
if (!isScrolling) {
|
50 |
-
window.requestAnimationFrame(function() {
|
51 |
-
// Skip the first scroll event which might be browser's automatic scroll
|
52 |
-
// to a hash on page load
|
53 |
-
if (initialScroll) {
|
54 |
-
initialScroll = false;
|
55 |
-
} else {
|
56 |
-
updateHashBasedOnScroll(lastKnownScrollPosition);
|
57 |
-
}
|
58 |
-
isScrolling = false;
|
59 |
-
});
|
60 |
-
}
|
61 |
-
|
62 |
-
isScrolling = true;
|
63 |
-
});
|
64 |
-
}
|
65 |
-
|
66 |
-
// Function to update the URL hash based on scroll position
|
67 |
-
function updateHashBasedOnScroll(scrollPosition) {
|
68 |
-
const closestHeading = findClosestHeading(scrollPosition);
|
69 |
-
|
70 |
-
// Update the URL hash if we found a closest element
|
71 |
-
if (closestHeading && closestHeading.id) {
|
72 |
-
// Only update if the hash is different to avoid unnecessary operations
|
73 |
-
if (window.location.hash !== `#${closestHeading.id}`) {
|
74 |
-
silentlyUpdateHash(closestHeading.id);
|
75 |
-
postMessageToHFSpaces(closestHeading.id);
|
76 |
-
}
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
// Find the closest heading to the current scroll position
|
81 |
-
function findClosestHeading(scrollPosition) {
|
82 |
-
// Get only heading elements with IDs that we want to track
|
83 |
-
const headingsWithIds = Array.from(document.querySelectorAll('h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]'));
|
84 |
-
|
85 |
-
// Skip if there are no headings with IDs
|
86 |
-
if (headingsWithIds.length === 0) return null;
|
87 |
-
|
88 |
-
// Find the element closest to the middle of the viewport
|
89 |
-
let closestHeading = null;
|
90 |
-
let closestDistance = Infinity;
|
91 |
-
const viewportMiddle = scrollPosition + window.innerHeight / 2;
|
92 |
-
|
93 |
-
// Iterate through all headings to find the closest one
|
94 |
-
headingsWithIds.forEach(heading => {
|
95 |
-
const headingTop = heading.getBoundingClientRect().top + scrollPosition;
|
96 |
-
const distance = Math.abs(headingTop - viewportMiddle);
|
97 |
-
|
98 |
-
if (distance < closestDistance) {
|
99 |
-
closestDistance = distance;
|
100 |
-
closestHeading = heading;
|
101 |
-
}
|
102 |
-
});
|
103 |
-
|
104 |
-
return closestHeading;
|
105 |
-
}
|
106 |
-
|
107 |
-
// Update hash without triggering scroll or other side effects
|
108 |
-
function silentlyUpdateHash(id) {
|
109 |
-
history.replaceState(null, null, `#${id}`);
|
110 |
-
}
|
111 |
-
|
112 |
-
function updateHashBasedOnHashChange() {
|
113 |
-
window.addEventListener('hashchange', () => {
|
114 |
-
const elementId = window.location.hash.slice(1);
|
115 |
-
postMessageToHFSpaces(elementId);
|
116 |
-
});
|
117 |
-
}
|
118 |
-
|
119 |
-
function postMessageToHFSpaces(elementId) {
|
120 |
-
const parentOrigin = "https://huggingface.co";
|
121 |
-
window.parent.postMessage({ queryString: `${queryArg}=${elementId}` }, parentOrigin);
|
122 |
-
}
|
123 |
-
|
124 |
-
export { syncHFSpacesURLHash };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
webpack.config.js
CHANGED
@@ -99,14 +99,9 @@ module.exports = {
|
|
99 |
],
|
100 |
devtool: process.env.NODE_ENV === 'production' ? 'source-map' : 'eval-source-map',
|
101 |
devServer: {
|
102 |
-
static:
|
103 |
-
|
104 |
-
|
105 |
-
hot: true,
|
106 |
-
watchFiles: ['src/**/*'],
|
107 |
-
client: {
|
108 |
-
overlay: true,
|
109 |
-
},
|
110 |
},
|
111 |
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
112 |
optimization: {
|
|
|
99 |
],
|
100 |
devtool: process.env.NODE_ENV === 'production' ? 'source-map' : 'eval-source-map',
|
101 |
devServer: {
|
102 |
+
static: "./dist", // Serve files from the 'dist' directory
|
103 |
+
open: process.env.NODE_ENV !== 'production', // Automatically open the browser unless in production
|
104 |
+
hot: process.env.NODE_ENV !== 'production', // Enable hot module replacement unless in production
|
|
|
|
|
|
|
|
|
|
|
105 |
},
|
106 |
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
107 |
optimization: {
|