Skip to content

Instantly share code, notes, and snippets.

@Billy99
Last active July 28, 2026 21:17
Show Gist options
  • Select an option

  • Save Billy99/75db258cc2fe8e571e7e793ba845ab05 to your computer and use it in GitHub Desktop.

Select an option

Save Billy99/75db258cc2fe8e571e7e793ba845ab05 to your computer and use it in GitHub Desktop.

Intel Gaudi Support for MCV - Implementation Guide

Status: Ready for implementation once Gaudi hardware is available Complexity: Medium (1-2 days) Pattern: CLI-based (similar to AMD/ROCm, not NVML) Date Created: 2026-07-28


Table of Contents

  1. Background Research
  2. What I Need From You
  3. Implementation Files
  4. Step-by-Step Implementation
  5. Testing Plan
  6. Risks & Concerns

Background Research

Intel Gaudi Status (as of 2026)

⚠️ IMPORTANT: Intel discontinued their open-source user-space Gaudi driver (SynapseAI Core) in February 2025. The GitHub repository was archived with no further development.

✅ AVAILABLE:

  • Kernel driver (open source, being upstreamed to Linux)
  • hl-smi CLI tool (Habana Labs System Management Interface)
  • Official Intel Gaudi software stack (proprietary)

Sources:

MCV Current GPU Support

MCV currently supports 3 GPU vendors:

  1. NVIDIA (NVML) - Library-based

    • Uses: github.com/NVIDIA/go-nvml/pkg/nvml (Go bindings)
    • Detection: Direct library calls
    • File: mcv/pkg/accelerator/devices/nvml.go
  2. AMD - CLI-based

    • Uses: amd-smi command-line tool
    • Detection: JSON output parsing
    • File: mcv/pkg/accelerator/devices/amd.go
  3. ROCm - CLI-based

    • Uses: rocm-smi command-line tool
    • Detection: Text output parsing
    • File: mcv/pkg/accelerator/devices/rocm.go

Intel Gaudi will follow the AMD pattern (CLI-based).

hl-smi Tool Capabilities

The hl-smi tool provides:

  • Device enumeration
  • Memory information (total, free, used)
  • Power consumption (54V + 12V rails)
  • Driver version
  • Temperature
  • Topology information (NUMA, CPU affinity)
  • Port status

Key Commands:

# Basic device summary
hl-smi

# Query specific metrics in JSON
hl-smi -Q memory.total,memory.free,memory.used -f json

# Query specific metrics in CSV
hl-smi -Q memory.total,memory.free,memory.used -f csv

# Topology information
hl-smi topo

# Daemon mode (monitoring)
hl-smi dmon

What I Need From You

Once you have access to Gaudi hardware, please run these commands and send me the output:

1. Basic Device Detection

hl-smi

What this tells us: Number of devices, basic info, driver version

2. JSON Output Format

hl-smi -Q memory.total,memory.free,memory.used,power.draw -f json

What this tells us: JSON structure for parsing

3. CSV Output Format (alternative)

hl-smi -Q memory.total,memory.free,memory.used,power.draw -f csv

What this tells us: CSV structure (might be easier to parse)

4. All Available Query Fields

hl-smi -h
# Or specifically:
hl-smi -Q --help

What this tells us: What fields we can query

5. Device Details

hl-smi -Q name,driver_version,uuid,pci.bus_id -f json

What this tells us: Unique identifiers and device naming

6. Topology Information

hl-smi topo

What this tells us: NUMA affinity, CPU topology

7. Docker/Container Context

If you're running in a container:

# Inside container with Gaudi access
hl-smi
echo "Exit code: $?"

What this tells us: Whether hl-smi works in containers

Critical Questions to Answer

  1. Device Enumeration: How are devices numbered? (0, 1, 2... like NVIDIA/AMD?)
  2. Product Names: What are the device names? ("Gaudi2"? "Gaudi3"? "HL-205"?)
  3. Architecture Identifiers: Is there an "arch" field? (for Triton cache matching)
  4. Memory Units: Are memory values in bytes, KB, MB, GB?
  5. Driver Version Format: What does the version string look like?

Implementation Files

File 1: /home/bmcfall/src/GKM/mcv/pkg/accelerator/devices/gaudi.go

Status: Skeleton created (see below) Lines of Code: ~350 (estimated) Pattern: Based on amd.go

Key Functions:

  • gaudiCheck() - Detect if hl-smi is available
  • gaudiDeviceStartup() - Initialize device
  • queryHLSMI() - Execute hl-smi and parse output
  • Init() - Enumerate devices and populate GPU info
  • GetGPUInfo() / GetAllGPUInfo() - Return Triton-compatible info
  • GetSummary() / GetAllSummaries() - Return device summaries

File 2: device.go - Modifications Required

Line 34-38: Add GAUDI DeviceType

const (
    MOCK DeviceType = iota
    AMD
    NVML
    ROCM
    GAUDI  // ADD THIS
)

Line 79: Update String() method

func (d DeviceType) String() string {
    return [...]string{"MOCK", "AMD", "NVML", "ROCM", "GAUDI"}[d]
}

Line 162: Add gaudiCheck() to registerDevices()

func registerDevices(r *Registry) {
    if config.IsStubEnabled() {
        cacheFilePath = constants.StubbedCacheFile
        logging.Debugf("Running in stubbed mode, loading static device config")
        staticCheck(r)
    } else {
        // Call individual device check functions
        amdCheck(r)
        rocmCheck(r)
        nvmlCheck(r)
        gaudiCheck(r)  // ADD THIS
    }
}

Line 298-306: Add GAUDI case to Startup()

switch cachedDevice.DeviceType {
case AMD:
    device = &gpuAMD{}
case NVML:
    device = &gpuNvml{}
case ROCM:
    device = &gpuROCm{}
case GAUDI:               // ADD THIS
    device = &gpuGaudi{}  // ADD THIS
default:
    logging.Errorf("Unsupported device type %s", cachedDevice.DeviceType.String())
    return nil
}

File 3: Dockerfile - Add Gaudi Variant

Location: mcv/images/amd64.dockerfile

New Target: mcv-gaudi (similar to mcv-nvidia and mcv-amd)

Base Image Options (TBD - need to research):

  • Option 1: Official Intel Gaudi image (if available)
  • Option 2: Ubuntu + install Gaudi driver packages
  • Option 3: Minimal + hl-smi binary only

Dependencies Needed:

  • hl-smi binary
  • Intel Gaudi driver (for container GPU access)
  • Possibly: libhabana libraries

File 4: Makefile - Add Build Target

.PHONY: image-gaudi
image-gaudi:
    $(CONTAINER_RUNTIME) build \
        --target mcv-gaudi \
        -t $(MCV_IMAGE):gaudi \
        -f images/amd64.dockerfile \
        mcv/

File 5: Documentation

  • mcv/docs/gaudi-support.md - Usage guide
  • Update mcv/README.md - Add Gaudi to supported GPUs
  • Update mcv/docs/unified-mcv-container.md - Add Gaudi to unified image (future)

Step-by-Step Implementation

Phase 1: Device Detection (Day 1)

  1. Get hl-smi output samples (from you)
  2. Create JSON parsing structs based on actual output
  3. Implement queryHLSMI() function
  4. Implement gaudiCheck() detection
  5. Test: Verify hl-smi detection works

Phase 2: Device Enumeration (Day 1-2)

  1. Implement Init() - Parse devices from hl-smi
  2. Map Gaudi fields to TritonGPUInfo:
    • Determine Backend value ("habana"? "gaudi"?)
    • Determine Arch value (Gaudi2 = "gaudi2"?)
    • Determine WarpSize equivalent (or leave empty?)
    • Map memory, driver version, device name
  3. Implement summary methods
  4. Test: Enumerate devices, print info

Phase 3: Cache Support (Day 2)

  1. Implement SetName/SetDeviceType/SetHwType/SetTritonInfo/SetSummaries
  2. Test: Cache write/read cycle
  3. Verify: Device survives cache restoration

Phase 4: Container Image (Day 2)

  1. Research Gaudi container requirements
  2. Create Dockerfile target
  3. Build image
  4. Test: Run in container with GPU access

Phase 5: Integration Testing (Day 2)

  1. Run preflight checks with Gaudi
  2. Verify cache detection works
  3. Test MCV build with Gaudi-compiled kernels
  4. Update documentation

Testing Plan

Unit Tests

Create mcv/pkg/accelerator/devices/gaudi_test.go:

func TestGaudiCheck(t *testing.T) {
    // Test hl-smi detection
}

func TestGaudiDeviceStartup(t *testing.T) {
    // Test device initialization
}

func TestQueryHLSMI(t *testing.T) {
    // Test JSON parsing (with mock output)
}

func TestGaudiCacheRestore(t *testing.T) {
    // Test cache save/restore cycle
}

Integration Tests

  1. Hardware Detection:

    ./mcv --detect-gpu
    # Should show: "Detected Gaudi device(s): X"
  2. Cache Building (if Triton/vLLM supports Gaudi):

    ./mcv build --source /path/to/triton/cache
    # Should create OCI image with Gaudi cache
  3. Container Test:

    podman run --device /dev/accel/accel0 mcv:gaudi --detect-gpu
    # Should detect Gaudi inside container

Manual Verification

  • hl-smi detected when available
  • Devices enumerated correctly
  • Device info matches hl-smi output
  • Cache write/restore works
  • Container image includes hl-smi
  • GPU access works in container

Risks & Concerns

1. Open Source Driver Discontinued ⚠️

Risk: Intel archived the SynapseAI Core user-space driver in Feb 2025.

Impact:

  • May limit long-term support
  • Could affect future Gaudi hardware versions
  • Community contributions unlikely

Mitigation:

  • Document this limitation clearly
  • Mark Gaudi support as "experimental"
  • Consider this a lower-priority feature

2. Triton/vLLM Compatibility ❓

Risk: Unknown if Triton/vLLM supports Gaudi for kernel compilation.

Impact:

  • MCV might detect Gaudi but have no caches to package
  • Feature would be GPU detection only, not full cache support

Mitigation:

  • Research Triton Gaudi support first
  • Document limitations if cache compilation unsupported
  • Consider this a "nice to have" for future

3. Unknown JSON Format ❓

Risk: hl-smi JSON output format is unknown until hardware available.

Impact:

  • Can't finalize implementation until hardware access
  • Might need multiple iterations to get parsing right

Mitigation:

  • Request comprehensive output samples from you
  • Build flexible parsing (handle missing fields gracefully)

4. Container Runtime Requirements ❓

Risk: Gaudi might require special container runtime setup.

Impact:

  • Standard Docker/Podman might not work
  • May need custom device mappings

Mitigation:

  • Research Gaudi container requirements
  • Document setup instructions clearly
  • Test with both Docker and Podman

5. Architecture Mapping 🤔

Risk: Unclear how to map Gaudi architecture to Triton's expectations.

Impact:

  • Cache matching might not work correctly
  • Runtime might not find correct cached kernels

Mitigation:

  • Research Triton's Gaudi backend (if exists)
  • Use conservative defaults
  • Allow manual override via config

Implementation Skeleton

gaudi.go (Partial)

package devices

import (
    "context"
    "encoding/json"
    "fmt"
    "os/exec"
    "strconv"
    "time"

    "github.com/redhat-et/GKM/mcv/pkg/config"
    "github.com/redhat-et/GKM/mcv/pkg/utils"
    logging "github.com/sirupsen/logrus"
)

const gaudiHwType = config.GPU

var (
    gaudiAccImpl = gpuGaudi{}
    gaudiType    DeviceType
)

type gpuGaudi struct {
    name       string
    deviceType DeviceType
    hwType     string
    tritonInfo []TritonGPUInfo
    summaries  []DeviceSummary
    devices    map[int]GPUDevice
}

// TODO: Define based on ACTUAL hl-smi JSON output
type HLSMIDevice struct {
    DeviceID      int    `json:"device_id"`      // Or "index"? Unknown
    DeviceName    string `json:"device_name"`    // "Gaudi2"? "HL-205"?
    MemoryTotal   int64  `json:"memory_total"`   // Bytes? MB? Unknown
    MemoryFree    int64  `json:"memory_free"`
    DriverVersion string `json:"driver_version"`
    UUID          string `json:"uuid"`           // Does it have UUIDs?
    PCIBusID      string `json:"pci_bus_id"`     // PCIe address
    // Add more fields based on actual output
}

func gaudiCheck(r *Registry) {
    if !utils.HasApp("hl-smi") {
        logging.Debug("hl-smi not found, skipping Gaudi detection")
        return
    }

    gaudiType = GAUDI
    if err := addDeviceInterface(r, gaudiType, gaudiHwType, gaudiDeviceStartup); err == nil {
        logging.Debugf("Using %s to obtain GPU info", gaudiAccImpl.Name())
    } else {
        logging.Debugf("Error registering Gaudi: %v", err)
    }
}

func gaudiDeviceStartup() Device {
    a := gaudiAccImpl
    if err := a.InitLib(); err != nil {
        logging.Debugf("Error initializing %s: %v", gaudiType.String(), err)
        return nil
    }
    if err := a.Init(); err != nil {
        logging.Errorf("failed to Init device: %v", err)
        return nil
    }
    logging.Debugf("Using %s to obtain GPU info", gaudiType.String())
    return &a
}

func (g *gpuGaudi) Name() string {
    return gaudiType.String()
}

func (g *gpuGaudi) DevType() DeviceType {
    return gaudiType
}

func (g *gpuGaudi) HwType() string {
    return gaudiHwType
}

func (g *gpuGaudi) InitLib() error {
    // No library initialization needed (CLI-based like AMD)
    return nil
}

func (g *gpuGaudi) Init() error {
    // Query hl-smi to detect and enumerate Gaudi devices
    devices, err := queryHLSMI()
    if err != nil {
        return fmt.Errorf("failed to query hl-smi: %w", err)
    }

    g.devices = make(map[int]GPUDevice, len(devices))

    // Process each device and populate tritonInfo, summaries
    for deviceID, deviceInfo := range devices {
        // TODO: Map Gaudi-specific fields to Triton format
        // CRITICAL UNKNOWNS:
        // - Backend: "habana"? "gaudi"? "intel"?
        // - Arch: "gaudi2"? "gaudi3"? Need to match Triton expectations
        // - WarpSize: Does Gaudi have an equivalent? NVIDIA=32, AMD varies

        tritonInfo := TritonGPUInfo{
            ID:            deviceID,
            Name:          deviceInfo.DeviceName,
            UUID:          deviceInfo.UUID,
            Backend:       "gaudi", // TBD - Need to verify with Triton
            Arch:          "unknown", // TBD - Need actual device info
            WarpSize:      0, // TBD - Unknown if applicable
            MemoryTotalMB: deviceInfo.MemoryTotal / (1024 * 1024), // Assuming bytes
            // PTXVersion: N/A for Gaudi
            // ComputeCapability: N/A for Gaudi
        }

        summary := DeviceSummary{
            ID:            strconv.Itoa(deviceID),
            ProductName:   deviceInfo.DeviceName,
            DriverVersion: deviceInfo.DriverVersion,
        }

        g.devices[deviceID] = GPUDevice{
            ID:         deviceID,
            TritonInfo: tritonInfo,
            Summary:    summary,
        }

        logging.Debugf("Gaudi device %d: %+v", deviceID, tritonInfo)
    }

    return nil
}

func queryHLSMI() (map[int]HLSMIDevice, error) {
    ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
    defer cancel()

    // TODO: Adjust command based on actual hl-smi capabilities
    // Try JSON format first, fall back to CSV if needed
    cmd := exec.CommandContext(ctx, "hl-smi", "-Q",
        "memory.total,memory.free,name,driver_version,uuid,pci.bus_id",
        "-f", "json")

    output, err := cmd.Output()
    if err != nil {
        // Try alternative format/command
        logging.Debugf("Failed to execute hl-smi with JSON: %v, trying alternative", err)
        // TODO: Implement fallback parsing
        return nil, fmt.Errorf("failed to execute hl-smi: %w", err)
    }

    // TODO: Parse actual JSON structure
    // Structure depends on hl-smi output format
    var result map[int]HLSMIDevice
    if err := json.Unmarshal(output, &result); err != nil {
        logging.Debugf("Failed to parse hl-smi JSON output: %v", err)
        logging.Debugf("Raw output: %s", string(output))
        return nil, fmt.Errorf("failed to parse hl-smi output: %w", err)
    }

    return result, nil
}

func (g *gpuGaudi) Shutdown() bool {
    // No cleanup needed for CLI-based detection
    return true
}

func (g *gpuGaudi) GetGPUInfo(gpuID int) (TritonGPUInfo, error) {
    dev, exists := g.devices[gpuID]
    if !exists {
        return TritonGPUInfo{}, fmt.Errorf("GPU device %d not found", gpuID)
    }
    return dev.TritonInfo, nil
}

func (g *gpuGaudi) GetAllGPUInfo() ([]TritonGPUInfo, error) {
    if len(g.tritonInfo) > 0 {
        return g.tritonInfo, nil
    }

    var allTritonInfo []TritonGPUInfo
    for _, dev := range g.devices {
        allTritonInfo = append(allTritonInfo, dev.TritonInfo)
    }
    g.tritonInfo = allTritonInfo
    return allTritonInfo, nil
}

func (g *gpuGaudi) GetSummary(gpuID int) (DeviceSummary, error) {
    dev, exists := g.devices[gpuID]
    if !exists {
        return DeviceSummary{}, fmt.Errorf("GPU device %d not found", gpuID)
    }
    return dev.Summary, nil
}

func (g *gpuGaudi) GetAllSummaries() ([]DeviceSummary, error) {
    if len(g.summaries) > 0 {
        return g.summaries, nil
    }

    var allSummaries []DeviceSummary
    for _, dev := range g.devices {
        allSummaries = append(allSummaries, dev.Summary)
    }
    g.summaries = allSummaries
    return allSummaries, nil
}

// Cache restoration methods (implement following AMD pattern)
func (g *gpuGaudi) SetName(name string) {
    g.name = name
}

func (g *gpuGaudi) SetDeviceType(deviceType DeviceType) {
    g.deviceType = deviceType
}

func (g *gpuGaudi) SetHwType(hwType string) {
    g.hwType = hwType
}

func (g *gpuGaudi) SetTritonInfo(info []TritonGPUInfo) {
    g.tritonInfo = info
    g.devices = make(map[int]GPUDevice, len(info))
    for _, tritonInfo := range info {
        g.devices[tritonInfo.ID] = GPUDevice{
            ID:         tritonInfo.ID,
            TritonInfo: tritonInfo,
        }
    }
}

func (g *gpuGaudi) SetSummaries(summaries []DeviceSummary) {
    g.summaries = summaries
    if g.devices != nil {
        for _, summary := range summaries {
            var gpuID int
            if _, err := fmt.Sscanf(summary.ID, "%d", &gpuID); err == nil {
                if dev, exists := g.devices[gpuID]; exists {
                    dev.Summary = summary
                    g.devices[gpuID] = dev
                }
            }
        }
    }
}

Next Steps Checklist

When Gaudi hardware is available:

  • Run all commands from "What I Need From You" section
  • Send me the outputs
  • I'll finalize the JSON parsing logic
  • I'll complete the Triton field mappings
  • We'll test device detection
  • We'll build the container image
  • We'll test end-to-end functionality

Reference Files

Current MCV implementations to reference:

  1. AMD (CLI pattern): /home/bmcfall/src/GKM/mcv/pkg/accelerator/devices/amd.go

    • Lines 258-290: amdCheck() and device startup
    • Lines 375-410: queryAMDSMI() - JSON parsing pattern
    • Most similar to what Gaudi needs
  2. NVML (Library pattern): /home/bmcfall/src/GKM/mcv/pkg/accelerator/devices/nvml.go

    • Lines 101-113: nvmlCheck() and registration
    • Different pattern (library vs CLI), but shows Device interface implementation
  3. Device Registry: /home/bmcfall/src/GKM/mcv/pkg/accelerator/devices/device.go

    • Lines 34-43: DeviceType enum
    • Lines 153-164: Device registration pattern
    • Lines 286-356: Startup and cache restoration

Contact

Once you have Gaudi hardware access, ping me with the hl-smi output and we'll finalize the implementation!

Estimated Timeline: 1-2 days from receiving hardware output to working implementation.

Questions? Check the "What I Need From You" section for exactly what to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment