Skip to content

feat(glm53): add device-resident HIP backend for MI350P - #1448

Open
azharlabs wants to merge 1 commit into
JustVugg:devfrom
azharlabs:feat/glm53-mi350p-hip
Open

azharlabs wants to merge 1 commit into
JustVugg:devfrom
azharlabs:feat/glm53-mi350p-hip

Conversation

@azharlabs

Copy link
Copy Markdown

Summary

This PR adds a device-resident HIP GPU backend for GLM-5.3-Flash, optimized and validated on AMD Instinct MI350P.

The implementation keeps the main inference pipeline on the GPU, including embeddings, normalization, mHC, KDA, MLA/DSA attention, MoE routing, expert execution, final collapse, and the LM head.

Key changes

  • Added GLM53_BACKEND=auto|gpu|cpu backend selection
  • Added GPU capability detection and startup validation
  • Implemented device-resident KDA with persistent recurrent state
  • Implemented MLA/DSA with paged latent and indexer caches
  • Added deterministic top-k expert routing
  • Added GPU shared and routed expert execution
  • Added a double-banked device expert cache with event-based publication
  • Integrated coli_glm53_gpu_forward() into the production request path
  • Added request-level failure handling and safe CPU fallback behavior
  • Fixed grouped fmt=4 Int4 decoding using offset-binary nibble - 8
  • Added component, integration, pipeline, and quality-gate tests

New files

  • c/glm53_gpu.c
  • c/glm53_gpu.h
  • c/tools/glm53_quality.c
  • GPU context and backend-selection tests
  • mHC, KDA, MLA/DSA, and MoE GPU tests
  • Full 45-layer pipeline tests
  • Production request and fallback integration tests

Validation results

Validation using a real GLM-5.3 checkpoint on MI350P produced:

  • Relative mean NLL delta: 6.65e-6
  • Bitwise GPU determinism: Passed
  • CPU/GPU generated-token agreement: Passed
  • GPU pipeline startup and backend selection: Passed
  • Int4 checkpoint decoding validation: Passed

Additional checks after rebasing onto the latest upstream dev:

  • make -C c glm53: Passed
  • Portable C test suite: Passed
  • Python suite: 722 tests executed
  • 38 tests skipped due to environment or optional dependencies
  • 2 subprocess shutdown tests timed out in the restricted test environment:
    • test_stop_kills_only_the_requested_server
    • test_completion_stops_only_its_own_converter

The HIP test suite was not rerun in the PR preparation environment because MI350P hardware and hipcc were unavailable.

MI350P configuration

export HSA_OVERRIDE_GFX_VERSION=9.4.2
export HIP_ARCH=gfx942
export GLM53_BACKEND=gpu

The backend can also be selected automatically:

export GLM53_BACKEND=auto

Use the CPU backend explicitly with:

export GLM53_BACKEND=cpu

Documentation

Updated:

  • CHANGELOG.md
  • README.md
  • GPU_BACKENDS.md
  • docs/glm53-flash.md
  • docs/cuda.md
  • docs/benchmarks.md
  • docs/ENVIRONMENT.md

Notes

Compiled test binaries and other generated ELF artifacts were intentionally excluded from this PR.

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.

1 participant