Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions dag/extdeps/huggingface/hub.dag
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module extdeps.huggingface.hub

import std.types { String, Bool, List, NonEmptyStr }
import std.nat { Nat }
import std.measure { ByteSize, byte_size_count, Gibibyte, gibibyte, gibibyte_scale_factor_bytes }
import extdeps.external_authority { ExternalAuthority }
import extdeps.uri { Uri, Https, uri_wire }

Expand Down Expand Up @@ -224,3 +226,55 @@ data hub_snapshot_download_refuses_incomplete_snapshots: Bool = true
// sharing above does not happen. A consumer sizing disk against a shared-blob assumption is wrong by
// a factor of the revision count when this is set.
data hub_disable_symlinks_env_var: NonEmptyStr = "HF_HUB_DISABLE_SYMLINKS" as NonEmptyStr

// ── A CHECKPOINT MANIFEST AT AN EXACT REVISION, WHICH IS THE HUB'S OWN STATEMENT ─────────────
//
// THE SHAPE IS THE HUB'S, NOT ANY MODEL'S. What the model API answers for a repo at a revision --
// how many safetensors shards, how many bytes they sum to, how many bytes the whole snapshot is --
// is the same five-field fact for every checkpoint on the Hub, and it lived for a while inside
// extdeps.zhipu.glm_5_3_flash as `GlmCheckpointManifest`, which made the base GLM model and a
// third party's redistribution import their ordinary Hub facts from a sibling Flash product. That
// is a generic shape single-homed in a product module: one authority, wrong layer. It moved here,
// and each product module owns only its concrete row.
//
// THE REVISION IS PART OF THE FACT, not a note beside it. A manifest without its revision is a
// claim about a branch, and Hub repositories move under their readers. TWO SUMS, BOTH HUB FACTS AND
// NEITHER A RUNTIME CLAIM: `safetensors_bytes` is the sum of the safetensors files' bytes at the exact
// revision, as the model API reports them; `repository_total_bytes` is the sum over every file of the
// snapshot, config and tokenizer included. What a runtime loads, shards or replicates from those
// files is a placement fact owned elsewhere. They are separated so a consumer says which sum it is
// asking for, even where the gap is a rounding error today.
type HubCheckpointManifest sole_constructor {
revision: NonEmptyStr
safetensors_shard_count: Nat
safetensors_bytes: ByteSize
repository_total_bytes: ByteSize
read_by: NonEmptyStr
}

// THE MINT, because the seal is per module and the rows are not: sole_constructor refuses a partial
// or reordered literal anywhere, and product modules author their rows through this.
fn hub_checkpoint_manifest(
revision: NonEmptyStr,
safetensors_shard_count: Nat,
safetensors_bytes: ByteSize,
repository_total_bytes: ByteSize,
read_by: NonEmptyStr,
) -> HubCheckpointManifest {
HubCheckpointManifest {
revision: revision,
safetensors_shard_count: safetensors_shard_count,
safetensors_bytes: safetensors_bytes,
repository_total_bytes: repository_total_bytes,
read_by: read_by,
}
}

// GiB IS DERIVED FOR PROSE AND SCREENING AND IS NOT A SECOND AUTHORITY, AND IT ROUNDS UP -- the only
// safe direction for a consumer that screens on it: a ceiling can refuse a candidate a byte-exact
// test would admit, never admit one it would refuse. Feasibility arithmetic that must be exact reads
// `safetensors_bytes` and does not round at all.
fn hub_checkpoint_manifest_gibibytes(m: HubCheckpointManifest) -> Gibibyte {
let scale = gibibyte_scale_factor_bytes()
gibibyte(count: (byte_size_count(b: m.safetensors_bytes) + (scale - 1)) / scale)
}
285 changes: 285 additions & 0 deletions dag/extdeps/radixark/glm_5_3_nvfp4.dag

Large diffs are not rendered by default.

138 changes: 138 additions & 0 deletions dag/extdeps/zhipu/glm_5_3.dag
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
module extdeps.zhipu.glm_5_3

import std.types { NonEmptyStr }
import std.nat { Nat }
import std.measure { TokenCount, token_count, byte_size }
import std.decl_ref { DeclarationRef, WholeDeclaration }
import extdeps.external_authority { ExternalAuthority, ExternalModelScope, ExternalSubjectRef }
import extdeps.huggingface.hub { HubRepoId, HubModelRepo, hub_repo_https_uri, HubCheckpointManifest, hub_checkpoint_manifest }

// GLM-5.3 -- THE BASE MODEL, NOT GLM-5.3-FLASH. The two are independently published Z.ai
// checkpoints with different architecture classes (this one declares GlmMoeDsaForCausalLM, Flash
// declares Glm5NextForConditionalGeneration), different shapes and different manifests, so under
// DESIGN section 3's external-decomposition rule each is its own module authority. This module
// exists because a THIRD PARTY's quantized redistribution of it (extdeps.radixark.glm_5_3_nvfp4)
// needs a base to cite: the architecture class and the MoE shape are facts about the model Z.ai
// published, which the redistribution inherits rather than owns.
data glm_5_3_hub_repo: HubRepoId = HubRepoId {
kind: HubModelRepo,
path: "zai-org/GLM-5.3" as NonEmptyStr,
}

data extdeps_external_authority_anchor: ExternalAuthority = ExternalAuthority {
uri: hub_repo_https_uri(repo: glm_5_3_hub_repo),
}

data extdeps_model_scope: ExternalModelScope = ExternalModelScope {
subject: ExternalSubjectRef {
declaration: DeclarationRef {
module_path: "extdeps.zhipu.glm_5_3",
decl_name: "glm_5_3_hub_repo",
field: WholeDeclaration
}
},
first_citation: extdeps_external_authority_anchor,
further_citations: [],
}

// THE ARCHITECTURE CLASS IS THE STRING A RUNTIME'S REGISTRY IS ASKED FOR, read from `architectures`
// (its sole entry) in config.json at the pinned revision below. Every consumer that needs to know
// whether an image can load this model -- or any quantization of it -- asks for THIS declaration,
// never a spelling of its own.
data glm_5_3_architecture_class: NonEmptyStr = "GlmMoeDsaForCausalLM" as NonEmptyStr

// ── THE MoE SHAPE, AS config.json STATES IT ──────────────────────────────────────────────────
//
// THESE ARE THE FACTS A FOOTPRINT DERIVATION NEEDS AND THEY ARE THE MODEL'S, NOT A CHECKPOINT'S. A
// quantized redistribution changes how many bytes each parameter occupies; it does not change how
// many parameters a routed expert has, how many experts a token visits, or which layers are dense.
// So the shape is carried once, here, and the redistribution's byte accounting is derived from it.
//
// THE FIELD NAMES ARE config.json's OWN. Renaming `first_k_dense_replace` to something friendlier
// would be a second name for one upstream fact, and the next reader diffing this row against the
// file would have to translate.
type GlmMoeDsaShape sole_constructor {
num_hidden_layers: Nat
first_k_dense_replace: Nat
hidden_size: Nat
intermediate_size: Nat
moe_intermediate_size: Nat
n_routed_experts: Nat
num_experts_per_tok: Nat
n_shared_experts: Nat
num_nextn_predict_layers: Nat
vocab_size: Nat
kv_lora_rank: Nat
q_lora_rank: Nat
max_position_embeddings: TokenCount
read_by: NonEmptyStr
}

data glm_5_3_shape: GlmMoeDsaShape = GlmMoeDsaShape {
num_hidden_layers: 78,
first_k_dense_replace: 3,
hidden_size: 6144,
intermediate_size: 12288,
moe_intermediate_size: 2048,
n_routed_experts: 256,
num_experts_per_tok: 8,
n_shared_experts: 1,
num_nextn_predict_layers: 1,
vocab_size: 154880,
kv_lora_rank: 512,
q_lora_rank: 2048,
max_position_embeddings: token_count(count: 1048576),
read_by: "config.json fetched from the Hub at revision aca966e4e02791568aa6a4ced368624b3d897f42 on 2026-09-18, each field copied under its own key; the same keys in RadixArk/GLM-5.3-NVFP4's config.json at 6e389189d564d9d3e4ea7fa284fe91f136d8ae2a were diffed against these and agree" as NonEmptyStr,
}

// THE MoE LAYER COUNT IS DERIVED, NOT STATED. config.json says how many layers there are and how
// many leading ones are dense; the count of layers that carry routed experts is the difference, and
// a hand-written 75 beside those two rows would be the third spelling of one fact. The nextn
// predictor layer (index num_hidden_layers) is NOT a hidden layer and is not in this count: it is
// carried separately by whichever checkpoint materialises it.
//
// A DENSE PREFIX LONGER THAN THE STACK IS A MALFORMED SHAPE, AND THE ANSWER IS A REFUSAL, NOT ZERO.
// Zero MoE layers would be a plausible number that no consumer could tell from a real dense model,
// so the fold is partial and every consumer carries the absence through.
fn glm_5_3_moe_layer_count(s: GlmMoeDsaShape) -> Nat? {
if s.num_hidden_layers >= s.first_k_dense_replace {
Present { value: s.num_hidden_layers - s.first_k_dense_replace }
} else {
none
}
}

// ONE ROUTED EXPERT IS THREE PROJECTIONS -- gate, up and down -- each hidden_size by
// moe_intermediate_size. The three is not a guess about the architecture: the redistribution
// module's representative expert carries exactly three weight tensors of exactly those shapes, and
// its witness checks this product against the bytes the shard header declares for them.
fn glm_5_3_routed_expert_projection_count() -> Nat {
3
}

fn glm_5_3_routed_expert_params(s: GlmMoeDsaShape) -> Nat {
glm_5_3_routed_expert_projection_count() * s.hidden_size * s.moe_intermediate_size
}

// THE EXPERTS ONE TOKEN VISITS ACROSS THE WHOLE STACK: num_experts_per_tok in each MoE layer. This
// is the multiplicity an expert-offload scheme would have to stream per decoded token, and it is
// the reason such a scheme is refused on unified-memory hardware (gunbc.spark.serving_fit_projection).
fn glm_5_3_routed_expert_visits_per_token(s: GlmMoeDsaShape) -> Nat? {
match glm_5_3_moe_layer_count(s: s) {
Absent => none
Present { value: layers } => Present { value: s.num_experts_per_tok * layers }
}
}

// ── THE NATIVE CHECKPOINT MANIFEST AT AN EXACT REVISION ──────────────────────────────────────
//
// Z.ai's own artifact is native FP8 (config.json: quant_method fp8, weight_block_size [128, 128]).
// It is carried so a redistribution can state what it quantized FROM, and so a consumer can see
// that the 465 GB NVFP4 artifact is a compression of a 756 GB one rather than a different model.
data glm_5_3_native_manifest: HubCheckpointManifest = hub_checkpoint_manifest(
revision: "aca966e4e02791568aa6a4ced368624b3d897f42" as NonEmptyStr,
safetensors_shard_count: 141,
safetensors_bytes: byte_size(count: 755632050320),
repository_total_bytes: byte_size(count: 755663689206),
read_by: "the Hub model API for zai-org/GLM-5.3 with blobs enabled, summed over the 141 safetensors siblings of its 155 files, read 2026-09-18. The response's own sha is the revision above and its lastModified was 2026-09-04T06:41:23Z" as NonEmptyStr,
)
47 changes: 7 additions & 40 deletions dag/extdeps/zhipu/glm_5_3_flash.dag
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
module extdeps.zhipu.glm_5_3_flash

import std.types { NonEmptyStr }
import std.nat { Nat }
import std.measure {
TokenCount,
token_count,
ByteSize,
byte_size,
byte_size_count,
Gibibyte,
gibibyte,
gibibyte_scale_factor_bytes,
}
import std.measure { TokenCount, token_count, byte_size }

import extdeps.external_authority { ExternalAuthority }
import extdeps.uri { Uri, Https }
import extdeps.huggingface.hub { HubCheckpointManifest, hub_checkpoint_manifest }

// THE GLM-5.3-FLASH FAMILY, as its own extdeps authority for the reason extdeps.deepseek.deepseek_v4
// is one: an independently versioned upstream model, governed by Z.ai, is not a property of whatever
Expand Down Expand Up @@ -119,7 +110,9 @@ data glm_5_3_flash_vllm_integration_commit: NonEmptyStr = "385dce36bcee42309924a
// caught the first divergence. That is the section 3 violation, and it is mine: I added the second
// and third spellings while repairing other findings.
//
// THE MANIFEST BELONGS HERE RATHER THAN IN gunbc BECAUSE IT IS NOT AN OBSERVATION OF THIS FLEET. The
// THE SHAPE IS extdeps.huggingface.hub HubCheckpointManifest -- a Hub fact, not a GLM one -- and
// this module owns only the row. THE MANIFEST BELONGS IN extdeps RATHER THAN IN gunbc BECAUSE IT IS
// NOT AN OBSERVATION OF THIS FLEET. The
// byte sizes at a content-addressed revision are what the publishing Hub says about its own files,
// re-readable by anyone from the cited authority. What a Spark's disk holds after a download IS a
// fleet observation and stays in the gunbc layer, which is exactly the distinction the selector's
Expand All @@ -138,37 +131,11 @@ data glm_5_3_flash_vllm_integration_commit: NonEmptyStr = "385dce36bcee42309924a
// multi-terabyte disk. It is separated anyway, because the carrier's job is to say which quantity a
// consumer is asking for, and a 28 MB coincidence today is not a reason to conflate two questions
// that will diverge on the next artifact.
type GlmCheckpointManifest sole_constructor {
revision: NonEmptyStr
safetensors_shard_count: Nat
safetensors_bytes: ByteSize
repository_total_bytes: ByteSize
read_by: NonEmptyStr
}

data glm_5_3_flash_native_manifest: GlmCheckpointManifest = GlmCheckpointManifest {
data glm_5_3_flash_native_manifest: HubCheckpointManifest = hub_checkpoint_manifest(
revision: "eb9eb208eb0d988989d07a6a12d0fdeb5f52574a" as NonEmptyStr,
safetensors_shard_count: 62,
safetensors_bytes: byte_size(count: 328337455672),
repository_total_bytes: byte_size(count: 328366173469),
read_by: "the Hub model API for zai-org/GLM-5.3-Flash at that exact revision with blobs enabled, summed over the safetensors siblings, read 2026-09-08. The response's own sha matched the revision and its lastModified was 2026-09-07T12:13:47Z" as NonEmptyStr,
}

// GiB IS DERIVED FOR PROSE AND IS NOT A SECOND AUTHORITY. The serving-arm row that carried 306 was a
// rounded restatement of these bytes; a consumer wanting a human-sized number computes it here rather
// than authoring one, so the rounding can never drift from the figure it rounds.
//
// AND IT ROUNDS UP, WHICH IS THE ONLY SAFE DIRECTION FOR A CONSUMER THAT SCREENS ON IT. The first
// version of this helper used integer division, yielding 305 for a 305.79 GiB artifact -- and
// gunbc.spark.serving_arm feeds exactly this value into a positive fit check. Rounding DOWN
// understates the weights, which makes that check more permissive: it is the wrong direction for a
// bound whose entire purpose is to refuse. A ceiling can only refuse a candidate that a byte-exact
// test would have admitted, never admit one it would have refused.
//
// A CONSUMER THAT NEEDS EXACTNESS READS THE BYTES. This helper exists for screening and for prose,
// and both are served by the conservative direction; feasibility arithmetic that must be exact takes
// `safetensors_bytes` and does not round at all.
fn glm_manifest_gibibytes(m: GlmCheckpointManifest) -> Gibibyte {
let scale = gibibyte_scale_factor_bytes()
gibibyte(count: (byte_size_count(b: m.safetensors_bytes) + (scale - 1)) / scale)
}
)
2 changes: 2 additions & 0 deletions dag/gunbc/extdeps_scope_frontier.dag
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ data scope_carrier_paths: List<String> = [
"dag/extdeps/cloudflare/account_api_tokens.dag",
"dag/extdeps/cloudflare/r2.dag",
"dag/extdeps/deepseek/deepseek_v4_1_flash.dag",
"dag/extdeps/zhipu/glm_5_3.dag",
"dag/extdeps/radixark/glm_5_3_nvfp4.dag",
"dag/extdeps/docker/images/gitcommit90_glm_53_one_spark.dag",
"dag/extdeps/docker/images/timothystewart6_vllm_gb10.dag",
"dag/extdeps/docker/images/xomoxcc_dgx_spark_sglang.dag",
Expand Down
Loading
Loading