Skip to content

Commit cdd6bf9

Browse files
authored
Add hackathon installation scripts (#16)
* Add hackathon install scripts and restrict submission modes - cross-platform install scripts, hardcoded API URL, test/benchmark modes only * Add automatic Discord registration to install scripts - eliminates manual registration step for hackathon participants * Revert anonymous access, switch to GitHub auth for hackathons - Remove --anonymous flag from CLI - Update install scripts to use GitHub authentication - Re-enable all submission modes - Simplify authentication flow to GitHub OAuth only * update * delete cargo.lock * rename * revert move * update instructions * update * fix gitignore stuff * rename * Update .gitignore * Update src/main.rs Co-authored-by: Copilot <[email protected]> * Update install.sh Co-authored-by: Copilot <[email protected]> * fix latest thingy * installsujdhasdouihgsda ---------
1 parent d9d2c5c commit cdd6bf9

File tree

7 files changed

+381
-8
lines changed

7 files changed

+381
-8
lines changed

β€Ž.gitignoreβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
submission.*
22
target/
3+
scratch.md

β€Ždocs/AMD_workshop/README.mdβ€Ž

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# 🍿 Popcorn CLI - Hackathon Quick Install
2+
3+
Get started with Popcorn CLI in seconds! Choose your installation method based on your operating system.
4+
5+
## πŸš€ One-Line Install Commands
6+
7+
### For Linux/macOS/Unix:
8+
```bash
9+
curl -fsSL https://raw.githubusercontent.com/gpu-mode/popcorn-cli/main/install.sh | bash
10+
```
11+
12+
### For Windows (PowerShell):
13+
```powershell
14+
powershell -ExecutionPolicy Bypass -Command "iwr -UseBasicParsing https://raw.githubusercontent.com/gpu-mode/popcorn-cli/main/install.ps1 | iex"
15+
```
16+
17+
## πŸ“‹ Quick Start After Installation
18+
19+
1. **Restart your terminal** (or run `source ~/.bashrc` / `source ~/.zshrc`)
20+
21+
2. **Register with GitHub** (one-time setup):
22+
```bash
23+
popcorn-cli register github
24+
```
25+
26+
3. **Submit your solution:**
27+
```bash
28+
popcorn-cli submit --gpu MI300 --leaderboard amd-fp8-mm --mode test example.py
29+
```
30+
31+
4. **Interactive mode** (choose GPU and options):
32+
```bash
33+
popcorn-cli submit my_solution.py
34+
```
35+
36+
## πŸ› οΈ Manual Installation
37+
38+
If the scripts don't work, you can manually install:
39+
40+
1. Download the binary for your OS from [releases](https://github.com/gpu-mode/popcorn-cli/releases/tag/v1.1.6)
41+
2. Extract the archive
42+
3. Move the binary to a directory in your PATH
43+
4. Make it executable (Linux/macOS): `chmod +x popcorn-cli`
44+
45+
## πŸ†˜ Troubleshooting
46+
47+
### Command not found after installation
48+
- Restart your terminal
49+
- Check if the install directory is in your PATH:
50+
- Linux/macOS: `echo $PATH`
51+
- Windows: `echo $env:PATH`
52+
- Check if POPCORN_API_URL is set to https://discord-cluster-manager-1f6c4782e60a.herokuapp.com
53+
- Linux/macOS: `echo $POPCORN_API_URL`
54+
- Windows: `echo $env:POPCORN_API_URL`
55+
56+
## πŸ’‘ Need Help?
57+
58+
- Run `popcorn-cli --help` for usage information
59+
- Check the [main repository](https://github.com/gpu-mode/popcorn-cli) and open an issue
60+
- Join the [GPU Mode Discord](https://discord.gg/gpumode) and ask a question in #amd-competition

β€Ždocs/AMD_workshop/example.pyβ€Ž

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import torch
2+
from task import input_t, output_t
3+
4+
def custom_kernel(data: input_t) -> output_t:
5+
"""
6+
Reference implementation of block-scale fp8 gemm
7+
Args:
8+
data: Tuple that expands to:
9+
a: torch.Tensor[float8_e4m3fnuz] of shape [m, k],
10+
b: torch.Tensor[float8_e4m3fnuz] of shape [n, k],
11+
a_scale: torch.Tensor[float32] of shape [m, k // 128],
12+
b_scale: torch.Tensor[float32] of shape [n // 128, k // 128],
13+
c: torch.Tensor[bfloat16] of shape [m, n]
14+
Returns:
15+
Tensor containing output in bf16
16+
"""
17+
# c: [m, n] is pre-allocated memory to avoid timing allocation overhead.
18+
a, b, a_scale, b_scale, c = data
19+
20+
# a is M x K in column-major order, we convert here for simplicity.
21+
a = a.contiguous()
22+
a_scale = a_scale.contiguous()
23+
b_scale = b_scale.contiguous()
24+
25+
# constants
26+
m = a.shape[0]
27+
n = b.shape[0]
28+
k = a.shape[1]
29+
block_shape_n = 128
30+
block_shape_k = 128
31+
scale_n = b_scale.shape[0]
32+
scale_k = b_scale.shape[1]
33+
34+
# Apply scaling to input 'a'
35+
a_scale = a_scale.unsqueeze(-1).repeat(1, 1, block_shape_k) # Shape: [m, scale_k, block_shape_k]
36+
a_scale = a_scale.reshape(m, scale_k * block_shape_k)
37+
a_scale = a_scale[:, :k]
38+
39+
# Dequantize 'a', in your implementation you should do this at the end.
40+
a = a.to(a_scale.dtype) * a_scale
41+
42+
# Apply scaling to input 'b'
43+
b_scale = (
44+
b_scale.view(-1, 1)
45+
.repeat(1, block_shape_n * block_shape_k)
46+
.view(scale_n, scale_k, block_shape_n, block_shape_k)
47+
.permute(0, 2, 1, 3) # Reorder dimensions: [scale_n, blk_n, scale_k, blk_k]
48+
.reshape(scale_n * block_shape_n, scale_k * block_shape_k)
49+
)
50+
b_scale = b_scale[:n, :k]
51+
52+
# Dequantize 'b', in your implementation you should do this at the end.
53+
b = b.to(b_scale.dtype) * b_scale
54+
55+
c[...] = (a @ b.T).to(torch.bfloat16)
56+
return c

β€Žinstall.ps1β€Ž

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Popcorn CLI Hackathon Installer for Windows
2+
# Run with: powershell -ExecutionPolicy Bypass -File install.ps1
3+
4+
param(
5+
[switch]$Force = $false
6+
)
7+
8+
Write-Host "Installing Popcorn CLI for Hackathon (Windows)..." -ForegroundColor Yellow
9+
10+
# Check if running as administrator (optional but recommended)
11+
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
12+
if (-not $isAdmin) {
13+
Write-Host "Not running as administrator. Installation will be user-scoped." -ForegroundColor Yellow
14+
}
15+
16+
# Set variables
17+
$downloadUrl = "https://github.com/gpu-mode/popcorn-cli/releases/latest/download/popcorn-cli-windows.zip"
18+
$tempDir = "$env:TEMP\popcorn-cli-install"
19+
$installDir = "$env:LOCALAPPDATA\popcorn-cli"
20+
$binaryPath = "$installDir\popcorn-cli.exe"
21+
22+
# Create directories
23+
try {
24+
if (Test-Path $tempDir) {
25+
Remove-Item $tempDir -Recurse -Force
26+
}
27+
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
28+
New-Item -ItemType Directory -Path $installDir -Force | Out-Null
29+
Write-Host "Created installation directories" -ForegroundColor Green
30+
} catch {
31+
Write-Host "Failed to create directories: $_" -ForegroundColor Red
32+
exit 1
33+
}
34+
35+
# Download the binary
36+
Write-Host "Downloading from: $downloadUrl" -ForegroundColor Cyan
37+
try {
38+
$zipPath = "$tempDir\popcorn-cli-windows.zip"
39+
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath -UseBasicParsing
40+
Write-Host "Download completed" -ForegroundColor Green
41+
} catch {
42+
Write-Host "Download failed: $_" -ForegroundColor Red
43+
exit 1
44+
}
45+
46+
# Extract the binary
47+
Write-Host "Extracting binary..." -ForegroundColor Cyan
48+
try {
49+
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
50+
51+
# Find the binary (it might be in a subdirectory)
52+
$binarySource = Get-ChildItem -Path $tempDir -Name "popcorn-cli.exe" -Recurse | Select-Object -First 1
53+
if ($binarySource) {
54+
$fullBinaryPath = Join-Path $tempDir $binarySource
55+
Copy-Item $fullBinaryPath $binaryPath -Force
56+
Write-Host "Binary extracted and copied" -ForegroundColor Green
57+
} else {
58+
Write-Host "popcorn-cli.exe not found in archive" -ForegroundColor Red
59+
exit 1
60+
}
61+
} catch {
62+
Write-Host "Extraction failed: $_" -ForegroundColor Red
63+
exit 1
64+
}
65+
66+
# Add to PATH
67+
Write-Host "Adding to PATH..." -ForegroundColor Cyan
68+
try {
69+
$userPath = [Environment]::GetEnvironmentVariable("PATH", "User")
70+
if ($userPath -notlike "*$installDir*") {
71+
$newPath = "$installDir;$userPath"
72+
[Environment]::SetEnvironmentVariable("PATH", $newPath, "User")
73+
Write-Host "Added $installDir to user PATH" -ForegroundColor Green
74+
Write-Host "Please restart your terminal or PowerShell session" -ForegroundColor Yellow
75+
} else {
76+
Write-Host "$installDir already in PATH" -ForegroundColor Green
77+
}
78+
79+
# Also add to current session
80+
$env:PATH = "$installDir;$env:PATH"
81+
} catch {
82+
Write-Host "Could not modify PATH automatically: $_" -ForegroundColor Yellow
83+
Write-Host "Please manually add $installDir to your PATH" -ForegroundColor Yellow
84+
}
85+
86+
# Cleanup
87+
Remove-Item $tempDir -Recurse -Force -ErrorAction SilentlyContinue
88+
89+
# Test installation
90+
Write-Host "Testing installation..." -ForegroundColor Cyan
91+
try {
92+
$version = & $binaryPath --version 2>$null
93+
if ($LASTEXITCODE -eq 0) {
94+
Write-Host "Installation successful!" -ForegroundColor Green
95+
} else {
96+
Write-Host "Binary installed but may not be working correctly" -ForegroundColor Yellow
97+
}
98+
} catch {
99+
Write-Host "Could not test binary: $_" -ForegroundColor Yellow
100+
}
101+
102+
Write-Host ""
103+
Write-Host "Popcorn CLI installed and ready for hackathon!" -ForegroundColor Green
104+
Write-Host ""
105+
Write-Host "Quick Start:" -ForegroundColor Cyan
106+
Write-Host " 1. Restart your terminal/PowerShell" -ForegroundColor White
107+
Write-Host " 2. Register with GitHub: popcorn-cli register github" -ForegroundColor White
108+
Write-Host " 3. Submit your solution: popcorn-cli submit --gpu MI300 --leaderboard amd-fp8-mm --mode test <your-file>" -ForegroundColor White
109+
Write-Host ""
110+
Write-Host "Hackathon mode features:" -ForegroundColor Cyan
111+
Write-Host " - API URL pre-configured" -ForegroundColor White
112+
Write-Host " - GitHub authentication (no Discord setup needed)" -ForegroundColor White
113+
Write-Host " - All modes available: test, benchmark, leaderboard, profile" -ForegroundColor White
114+
Write-Host " - Clean user identification" -ForegroundColor White
115+
Write-Host ""
116+
Write-Host "Need help? Run: popcorn-cli --help" -ForegroundColor White
117+
Write-Host "Example: popcorn-cli submit --gpu MI300 --leaderboard amd-fp8-mm --mode test example.py" -ForegroundColor White
118+
Write-Host ""
119+
Write-Host "Installation location: $installDir" -ForegroundColor Gray

β€Žinstall.shβ€Ž

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Popcorn CLI Hackathon Installer (Unix/Linux/macOS)
6+
# For Windows users: Use install.ps1 instead
7+
echo "🍿 Installing Popcorn CLI for Hackathon (Unix/Linux/macOS)..."
8+
9+
# Check if we're on Windows
10+
if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
11+
echo "⚠️ Detected Windows environment"
12+
echo "For native Windows, please use install.ps1 instead:"
13+
echo " powershell -ExecutionPolicy Bypass -File install.ps1"
14+
echo ""
15+
echo "This script will continue assuming you're in a Unix-like environment (WSL/Git Bash/MSYS2)"
16+
read -p "Continue? (y/N): " -n 1 -r
17+
echo
18+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
19+
exit 0
20+
fi
21+
fi
22+
23+
# Detect OS
24+
OS=""
25+
ARCH=""
26+
BINARY_NAME=""
27+
EXTENSION=""
28+
29+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
30+
OS="linux"
31+
EXTENSION=".tar.gz"
32+
BINARY_NAME="popcorn-cli"
33+
elif [[ "$OSTYPE" == "darwin"* ]]; then
34+
OS="macos"
35+
EXTENSION=".tar.gz"
36+
BINARY_NAME="popcorn-cli"
37+
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
38+
OS="windows"
39+
EXTENSION=".zip"
40+
BINARY_NAME="popcorn-cli.exe"
41+
else
42+
echo "❌ Unsupported operating system: $OSTYPE"
43+
exit 1
44+
fi
45+
46+
echo "βœ… Detected OS: $OS"
47+
48+
# Download URL
49+
DOWNLOAD_URL="https://github.com/gpu-mode/popcorn-cli/releases/latest/download/popcorn-cli-${OS}${EXTENSION}"
50+
TEMP_DIR="/tmp/popcorn-cli-install"
51+
INSTALL_DIR="$HOME/.local/bin"
52+
53+
# Create directories
54+
mkdir -p "$TEMP_DIR"
55+
mkdir -p "$INSTALL_DIR"
56+
57+
echo "πŸ“₯ Downloading from: $DOWNLOAD_URL"
58+
59+
# Download the binary
60+
if command -v curl >/dev/null 2>&1; then
61+
curl -L -o "$TEMP_DIR/popcorn-cli${EXTENSION}" "$DOWNLOAD_URL"
62+
elif command -v wget >/dev/null 2>&1; then
63+
wget -O "$TEMP_DIR/popcorn-cli${EXTENSION}" "$DOWNLOAD_URL"
64+
else
65+
echo "❌ Neither curl nor wget found. Please install one of them."
66+
exit 1
67+
fi
68+
69+
echo "πŸ“¦ Extracting binary..."
70+
71+
# Extract the binary
72+
cd "$TEMP_DIR"
73+
if [[ "$EXTENSION" == ".tar.gz" ]]; then
74+
tar -xzf "popcorn-cli${EXTENSION}"
75+
elif [[ "$EXTENSION" == ".zip" ]]; then
76+
unzip "popcorn-cli${EXTENSION}"
77+
fi
78+
79+
# Find and move the binary
80+
if [[ -f "$BINARY_NAME" ]]; then
81+
chmod +x "$BINARY_NAME"
82+
mv "$BINARY_NAME" "$INSTALL_DIR/"
83+
echo "βœ… Binary installed to $INSTALL_DIR/$BINARY_NAME"
84+
else
85+
echo "❌ Binary not found after extraction"
86+
exit 1
87+
fi
88+
89+
# Add to PATH
90+
SHELL_RC=""
91+
if [[ -n "$ZSH_VERSION" ]]; then
92+
SHELL_RC="$HOME/.zshrc"
93+
elif [[ -n "$BASH_VERSION" ]]; then
94+
SHELL_RC="$HOME/.bashrc"
95+
else
96+
# Try to detect shell
97+
case "$SHELL" in
98+
*/zsh)
99+
SHELL_RC="$HOME/.zshrc"
100+
;;
101+
*/bash)
102+
SHELL_RC="$HOME/.bashrc"
103+
;;
104+
*)
105+
SHELL_RC="$HOME/.profile"
106+
;;
107+
esac
108+
fi
109+
110+
# Check if PATH already contains the directory
111+
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
112+
echo "πŸ”§ Adding $INSTALL_DIR to PATH in $SHELL_RC"
113+
echo "" >> "$SHELL_RC"
114+
echo "# Added by Popcorn CLI installer" >> "$SHELL_RC"
115+
echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$SHELL_RC"
116+
export PATH="$INSTALL_DIR:$PATH"
117+
else
118+
echo "βœ… $INSTALL_DIR already in PATH"
119+
fi
120+
121+
# Cleanup
122+
rm -rf "$TEMP_DIR"
123+
124+
echo ""
125+
echo "πŸŽ‰ Popcorn CLI installed and ready for hackathon!"
126+
echo ""
127+
echo "πŸ“‹ Quick Start:"
128+
echo " 1. Restart your terminal or run: source $SHELL_RC"
129+
echo " 2. Register with GitHub: popcorn-cli register github"
130+
echo " 3. Submit your solution: popcorn-cli submit --gpu MI300 --leaderboard amd-fp8-mm --mode test <your-file>"
131+
echo ""
132+
echo "πŸš€ Hackathon mode features:"
133+
echo " - βœ… API URL pre-configured"
134+
echo " - βœ… GitHub authentication (no Discord setup needed)"
135+
echo " - βœ… All modes available: test, benchmark, leaderboard, profile"
136+
echo " - βœ… Clean user identification"
137+
echo ""
138+
echo "πŸ’‘ Need help? Run: popcorn-cli --help"
139+
echo "πŸ”— Example: popcorn-cli submit --gpu MI300 --leaderboard amd-fp8-mm --mode test example.py"

β€Žsrc/cmd/mod.rsβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,12 @@ pub async fn execute(cli: Cli) -> Result<()> {
111111
let config = load_config()?;
112112
let cli_id = config.cli_id.ok_or_else(|| {
113113
anyhow!(
114-
"cli_id not found in config file ({}). Please run `popcorn register` first.",
114+
"cli_id not found in config file ({}). Please run 'popcorn-cli register' first.",
115115
get_config_path()
116116
.map_or_else(|_| "unknown path".to_string(), |p| p.display().to_string())
117117
)
118118
})?;
119+
119120
// Use filepath from Submit command first, fallback to top-level filepath
120121
let final_filepath = filepath.or(cli.filepath);
121122
submit::run_submit_tui(

0 commit comments

Comments
Β (0)