diff --git a/docs/cli-design.md b/docs/cli-design.md index 6feab2035..3fc182813 100644 --- a/docs/cli-design.md +++ b/docs/cli-design.md @@ -901,10 +901,14 @@ flare run ORG/MODEL@gb202 --filename model.safetensors --gpus 0,1,2,3 These examples use `ORG/MODEL` as a repository placeholder. Repositories contain prepared Flare cores, not source Transformers checkpoints. Hardware variants -are separate Hugging Face revisions named `ga102`, `gb10`, `gb202`, `gb206`, and `gb300`. Automatic selection -queries the selected GPUs' PCI device identifiers through NVML without initializing -CUDA. GB10 selects `gb10`; known GB202 devices, including RTX PRO -6000 Blackwell, select `gb202`; known GB206 devices, including GeForce RTX 5060 Ti, select `gb206`; GB300 selects `gb300`; known GA102 devices select `ga102`. All selected GPUs must belong to the same family. +are separate Hugging Face revisions named by NVIDIA GPU platform identifier +(Ampere `ga100`, `ga102`, `ga103`, `ga104`, `ga106`, `ga107`, `ga10b`; +Blackwell `gb10`, `gb100`, `gb102`, `gb10b`, `gb112`, `gb120`, `gb202`, +`gb203`, `gb205`, `gb206`, `gb207`, `gb300`). Automatic selection queries the +selected GPUs' PCI device identifiers through NVML without initializing CUDA, +falling back to CUDA compute capability for integrated Tegra GPUs (`ga10b`, +`gb10b`) that report no PCI ID. All selected GPUs must belong to the same +platform. An unknown identifier or a driver unable to report it requires an explicit revision. GPU selection follows `CUDA_VISIBLE_DEVICES` for both commands. Revision detection runs in a short-lived process so NVML's worker threads cannot @@ -915,9 +919,10 @@ An explicit GPU list must match the core's local rank count. An explicit `--revision` overrides `@revision` and hardware detection. It accepts a branch, tag, or commit, and permits downloading on a machine without NVIDIA -hardware. For `gb10`, `gb202`, and `gb300`, the shared CLI and desktop downloader -tries the corresponding `-tp1` revision if the initial revision lookup returns -HTTP 404. Flare downloads from the resolved commit and records it under the +hardware. For any platform revision beginning with `gb`, the shared CLI and +desktop downloader tries the corresponding `-tp1` revision if the initial revision +lookup returns HTTP 404; Ampere (`ga*`) revisions are not retried. Flare +downloads from the resolved commit and records it under the requested revision for offline use. Flare excludes SHA-256 blob filenames and `*-data-NN-of-NN.safetensors` companions when selecting the primary; multiple primaries require `--filename`. Referenced companions resolve from the primary's @@ -937,7 +942,7 @@ Both commands accept these download options: | Flag | Meaning | Default | |---|---|---| -| `--revision REVISION` | Explicit Hub branch, tag, or commit | Recorded model origin, otherwise detected `ga102`, `gb10`, `gb202`, `gb206`, or `gb300` | +| `--revision REVISION` | Explicit Hub branch, tag, or commit | Recorded model origin, otherwise detected GPU platform revision | | `--filename FILE` | Repository-relative prepared core filename | Sole primary `.safetensors` file | | `--cache-dir PATH` | Parent for the shared Hugging Face download transport cache | Flare model cache | | `--token-file PATH` | File containing a Hub access token (must exist and be non-empty when passed) | `HF_TOKEN`, then `$HF_TOKEN_PATH` / `$HF_HOME/token` / `~/.cache/huggingface/token` when present, otherwise unauthenticated | diff --git a/docs/core-format-design.md b/docs/core-format-design.md index 416d03a62..529c89d27 100644 --- a/docs/core-format-design.md +++ b/docs/core-format-design.md @@ -750,8 +750,9 @@ A published cache entry is named for its selected deployments: `-tp-`, for example `gb202-tp1-202610170923`. An entry containing several TP sizes joins their labels in ascending order, without duplicates: `gb202-tp1+tp2-202610170923`. -The platform is the device identifier recorded by preparation (`ga102`, `gb10`, -`gb202`, `gb206`, or `gb300`), never an SM architecture name. Downloads use the authenticated device +The platform is the NVIDIA GPU platform identifier recorded by preparation (for +example `gb202`, `gb203`, `gb10`, `gb300`, or `ga102`, as listed in +`PLATFORMS`), never an SM architecture name. Downloads use the authenticated device identity; cores without one use `unknown-device`, including union names such as `unknown-device-tp1+tp2-202610170923`. The timestamp records entry creation in UTC with minute resolution. diff --git a/docs/orbit.md b/docs/orbit.md index 9c331b063..2e34f630f 100644 --- a/docs/orbit.md +++ b/docs/orbit.md @@ -215,6 +215,10 @@ sequenceDiagram repository. An explicit `--revision` overrides the suffix; otherwise the controller infers the revision from available candidate GPUs, refusing mixed hardware unless the operator supplies a revision or narrower node/GPU constraints. + Placement matches each candidate GPU's reported revision against the resolved + core's signed platform identity (falling back to compute capability only for + legacy cores without a device identity), so `--revision` selects the Hub branch + without overriding Orbit's platform match. The first candidate node with an available selected GPU acquires the pinned core into its own Flare model cache. `--filename`, `--offline`, and `--tensor-parallel` travel to that node; `--offline` resolves only that @@ -318,8 +322,9 @@ Orbit allocates GPUs within hosts. A DGX Spark is a node with one GPU; a workstation with sixteen RTX PRO 6000 GPUs is a node with sixteen, running one agent. The agent reads its GPUs through NVML, loaded dynamically like the CUDA driver, without creating a context: index, UUID, name, hardware -revision (`gb10`, `gb202`, `gb300` from the PCI device id or compute -capability), memory total and free, and utilization, memory-controller +revision (a `PLATFORMS` identifier from the PCI device id or compute capability, +or `sm{major}{minor}` for an unlisted compute capability), memory total and free, +and utilization, memory-controller utilization (the share of the sample period with memory reads or writes), temperature, and SM clock where NVML reports them. These utilization values are not measurements of bytes per second. Integrated GPUs whose NVML memory query diff --git a/flare-cli/src/cli.rs b/flare-cli/src/cli.rs index 420ebd996..6ae41b15b 100644 --- a/flare-cli/src/cli.rs +++ b/flare-cli/src/cli.rs @@ -203,7 +203,7 @@ pub struct CacheGc { #[derive(Debug, Args, Default, Clone, serde::Serialize, serde::Deserialize)] pub struct HubOptions { - /// Hub revision; uses the model origin when cached, otherwise detects ga102, gb10, gb202, gb206, or gb300. + /// Hub revision; uses the model origin when cached, otherwise detects the GPU's platform. #[arg(long, value_name = "REVISION", help_heading = "Download options")] pub revision: Option, diff --git a/flare-cli/src/orbit/controller.rs b/flare-cli/src/orbit/controller.rs index f6e1f5afa..75ac6f13f 100644 --- a/flare-cli/src/orbit/controller.rs +++ b/flare-cli/src/orbit/controller.rs @@ -2290,8 +2290,9 @@ fn describe( .ok_or("the core path names no file")? .to_owned(); let cluster = runtime_core::core_cluster(authorized); + let hardware = authorized.identity().map_err(|e| e.to_string())?.hardware; let needs = CoreNeeds { - revision: super::gpu::capability_revision(first.architecture[0], first.architecture[1]), + revision: super::gpu::core_revision(&hardware, first.architecture[0], first.architecture[1]), multi_host: cluster.is_some(), rank_bytes: rank_needs.iter().map(|r| r.device_bytes).collect(), reserve_bytes: runtime_core::reserve_bytes(authorized), diff --git a/flare-cli/src/orbit/gpu.rs b/flare-cli/src/orbit/gpu.rs index aed8197a5..64bf76415 100644 --- a/flare-cli/src/orbit/gpu.rs +++ b/flare-cli/src/orbit/gpu.rs @@ -35,7 +35,7 @@ pub struct Gpu { pub uuid: String, /// Product name, such as `NVIDIA GB300`. pub name: String, - /// Flare hardware revision: `gb10`, `gb202`, `gb300`, or `sm{major}{minor}` for any other + /// Flare hardware revision: a `PLATFORMS` name, or `sm{major}{minor}` for an unlisted /// compute capability. pub revision: String, /// Device memory in bytes. NVML reports no device memory for an integrated GPU that shares @@ -218,11 +218,17 @@ pub fn enumerate() -> Result, Failure> { } } -/// The Flare hardware revision of a compute capability: `gb10`, `gb202`, `gb300`, or -/// `sm{major}{minor}`. +/// The Flare hardware revision of a compute capability, for devices the PCI table does not list +/// and cores that record no device identity. pub fn capability_revision(major: i32, minor: i32) -> String { + if major > 0 + && minor >= 0 + && let Some(platform) = + flare_helios::core::naming::platform_from_capability(major as u32, minor as u32) + { + return platform.into(); + } match (major, minor) { - (8, 7) => "ga10b".into(), (12, 1) => "gb10".into(), (12, 0) => "gb202".into(), (10, 3) => "gb300".into(), @@ -230,6 +236,16 @@ pub fn capability_revision(major: i32, minor: i32) -> String { } } +/// The revision a core requires of its GPUs: the platform recorded in its signed device identity +/// when that is one Flare names, otherwise the capability of the architecture it was prepared for +/// (legacy cores record no device identity). +pub fn core_revision(hardware: &str, major: i32, minor: i32) -> String { + if flare_helios::core::naming::PLATFORMS.contains(&hardware) { + return hardware.to_owned(); + } + capability_revision(major, minor) +} + /// The `CUDA_VISIBLE_DEVICES` value that exposes exactly `uuids`, in that order. pub fn visible_devices(uuids: &[String]) -> String { uuids.join(",") @@ -295,25 +311,9 @@ fn text(buffer: &[u8]) -> String { } fn revision(pci_device_id: u32, major: c_int, minor: c_int) -> String { - if let Some(revision) = platform(pci_device_id) { - return revision.into(); - } - capability_revision(major, minor) -} - -/// The PCI ID table of `crate::hardware`, which selects a revision before compute capability. -fn platform(pci_id: u32) -> Option<&'static str> { - if pci_id & 0xffff != 0x10de { - return None; - } - match pci_id >> 16 { - device if flare_helios::core::naming::GB300_DEVICES.contains(&device) => Some("gb300"), - 0x2e12 => Some("gb10"), - 0x2b85 | 0x2b87 | 0x2b8c | 0x2bb1 | 0x2bb2 | 0x2bb3 | 0x2bb4 | 0x2bb5 | 0x2bb9 | 0x2bbc => { - Some("gb202") - } - _ => None, - } + flare_helios::core::naming::platform_from_pci(pci_device_id) + .map(str::to_owned) + .unwrap_or_else(|| capability_revision(major, minor)) } /// Total and available host memory in bytes, which an integrated GPU allocates from. @@ -347,19 +347,38 @@ mod tests { assert_eq!(revision(0x31c210de, 9, 9), "gb300"); assert_eq!(revision(0x31c310de, 9, 9), "gb300"); assert_eq!(revision(0x2e1210de, 12, 1), "gb10"); + assert_eq!(revision(0x2e1310de, 12, 1), "gb10"); assert_eq!(revision(0x2bb410de, 12, 0), "gb202"); assert_eq!(revision(0x2b8510de, 9, 9), "gb202"); + assert_eq!(revision(0x2c3110de, 12, 0), "gb203"); + assert_eq!(revision(0x290110de, 10, 0), "gb100"); + assert_eq!(revision(0x220410de, 8, 6), "ga102"); + assert_eq!(revision(0x248410de, 8, 6), "ga104"); } #[test] fn unknown_pci_ids_fall_back_to_compute_capability() { assert_eq!(revision(0x31c410de, 10, 3), "gb300"); assert_eq!(revision(0x31c21234, 9, 0), "sm90"); - assert_eq!(revision(0x2e1310de, 12, 1), "gb10"); + assert_eq!(revision(0x2e0710de, 12, 1), "gb10"); assert_eq!(revision(0x2c0010de, 12, 0), "gb202"); assert_eq!(revision(0x2bb41234, 9, 0), "sm90"); assert_eq!(revision(0x233010de, 9, 0), "sm90"); - assert_eq!(revision(0x290110de, 10, 0), "sm100"); + assert_eq!(revision(0x29ff10de, 10, 0), "sm100"); + assert_eq!(revision(0, 8, 7), "ga10b"); + assert_eq!(revision(0, 11, 0), "gb10b"); + assert_eq!(revision(0x24ff10de, 8, 6), "sm86"); + } + + #[test] + fn a_core_requires_the_revision_its_device_identity_records() { + // Compute capability 12.0 covers several dies, so the signed identity decides. + assert_eq!(core_revision("gb203", 12, 0), "gb203"); + assert_eq!(core_revision("ga104", 8, 6), "ga104"); + // A legacy core records no device identity and keeps the capability fallback. + assert_eq!(core_revision("", 12, 0), "gb202"); + assert_eq!(core_revision("", 11, 0), "gb10b"); + assert_eq!(core_revision("sm120", 9, 0), "sm90"); } #[test] diff --git a/flare-cli/src/orbit/plan.rs b/flare-cli/src/orbit/plan.rs index df667c840..b365be00a 100644 --- a/flare-cli/src/orbit/plan.rs +++ b/flare-cli/src/orbit/plan.rs @@ -35,8 +35,8 @@ const GIB: f64 = (1u64 << 30) as f64; /// What a core needs from the pool. #[derive(Clone, Debug)] pub struct Needs { - /// The hardware revision every GPU of the group must have: `gb10`, `gb202`, `gb300`, or - /// `sm{major}{minor}`. + /// The hardware revision every GPU of the group must have: a `PLATFORMS` name, or + /// `sm{major}{minor}` for a core that records no device identity. pub revision: String, /// True for a multi-host core: one node per rank, one GPU each. False for a single-host /// tensor-parallel core: one node with one GPU per rank, run as one process. diff --git a/flare/src/catalog.rs b/flare/src/catalog.rs index 0a4cbcfff..d5ee23e05 100644 --- a/flare/src/catalog.rs +++ b/flare/src/catalog.rs @@ -558,14 +558,42 @@ mod tests { assert_eq!(entry.build_target_match, Some(target == published)); } } - let refs = serde_json::from_value(json!({"branches": [ - {"name": "ga102-tp1"}, {"name": "ga10b-tp1"}, {"name": "gb10-tp1"}, {"name": "gb202"}, {"name": "gb206"}, {"name": "gb300-tp8"} - ]})).unwrap(); + let refs = serde_json::from_value(json!({ + "branches": flare_helios::core::naming::PLATFORMS + .iter() + .enumerate() + .map(|(i, p)| { + let suffix = ["", "-tp1", "-tp8"][i % 3]; + json!({"name": format!("{p}{suffix}")}) + }) + .collect::>() + })) + .unwrap(); let mut entry = CatalogEntry::default(); let branches = apply_refs(&mut entry, refs, Some(target)); assert_eq!(entry.build_target_match, Some(true)); assert_eq!(branch_platform(select_revision(&branches, Some(target)).unwrap()), Some(target)); } + // Platforms whose names share a prefix (gb10 vs gb100/gb102/gb10b, gb202 vs gb203) + // must never match each other. + let branches = ["gb10", "gb100-tp1", "gb102-tp1", "gb10b-tp1", "gb202", "gb203-tp1"] + .map(String::from) + .into_iter() + .collect(); + for (target, expected) in [ + ("gb10", "gb10"), + ("gb100", "gb100-tp1"), + ("gb102", "gb102-tp1"), + ("gb10b", "gb10b-tp1"), + ("gb202", "gb202"), + ("gb203", "gb203-tp1"), + ] { + assert_eq!( + select_revision(&branches, Some(target)).map(String::as_str), + Some(expected) + ); + assert_eq!(branch_platform(expected), Some(target)); + } } #[test] fn unknown_builds_or_hardware_do_not_hide_discovery_entries() { diff --git a/helios/src/core/naming.rs b/helios/src/core/naming.rs index ddd6b7d34..ebeef41c1 100644 --- a/helios/src/core/naming.rs +++ b/helios/src/core/naming.rs @@ -11,59 +11,152 @@ use std::time::{SystemTime, UNIX_EPOCH}; /// Platforms a core may be named for. These are the NVIDIA device -/// identifiers Flare already uses for revisions, not SM architecture names. -pub const PLATFORMS: [&str; 6] = ["ga102", "ga10b", "gb10", "gb202", "gb206", "gb300"]; +/// identifiers Flare uses for revisions, not SM architecture names. +pub const PLATFORMS: [&str; 19] = [ + "ga100", "ga102", "ga103", "ga104", "ga106", "ga107", "ga10b", "gb10", "gb100", "gb102", + "gb10b", "gb112", "gb120", "gb202", "gb203", "gb205", "gb206", "gb207", "gb300", +]; -/// Platform for one NVIDIA PCI id in NVML's `device<<16 | vendor` layout. -/// -/// This table is the single source consumed by Flare's device detection and by -/// core export naming; do not duplicate the identifiers elsewhere. -pub const GB202_DEVICES: [u32; 9] = [ - 0x2b85, 0x2b87, 0x2b8c, 0x2bb1, 0x2bb2, 0x2bb3, 0x2bb4, 0x2bb5, 0x2bb9, +/// GA100 device identifiers for the SM80 platform: A100, A800, A30, AX800, and CMP 170HX. +pub const GA100_DEVICES: [u32; 28] = [ + 0x2080, 0x2081, 0x2082, 0x20b0, 0x20b1, 0x20b2, 0x20b3, 0x20b4, 0x20b5, 0x20b6, 0x20b7, + 0x20b8, 0x20b9, 0x20bb, 0x20bd, 0x20be, 0x20bf, 0x20c0, 0x20c2, 0x20f0, 0x20f1, 0x20f2, + 0x20f3, 0x20f5, 0x20f6, 0x20fd, 0x20fe, 0x20ff, +]; + +/// GA102 device identifiers for the SM86 platform: GeForce RTX 3090 Ti/3090/3080 Ti/3080/3070 Ti, +/// RTX A6000/A5500/A5000/A4500, A40, A10/A10G/A10M, and CMP 90HX. +pub const GA102_DEVICES: [u32; 21] = [ + 0x2200, 0x2203, 0x2204, 0x2205, 0x2206, 0x2207, 0x2208, 0x220a, 0x220d, 0x2216, 0x222b, + 0x222f, 0x2230, 0x2231, 0x2232, 0x2233, 0x2235, 0x2236, 0x2237, 0x2238, 0x223f, +]; + +/// GA103 device identifiers for the SM86 platform: GeForce RTX 3060 Ti (GA103), RTX 3080 Ti +/// Mobile/Laptop, and RTX A5500 Laptop. +pub const GA103_DEVICES: [u32; 4] = [0x2414, 0x2420, 0x2438, 0x2460]; + +/// GA104 device identifiers for the SM86 platform: GeForce RTX 3070 Ti/3070/3060 Ti/3060, +/// RTX 3080/3070 Mobile, RTX A4000/A4500/A5000 Mobile/A3000 Mobile, and CMP 70HX. +pub const GA104_DEVICES: [u32; 38] = [ + 0x2480, 0x2482, 0x2483, 0x2484, 0x2486, 0x2487, 0x2488, 0x2489, 0x248a, 0x248c, 0x248d, + 0x248e, 0x249c, 0x249d, 0x249f, 0x24a0, 0x24a4, 0x24ac, 0x24ad, 0x24af, 0x24b0, 0x24b1, + 0x24b6, 0x24b7, 0x24b8, 0x24b9, 0x24ba, 0x24bb, 0x24bf, 0x24c0, 0x24c7, 0x24c8, 0x24c9, + 0x24dc, 0x24dd, 0x24df, 0x24e0, 0x24fa, +]; + +/// GA106 device identifiers for the SM86 platform: GeForce RTX 3060/3050, mobile variants, and +/// RTX A2000. +pub const GA106_DEVICES: [u32; 17] = [ + 0x2501, 0x2503, 0x2504, 0x2505, 0x2507, 0x2508, 0x2509, 0x2520, 0x2521, 0x2523, 0x252f, + 0x2531, 0x2544, 0x2560, 0x2561, 0x2563, 0x2571, +]; + +/// GA107 device identifiers for the SM86 platform: GeForce RTX 3050/2050, MX570, RTX A1000/A400/ +/// A500/A2000 Mobile, and A2/A16. +pub const GA107_DEVICES: [u32; 34] = [ + 0x2582, 0x2583, 0x2584, 0x25a0, 0x25a2, 0x25a3, 0x25a4, 0x25a5, 0x25a6, 0x25a7, 0x25a9, + 0x25aa, 0x25ab, 0x25ac, 0x25ad, 0x25af, 0x25b0, 0x25b2, 0x25b5, 0x25b6, 0x25b8, 0x25b9, + 0x25ba, 0x25bb, 0x25bc, 0x25bd, 0x25e0, 0x25e2, 0x25e5, 0x25ec, 0x25ed, 0x25f9, 0x25fa, + 0x25fb, +]; + +/// GB10 and RTX Spark N1X (GB20B) device identifiers for the SM121 platform. +pub const GB10_DEVICES: [u32; 6] = [0x2e02, 0x2e03, 0x2e06, 0x2e12, 0x2e13, 0x2e2a]; + +/// GB100 device identifiers for the SM100 platform: B200, HGX B200, HGX GB200, and B100. +pub const GB100_DEVICES: [u32; 11] = [ + 0x2900, 0x2901, 0x2909, 0x290a, 0x2920, 0x2924, 0x2925, 0x293d, 0x2940, 0x2941, 0x297e, +]; + +/// GB102 device identifiers for the SM100 platform: B100 and DRIVE P2021 variants. +pub const GB102_DEVICES: [u32; 5] = [0x2980, 0x29bb, 0x29bc, 0x29c0, 0x29f1]; + +/// GB10B device identifiers for the SM110 platform: Jetson AGX Thor and Tegra RP iGPU. +pub const GB10B_DEVICES: [u32; 2] = [0x2b00, 0x3400]; + +/// GB112 device identifiers for Blackwell data-center derivatives. +pub const GB112_DEVICES: [u32; 3] = [0x3200, 0x3224, 0x323e]; + +/// GB120 device identifiers for Blackwell data-center derivatives. +pub const GB120_DEVICES: [u32; 1] = [0x3340]; + +/// GB202 device identifiers for the SM120 platform: GeForce RTX 5090/5090 D and RTX PRO +/// 6000/6000D/5500/5000 Blackwell. +pub const GB202_DEVICES: [u32; 11] = [ + 0x2b85, 0x2b87, 0x2b8c, 0x2bb1, 0x2bb2, 0x2bb3, 0x2bb4, 0x2bb5, 0x2bb9, 0x2bbc, 0x2bbd, ]; -/// GB206 device identifiers for the SM120 platform: GeForce RTX 5060 Ti, 5060, -/// and mobile/workstation variants. +/// GB203 device identifiers for the SM120 platform: GeForce RTX 5080/5070 Ti/5070, RTX 5090/5080 +/// Mobile, and RTX PRO 4500/4000/5000 Mobile/Embedded Blackwell. +pub const GB203_DEVICES: [u32; 15] = [ + 0x2c02, 0x2c05, 0x2c09, 0x2c18, 0x2c19, 0x2c31, 0x2c33, 0x2c34, 0x2c38, 0x2c39, 0x2c3a, + 0x2c58, 0x2c59, 0x2c77, 0x2c79, +]; + +/// GB205 device identifiers for the SM120 platform: GeForce RTX 5070 SUPER/5070/5060, RTX 5070 Ti +/// Mobile, and RTX PRO 3000 Laptop Blackwell. +pub const GB205_DEVICES: [u32; 6] = [0x2f02, 0x2f04, 0x2f06, 0x2f18, 0x2f38, 0x2f58]; + +/// GB206 device identifiers for the SM120 platform: GeForce RTX 5060 Ti/5060, RTX 5070/5060 +/// Mobile, and RTX PRO 2000 Blackwell. pub const GB206_DEVICES: [u32; 9] = [ 0x2d04, 0x2d05, 0x2d18, 0x2d19, 0x2d30, 0x2d39, 0x2d58, 0x2d59, 0x2d79, ]; -/// GB10 and RTX Spark N1X device identifiers for the SM121 platform. -pub const GB10_DEVICES: [u32; 5] = [0x2e02, 0x2e03, 0x2e06, 0x2e12, 0x2e2a]; +/// GB207 device identifiers for the SM120 platform: GeForce RTX 5050, mobile variants, and +/// RTX PRO 1000/500 Blackwell. +pub const GB207_DEVICES: [u32; 6] = [0x2d83, 0x2d98, 0x2db8, 0x2db9, 0x2dd8, 0x2df9]; -/// GA102 device identifiers for the SM86 platform: GeForce RTX 3090 Ti, 3090, -/// 3080, 3080 Ti, 3080 12 GB and 3080 LHR. -pub const GA102_DEVICES: [u32; 6] = [0x2203, 0x2204, 0x2206, 0x2208, 0x220a, 0x2216]; +/// GB110 (GB300/B300) device identifiers for the SM103 platform. `0x31c3` is the SM103 GPU of +/// DGX Station GB300. +pub const GB300_DEVICES: [u32; 9] = [ + 0x3180, 0x3182, 0x3183, 0x3184, 0x31a1, 0x31c0, 0x31c2, 0x31c3, 0x31fe, +]; -/// GB300 device identifiers. `0x31c3` is the SM103 GPU of DGX Station GB300. -pub const GB300_DEVICES: [u32; 2] = [0x31c2, 0x31c3]; +const PCI_PLATFORMS: &[(&str, &[u32])] = &[ + ("ga100", &GA100_DEVICES), + ("ga102", &GA102_DEVICES), + ("ga103", &GA103_DEVICES), + ("ga104", &GA104_DEVICES), + ("ga106", &GA106_DEVICES), + ("ga107", &GA107_DEVICES), + ("gb10", &GB10_DEVICES), + ("gb100", &GB100_DEVICES), + ("gb102", &GB102_DEVICES), + ("gb10b", &GB10B_DEVICES), + ("gb112", &GB112_DEVICES), + ("gb120", &GB120_DEVICES), + ("gb202", &GB202_DEVICES), + ("gb203", &GB203_DEVICES), + ("gb205", &GB205_DEVICES), + ("gb206", &GB206_DEVICES), + ("gb207", &GB207_DEVICES), + ("gb300", &GB300_DEVICES), +]; +/// Platform for one NVIDIA PCI id in NVML's `device<<16 | vendor` layout. +/// +/// These tables are the single source consumed by Flare's device detection, by +/// core export naming, and by the Orbit agent's reported revision; do not +/// duplicate the identifiers elsewhere. pub fn platform_from_pci(pci_id: u32) -> Option<&'static str> { if pci_id & 0xffff != 0x10de { return None; } let device = pci_id >> 16; - if GB10_DEVICES.contains(&device) { - return Some("gb10"); - } - if GB300_DEVICES.contains(&device) { - return Some("gb300"); - } - if GA102_DEVICES.contains(&device) { - return Some("ga102"); - } - if GB206_DEVICES.contains(&device) { - return Some("gb206") - } - GB202_DEVICES.contains(&device).then_some("gb202") + PCI_PLATFORMS + .iter() + .find_map(|(platform, devices)| devices.contains(&device).then_some(*platform)) } /// Platform for integrated Tegra GPUs that have no PCI device ID in NVML. /// -/// Compute capability 8.7 uniquely identifies the NVIDIA Orin (GA10B) GPU. +/// Compute capability 8.7 uniquely identifies NVIDIA Orin (GA10B), and 11.0 +/// uniquely identifies NVIDIA Thor (GB10B). pub fn platform_from_capability(major: u32, minor: u32) -> Option<&'static str> { match (major, minor) { (8, 7) => Some("ga10b"), + (11, 0) => Some("gb10b"), _ => None, } } @@ -197,47 +290,60 @@ mod tests { #[test] fn pci_ids_select_the_platform_identifier() { - for device in [0x2e02, 0x2e03, 0x2e06, 0x2e12, 0x2e2a] { - assert_eq!( - platform_from_pci(device << 16 | 0x10de), - Some("gb10"), - "{device:#06x}" - ); + let mut seen = std::collections::HashSet::new(); + for &(platform, devices) in PCI_PLATFORMS { + assert!(PLATFORMS.contains(&platform), "missing {platform}"); + for &device in devices { + assert!( + seen.insert(device), + "duplicate PCI device {device:#06x} in {platform}" + ); + assert_eq!( + platform_from_pci(device << 16 | 0x10de), + Some(platform), + "{platform} {device:#06x}" + ); + assert_eq!( + platform_from_pci(device << 16 | 0x1af4), + None, + "non-NVIDIA vendor {device:#06x}" + ); + } } + // Representative literals across Ampere and Blackwell dies. + assert_eq!(platform_from_pci(0x20b2_10de), Some("ga100")); + assert_eq!(platform_from_pci(0x2204_10de), Some("ga102")); + assert_eq!(platform_from_pci(0x2230_10de), Some("ga102")); + assert_eq!(platform_from_pci(0x2414_10de), Some("ga103")); + assert_eq!(platform_from_pci(0x2484_10de), Some("ga104")); + assert_eq!(platform_from_pci(0x2503_10de), Some("ga106")); + assert_eq!(platform_from_pci(0x2582_10de), Some("ga107")); + assert_eq!(platform_from_pci(0x2e12_10de), Some("gb10")); + assert_eq!(platform_from_pci(0x2e13_10de), Some("gb10")); + assert_eq!(platform_from_pci(0x2901_10de), Some("gb100")); + assert_eq!(platform_from_pci(0x29bc_10de), Some("gb102")); + assert_eq!(platform_from_pci(0x2b00_10de), Some("gb10b")); + assert_eq!(platform_from_pci(0x3200_10de), Some("gb112")); + assert_eq!(platform_from_pci(0x3340_10de), Some("gb120")); + assert_eq!(platform_from_pci(0x2b85_10de), Some("gb202")); + assert_eq!(platform_from_pci(0x2bbc_10de), Some("gb202")); + assert_eq!(platform_from_pci(0x2bbd_10de), Some("gb202")); + assert_eq!(platform_from_pci(0x2c31_10de), Some("gb203")); + assert_eq!(platform_from_pci(0x2c02_10de), Some("gb203")); + assert_eq!(platform_from_pci(0x2f04_10de), Some("gb205")); + assert_eq!(platform_from_pci(0x2d04_10de), Some("gb206")); + assert_eq!(platform_from_pci(0x2d83_10de), Some("gb207")); + assert_eq!(platform_from_pci(0x3182_10de), Some("gb300")); assert_eq!(platform_from_pci(0x31c2_10de), Some("gb300")); assert_eq!(platform_from_pci(0x31c3_10de), Some("gb300")); - for device in GB202_DEVICES { - assert_eq!( - platform_from_pci(device << 16 | 0x10de), - Some("gb202"), - "{device:#06x}" - ); - } - for device in GB206_DEVICES { - assert_eq!( - platform_from_pci(device << 16 | 0x10de), - Some("gb206"), - "{device:#06x}" - ); - } - for device in GA102_DEVICES { - assert_eq!( - platform_from_pci(device << 16 | 0x10de), - Some("ga102"), - "{device:#06x}" - ); - } - assert_eq!(platform_from_pci(0x2d04_10de), Some("gb206")); - assert_eq!(platform_from_pci(0x2d04_1af4), None); - assert_eq!(platform_from_pci(0x2204_1af4), None); - assert_eq!(platform_from_pci(0x2484_10de), None); - assert_eq!(platform_from_pci(0x2bbc_1af4), None); - assert_eq!(platform_from_pci(0x31c2_1af4), None); - assert_eq!(platform_from_pci(0x31c3_1af4), None); - assert_eq!(platform_from_pci(0x2e06_1af4), None); + // Unlisted, Turing, Ada, and Hopper IDs stay None. assert_eq!(platform_from_pci(0x2e07_10de), None); assert_eq!(platform_from_pci(0x1e02_10de), None); + assert_eq!(platform_from_pci(0x26b1_10de), None); + assert_eq!(platform_from_pci(0x2330_10de), None); + // Integrated Tegra GPUs without PCI device IDs. assert_eq!(platform_from_capability(8, 7), Some("ga10b")); + assert_eq!(platform_from_capability(11, 0), Some("gb10b")); assert_eq!(platform_from_capability(12, 1), None); assert_eq!(platform_from_capability(8, 6), None); }