This repository contains two independent projects developed for the AMD AI Challenge. Both architectures are heavily optimized to run efficiently on AMD ROCm hardware under strict constraints: a maximum of 48 GB VRAM and <30 seconds of execution time per inference.
- 02: VLM OCR Pipeline
- 03: Enterprise RAG Engine
- 04: Intelligent Web Information Retrieval
- 05: AI-Powered Code Repository Repair
- 06: Can Your AI Master the Unknown
- Author
Folder: 02_vlm_ocr/
The objective of this project is to build an intelligent Optical Character Recognition (OCR) pipeline capable of reliably extracting text from uncooperative images, such as US and Chinese license plates, speed limits, and road work signs under adverse conditions (noise, blur, low light, and off-axis angles).
Instead of relying on traditional OCR frameworks, this solution leverages a lightweight Vision-Language Model (VLM) to interpret the images contextually.
Core Model: Qwen2-VL-2B-Instruct.
Why this model? It provides a strong balance between visual comprehension (accurately reading complex characters like "京 A" on Chinese plates) and parameter efficiency, allowing it to easily fit within the strict hardware limits.
- Frameworks: PyTorch, Hugging Face Transformers.
- Platform: AMD ROCm (Radeon Open Compute).
- Infrastructure: Docker.
The AMD evaluation environment imposes strict hardware and execution limits. This pipeline was specifically engineered to survive these constraints:
- Memory Limit (48 GB VRAM): The application strictly controls memory allocation. The model is loaded in
bfloat16precision. We maintain a static execution graph by pre-allocating tensor shapes and limiting themax_new_tokensgeneration to prevent dynamic memory spikes. Explicit VRAM garbage collection (torch.cuda.empty_cache()) is triggered after every inference. - Execution Time (30s per image): To meet the 30-second per-image inference limit, the VLM and its processor are loaded globally during a single "Cold Start" phase (which has a separate 10-minute budget).
- Docker Environment: The container is built strictly on top of the mandated
rocm/pytorchbase image. Uncompressed image size is kept well under the 60 GiB limit by handling dependencies viarequirements.txtwithout squashing Docker layers, preserving the base image signature required by the automated grader. - Normalization Engine: A robust Regex-based post-processing engine cleans the VLM output to exactly match the evaluation criteria (uppercase conversion, whitespace/punctuation stripping, and contextual filtering).
1. Build the Docker Image
cd 02_vlm_ocr
docker build -t agustindiazcano/amd-ocr-challenge:v1 .2. Run Local Inference
docker run --rm \
--device=/dev/kfd --device=/dev/dri \
-v $(pwd)/local_test_images:/app/input \
-v $(pwd)/output:/app/output \
agustindiazcano/amd-ocr-challenge:v1 \
python app.py --input-image /app/input/sample.jpg(Note: Omit --device=/dev/kfd --device=/dev/dri if running CPU-only without AMD ROCm hardware).
Folder: 03_enterprise_rag/
The objective of this project is to build an Enterprise Retrieval-Augmented Generation (RAG) engine capable of ingesting a mixed corpus of internal documents (.pdf, .docx, .xlsx, .csv, .txt, .log, .py, .png, .jpg) and answering extremely precise queries under a strict 30-second inference limit per question.
Because the evaluator executes the app.py script repeatedly as a completely new process for each query, loading the model at every execution would immediately violate the 30-second limit. We solve this by implementing a Client-Server architecture:
- Daemon (
daemon.py): A persistent FastAPI server runs in the background holding the VLM (Qwen2-VL-2B-Instruct) and a localSQLite FTS5index in memory. - Thin Client (
app.py): A lightweight CLI script that passes the evaluator's arguments directly to the daemon via HTTP and reliably writes the JSON output.
- Frameworks: FastAPI, PyTorch, Hugging Face Transformers, SQLite FTS5, pdfplumber, openpyxl, python-docx.
- Platform: AMD ROCm (Radeon Open Compute).
- Infrastructure: Docker.
- Memory Limit (48 GB VRAM): We enforce strict VRAM pre-allocation with fixed array shapes (
max_length=2048) to maintain a static execution graph, eliminating dynamic memory spikes. Explicit garbage collection (torch.cuda.empty_cache()) clears any visual tensors post-inference. - Causal Citations: The system implements a strict causal necessity rule for citations. A document is only cited if removing it makes the answer impossible. The FTS5 index relies purely on deterministic lexical search (BM25) over abstract vectors to ensure no "hallucinated" citations.
- Fault-Tolerance (Corpus Traps): The indexing engine is fortified against deliberate evaluator traps. It silently logs and bypasses completely empty directories, unrecognized binary formats, files lacking read permissions (
chmod 000dropped viaDAC_OVERRIDE), and password-protected encrypted PDFs, without crashing or halting the pipeline. - Strict Evaluator Dependencies: Deep learning packages (
transformers,qwen-vl-utils) are strictly installed using--no-depsto prevent standardpipfrom silently overwriting the mandated ROCm PyTorch base with an incompatible CUDA build.
1. Build the Docker Image
cd 03_enterprise_rag
docker build -t agustindiazcano/amd-rag-challenge:v1 .2. Run Local Evaluation Simulation You can run the simulated hostile environment directly:
cd 03_enterprise_rag
python test_traps.pyThis script will assemble a hostile corpus with unreadable files, start the daemon, perform the 10-minute indexing pass, run an isolated query passing the 30-second strict limit, and evaluate the fallback resilience.
Folder: 04_intelligent_web_information_retrieval/
(Upcoming) Details for the fourth phase of the challenge will be placed here.
Folder: 05_ai_powered_code_repository_repair/
(Upcoming) Details for the fifth phase of the challenge will be placed here.
Folder: 06_can_your_ai_master_the_unknown/
(Upcoming) Details for the sixth and final phase of the challenge will be placed here.
Agustin Diaz-Cano
MS Candidate, Information Systems Engineering
These projects are official submissions for the AMD & LabLab AI Academy Challenge.