Skip to content

Commit

Permalink
Update to Generate Grid
Browse files Browse the repository at this point in the history
- Automatic Author Attribution on Latest Blogs (After September 1, 2024)
  • Loading branch information
Danny213123 committed Dec 10, 2024
1 parent b9ab52b commit 4c99560
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 51 deletions.
2 changes: 0 additions & 2 deletions blogs/artificial-intelligence/vllm-optimize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ myst:

# Enhancing vLLM Inference on AMD GPUs

<span style="font-size:0.7em;">11 October, 2024 by {hoverxref}`Clint Greene<clingree>`. </span>

In this blog, we’ll demonstrate the latest performance enhancements in vLLM inference on AMD Instinct accelerators using ROCm. In a nutshell, vLLM optimizes GPU memory utilization, allowing more efficient handling of large language models (LLMs) within existing hardware constraints, maximizing throughput and minimizing latency. We start the blog by briefly explaining how causal language models like Llama 3 and ChatGPT generate text, motivating the need to enhance throughput and reduce latency. If you’re new to vLLM, we also recommend reading our introduction to [Inferencing and serving with vLLM on AMD GPUs](https://rocm.blogs.amd.com/artificial-intelligence/vllm/README.html).
ROCm 6.2 introduces support for the following vLLM features which we will use in this blog post.

Expand Down
2 changes: 0 additions & 2 deletions blogs/artificial-intelligence/vllm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ myst:

# Inferencing and serving with vLLM on AMD GPUs

<span style="font-size:0.7em;">19 September, 2024 by {hoverxref}`Clint Greene<clingree>`. </span>

## Introduction

In the rapidly evolving field of artificial intelligence, Large Language Models (LLMs) have emerged as powerful tools for understanding and generating human-like text. However, deploying these models efficiently at scale presents significant challenges. This is where vLLM comes into play. vLLM is an innovative open-source library designed to optimize the serving of LLMs using advanced techniques. Central to vLLM is PagedAttention, a novel algorithm that enhances the efficiency of the model's attention mechanism by managing it as virtual memory. This approach optimizes GPU memory utilization, facilitating the processing of longer sequences and enabling more efficient handling of large models within existing hardware constraints. Additionally, vLLM incorporates continuous batching to maximize throughput and minimize latency. By leveraging these cutting-edge techniques, vLLM significantly improves the performance and scalability of LLM deployment, allowing organizations to harness the power of state-of-the-art AI models more effectively and economically.
Expand Down
2 changes: 0 additions & 2 deletions blogs/ecosystems-and-partners/fortran-journey/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ myst:

# Introducing AMD's Next-Gen Fortran Compiler

<span style="font-size:0.7em;">2024 November 13 by {hoverxref}`Justin Chang<justchan>`, Brian Cornille, Michael Klemm, and Johanna Potyka. </span>

We are excited to share a brief preview of AMD's
[Next-Gen Fortran Compiler](https://github.com/amd/InfinityHub-CI/blob/main/fortran/README.md),
our new open source Fortran complier supporting OpenMP offloading. AMD's
Expand Down
194 changes: 155 additions & 39 deletions blogs/generate_grid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Index.md Generator
# Updated 2024 November 13
# Version 1.2
# Version 1.3


import os
Expand Down Expand Up @@ -148,6 +148,49 @@ def sort_blogs_by_date(blogs):
return sorted(blogs_with_date, key=lambda blog: blog.date, reverse=True)


def grab_authors(authors_list):

author_pages_dir = (
"./blogs/authors" # Directory where author markdown files are stored
)

author_links = []

for author in authors_list:

# Clean author name and format it correctly for the file system

author_name = author.strip().replace(" ", "-").lower()

# Path to the author's markdown file in the 'authors' directory

author_file = os.path.join(author_pages_dir, f"{author_name}.md")

print(f"Checking for author file: {author_file}") # Debug print

if os.path.exists(author_file):

# If the author file exists, create a clickable link to the author's page

author_page = author_file.replace(
".md", ".html"
) # Convert .md to .html for the link

print(author_page)

author_page = author_page.replace("blogs", ".")

author_links.append(f'<a href="{author_page}">{author.strip()}</a>')
else:

# If no author page exists, display the author's name as plain text

print(f"Author file {author_file} does not exist.")

author_links.append(author.strip())
return ", ".join(author_links) if author_links else ""


def generate_blog_grid(
blogs, output_file="latest_blogs.md", max_blogs=9, max_category=3
):
Expand Down Expand Up @@ -399,9 +442,6 @@ def generate_blog_grid(
eco_grid_items = []

holder = []
author_pages_dir = (
"./blogs/authors" # Directory where author markdown files are stored
)

for index, blog in enumerate(blogs):

Expand Down Expand Up @@ -457,6 +497,8 @@ def generate_blog_grid(

temp_image = image.replace("//", "/").replace("./", "blogs/")

print(f"Date: {date}")

print("\n-------------------------------------------------------------------\n")
print(f"Link: {href}")

Expand All @@ -482,44 +524,11 @@ def generate_blog_grid(
else:

print(f"Image {image} exists.")
# Create authors HTML by checking if an author page exists

author_links = []

for author in authors_list:

# Clean author name and format it correctly for the file system

author_name = author.strip().replace(" ", "-").lower()

# Path to the author's markdown file in the 'authors' directory

author_file = os.path.join(author_pages_dir, f"{author_name}.md")

print(f"Checking for author file: {author_file}") # Debug print

if os.path.exists(author_file):

# If the author file exists, create a clickable link to the author's page

author_page = author_file.replace(
".md", ".html"
) # Convert .md to .html for the link

author_page = author_page.replace("blogs", ".")

author_links.append(f'<a href="{author_page}">{author.strip()}</a>')
else:

# If no author page exists, display the author's name as plain text

print(f"Author file {author_file} does not exist.")

author_links.append(author.strip())
# Join author links with commas

authors_html = ", ".join(author_links) if author_links else ""
if authors_list:

authors_html = grab_authors(authors_list)
if authors_html:

authors_html = f"by {authors_html}"
Expand Down Expand Up @@ -602,6 +611,111 @@ def generate_blog_grid(
return index_template


def author_attribution(blogs, minimum_date="September 1, 2024"):

blogs_to_process = []

for blog in blogs:

if blog.date < datetime.strptime(minimum_date, "%B %d, %Y"):

print(f"Skipping {blog.file_path}: Date is before {minimum_date}.")

continue
else:

blogs_to_process.append(blog)
print(f"Processing {len(blogs_to_process)} blogs...")

print(f"Current working directory as of author attribution: {os.getcwd()}")

print("\n-------------------------------------------------------------------\n")

for blog in blogs_to_process:

authors_list = getattr(blog, "author", "").split(",")
date = blog.date.strftime("%B %d, %Y") if blog.date else "No Date"

if authors_list:

authors_html = grab_authors(authors_list)

if authors_html:

authors_html = authors_html.replace("././", "../../").replace(
".md", ".html"
)

authors_string = f"{date}, by {authors_html}"

print(authors_html)

# replace with just blogs/{author_name}.html

# make it work with markdown and html
# authors_html = f'<span style="font-size:0.7em;">{authors_string}</span>'

print(f"Authors: {authors_string}")

authors_html = f'<div class="date">{authors_string}</div>'
print(f"Current working directory as of write file: {os.getcwd()}")

# grab blog link

readme_file = blog.file_path

with open(readme_file, "r", encoding="utf-8") as file:

lines = file.readlines()
title, line_number = None, None

for i, line in enumerate(lines):

# only check for # , do not check if there are more than one # in the line

if line.startswith("#") and line.count("#") == 1:

title = line

line_number = i

break
if title:

# insert the author attribution after the title
# title
#
# author attribution
#
# content

lines.insert(
line_number + 1,
"""
<style>
.date {
font-size: 13px;
font-weight: 300;
line-height: 22.5px;
text-transform: none;
margin-bottom: 10px;
}
</style>\n""",
)

lines.insert(line_number + 2, f"\n{authors_html}\n")

with open(readme_file, "w", encoding="utf-8") as file:

# add date class style

file.writelines(lines)
print(f"Author attribution inserted in '{readme_file}'.")
else:

print("No authors found in metadata.")


def main():

root_directory = "blogs" # Specify the root directory
Expand Down Expand Up @@ -645,6 +759,8 @@ def main():

generate_blog_grid(sorted_blogs)

author_attribution(sorted_blogs)

# change back working directory

os.chdir("blogs")
Expand Down
2 changes: 0 additions & 2 deletions blogs/software-tools-optimization/amd-smi-overview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ myst:

# Getting to Know Your GPU: A Deep Dive into AMD SMI

<span style="font-size:0.7em;">17 Sep, 2024 by {hoverxref}`Matt Elliott<mael>` </span>

For system administrators and power users working with AMD hardware, performance optimization and efficient monitoring of resources is paramount. The AMD System Management Interface command-line tool, `amd-smi`, addresses these needs.

`amd-smi` is a versatile command-line utility designed to manage and monitor AMD hardware, with a primary focus on GPUs. As the future replacement for `rocm-smi`, `amd-smi` is poised to become the primary tool for AMD hardware management across a wide range of devices. For those new to hardware management or transitioning from other tools, `amd-smi` provides an extensive set of features to help optimize AMD hardware usage.
Expand Down
1 change: 1 addition & 0 deletions blogs/sphinx/requirements.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ablog
rocm-docs-core==1.9.1
sphinx-hoverxref
markdown
5 changes: 1 addition & 4 deletions blogs/sphinx/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,4 @@ watchdog==4.0.1
# via ablog
wrapt==1.16.0
# via deprecated
zipp==3.17.0
# via
# importlib-metadata
# importlib-resources
markdown

0 comments on commit 4c99560

Please sign in to comment.