Repository navigation
deepseek41: the original V4.1-Flash-1017 folder opens, plans its ranks and lists each rank's reads - #1160
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: The preflight mixes memory pools, undercounts row pages, and adds a duplicate test harness.
Must fix
1. Reject discrete cards before comparing host bytes with VRAM
crates/gpu-gates/src/ds41_preflight.rs:44 Kind A. On a discrete card, RankPool::of supplies VRAM. The call through rank_ledgers to placement::tp::preflight sums device allocations with host ring shadows, row pages and read buffers against that pool. Increasing --ctx grows the host shadows; when the sum crosses VRAM, preflight returns Short even if device allocations fit and RAM holds the host allocations. Host capacity is never checked.
Guard the new entry point now, before callers depend on these admission results. Until separate host and device checks exist, replace the pool declaration with:
let spec = workstation::spec_of_device(here);
if workstation::unified_of(&spec).is_none() {
return Err(
"--preflight requires unified memory; host and device budgets are separate on this card"
.into(),
);
}
let pool = RankPool::of("local".into(), &spec);2. Count every page a gathered plane can touch
crates/model/src/arch/deepseek41/tp.rs:287 Kind A. folder::table_rows retains the value and scale file ranges without a page-alignment guard. For the 256-byte value and 8-byte scale rows, an unaligned row can touch more than the two 4,096-byte pages reserved here (up to four [derived]). rank_need passes the understated reserve to preflight, so a pool between the computed and required totals is accepted. The read-set gate never asserts row_cache.
Reuse crates/placement/src/placement/room.rs:219 now so both planners keep one sizing rule (R14). Add this arm before its fallback:
(RowTableSource::Parts, GgmlType::MXFP8) => {
let groups = bytes / 33;
span(groups * 32) + span(groups)
}Replace the new page-cache calculation with:
let page = crate::placement::host_lock::page_bytes()?;
let mut tables = roles::classify(split, hp)?;
for t in &mut tables.tensors {
t.gathered_rows = t.gathered_rows.map(|_| cols.end - cols.start);
}
row_cache = crate::placement::row_room(
&tables,
run.batch,
page,
crate::placement::RowTableSource::Parts,
)?;Assert the resulting page reserve in the gate; replacing the common page-span calculation with one page per plane must turn it red.
3. Share the corpus comparison harness
crates/tokenizer/src/pretok.rs:1606 Kind B. This duplicates crates/tokenizer/src/pretok.rs:1552. Their 46-line definitions are identical after substituting the function name, fixture and pre-tokenizer. The replacement below reduces the two definitions and their test attributes to 38 lines [derived].
Extract the shared comparison now so future assertion fixes have one owner (R14). Replace both definitions, including their test attributes, with:
fn hf_pieces(pre: Pre, fixture: &str) {
let path = format!(
"{}/../hf/tests/fixtures/{fixture}.json.gz",
env!("CARGO_MANIFEST_DIR")
);
let corpus: serde_json::Value = serde_json::from_reader(
flate2::read::GzDecoder::new(
std::fs::File::open(&path).unwrap_or_else(|e| panic!("{path}: {e}")),
),
).unwrap();
let cases = corpus["cases"].as_array().unwrap();
assert!(cases.len() >= 11_000, "{} cases in {path}", cases.len());
let mut scratch = Scratch::default();
for case in cases {
let text = case["text"].as_str().unwrap();
let want: Vec<usize> = serde_json::from_value(case["pieces"].clone()).unwrap();
let cpts: Vec<u32> = text.chars().map(u32::from).collect();
let mut at = 0;
let got: Vec<usize> = split(pre, &cpts, &mut scratch).iter().map(|&n| {
let bytes = cpts[at..at + n].iter()
.map(|&c| char::from_u32(c).unwrap().len_utf8())
.sum();
at += n;
bytes
}).collect();
assert_eq!(got, want, "{path}: {text:?}");
}
}
#[test]
fn qwen2_hf_pieces_are_hugging_faces() {
hf_pieces(Pre::Qwen2Hf, "qwen2-hf-pieces");
}
#[test]
fn deepseek_v3_hf_pieces_are_hugging_faces() {
hf_pieces(Pre::DeepseekV3Hf, "deepseek-v3-hf-pieces");
}Checked
Validated all three citations against added lines, followed the budget and stored-plane paths, and compared both corpus definitions. The read-set gate checks KV, shadows, staging and gathers but has no assertion on row_cache. No escape-catalog pattern or ledger lesson applies to these findings.
Notes
Validation used static inspection; no local Rust build or hardware gate was run.
The PR body lacks FAIL-first output for the new read-set gate. GPU evidence names earlier commits and provides no just gate-* output.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/generate_ds41.rs, crates/gpu-gates/src/ds41_preflight.rs, crates/gpu-gates/src/lib.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
…s and lists each rank's reads DeepSeek-V4.1-Flash-1017's checkpoint folder (model_type deepseek_v41) reads as deepseek41 (model_hf::arch::deepseek41::Ds41Map): every trunk tensor in the deepseek41 names, the routed experts' MXFP4 codes and E8M0 scales as MXFP4 stacks, the 32 by 32 F8_E4M3 projections as MXFP8, the Engram tables' two planes as MXFP8 row tables read where the folder stores them (engram::rows::PlanarTable), the draft and the vision tower skipped by reason. The header's keys come from the config; the Engram hash constants (multipliers, primes, offsets, token map) are derived as the reference derives them (hf::engram), and the tokenizer reads as deepseek-v3 with its Hugging Face reading (Pre::DeepseekV3Hf). Tensor parallel: model::arch::deepseek41::tp cuts each tensor (heads, output groups, inner width, vocabulary rows, Engram hash columns) and counts a rank's need beside its weights; placement::tp::preflight admits each rank by every item and refuses a short one with the items. model_hf::arch::deepseek41::rank_reads lists the file bytes a rank reads, from the plan the load reads by, the Engram rows of its hash columns at their original row ids. generate_ds41 --preflight, in a build with the checkpoint feature, prints each rank's ledger; fixture ds41-folder writes an original-format fixture folder. Added tokens marked normalized are read under a normalizer that changes no text, unless one can overlap an unnormalized one.
2c0d558 to
511f1a8
Compare
There was a problem hiding this comment.
Since the last review:
- Fixed 1: crates/gpu-gates/src/ds41_preflight.rs:85 rejects discrete cards before budgeting.
- Fixed 2: crates/model/src/arch/deepseek41/tp.rs:294 uses the common row-page owner. The gate now asserts each rank's reserve.
- Fixed 3: crates/tokenizer/src/pretok.rs:1547 shares the corpus comparison across all three pre-tokenizers.
Verdict: CLEAN: All earlier must-fix items are resolved, and no new defect survived the interdiff review.
Checked
Duplicates: 3 new function definitions checked; no duplicate owner remains. Dryer supplied no pairs.
Complexity: one admission guard and one quant-format arm added; no kernel or decode-step changes. Crapper supplied no results.
Silent failure: 0 new fallback sites. Admission, malformed-row and sizing errors reach the preflight caller.
Tests, static mutation checks: removing the admission guard fails unwrap_err; deleting crates/placement/src/placement/room.rs:233 fails the four-page assertion; dropping crates/model/src/arch/deepseek41/tp.rs:291 fails the two- and four-rank assertions; forcing the wrong pre-tokenizer at crates/tokenizer/src/pretok.rs:1565 fails the corpus comparison.
Validation: the extracted helper preserves both existing comparison bodies. All three corpora meet its size and byte-coverage checks. Independent page arithmetic covers every offset on 4, 16 and 64 KiB pages, including unaligned planes.
Gates: no pin, threshold or assertion relaxed; existing corpus assertions retained.
Escape catalog: no matching pattern. No ledger lessons are in force.
Notes
Dryer and crapper did not run because their Python modules are missing.
No local Rust build or hardware gate ran. The PR body lacks FAIL-first output for the revised checks. Its card evidence names earlier commits and contains no just gate-* commands with output.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/generate_ds41.rs, crates/gpu-gates/src/ds41_preflight.rs, crates/gpu-gates/src/lib.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
DeepSeek V4.1 Flash 원본 폴더를 열고, 랭크별 배치와 읽을 범위를 계획하는 기능입니다.
What and why
The original DeepSeek-V4.1-Flash-1017 checkpoint folder (MXFP4 experts, MXFP8 dense weights, Engram tables, Hugging Face tokenizer) now opens through the common folder reader. A tensor-parallel cut table, a per-rank memory preflight and a per-rank read-set are built on top of it, so a rank can be planned and loaded from the original files. A rank count that does not divide a cut's units is refused by name.
model_hf::arch::deepseek41::Ds41Mapmaps the trunk tensors to the deepseek41 names. The Engram hash constants and the token map come fromconfig.jsonandtokenizer.json.hf::modeloptreads MXFP4 and MXFP8 (E8M0 scales);hf::vocabandtokenizer::Pre::DeepseekV3Hfread the folder's tokenizer.model::arch::deepseek41::tpholds the cut table (heads, groups, experts, head rows, Engram columns).placement::tp::preflightchecks every rank's weights and buffers against its pool and names the item that does not fit.model_hf::arch::deepseek41::rank_readslists the byte ranges a rank reads, merged where they lie within 1 MiB.generate_ds41 --preflightcounts every rank against one unified pool and refuses a card with its own memory by name, since a rank's need adds device allocations to host ones.placement::row_roomcounts MXFP8 part-source rows as separate code and scale planes, the way it already counted NVFP4 rows, so the preflight'srow_cacheis the host base pages those planes touch.fixture ds41-folder <source> <out> [--seed N]writes a small folder in the original format for tests and gates;generate_ds41 --preflight <folder> --ranks N[,N...]prints onetp needrecord per rank.Release notes: Added: DeepSeek V4.1 Flash original checkpoint folders open and plan their tensor-parallel ranks.
Code shape
copying it (
AGENTS.md"Common code first",docs/rust-quality.mdR14). Where I found an existing copy, Inamed it below.
(tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
tools/check-comments.sh).PIN(YYYY-MM-DD):and its reason.
cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line):crates/model/src/arch/deepseek41/tp.rsandcrates/model/src/arch/glm5next/tp.rsboth had the cut and span bodies; they now live once inplacement::tp::{cut_blocks, span_of, cut_units}and each family keeps a one-line wrapper with its own cut rule. The tokenizer's Hugging Face corpus comparisons (crates/tokenizer/src/pretok.rs) share onehf_pieceshelper instead of three copies.What I ran
Upstream base
c446bc7420e365a0b15d1181fa7efc20a723f5af, PR head511f1a8af2cfa9f0b203f81e7119eab417f22428.Card:
Original-format fixture folder, written from the DeepSeek-V4.1-Flash-1017 folder (
$DS41_1017, mounted read-only):generate_ds41 --preflighton that folder, built and run on the GB10. Every rank count plans, and each line lists the rank's weights, buffers and the bytes it reads:The same binary builds for the RTX 5090 machine's card family:
Unit tests and the rank read-set gate. For each of the 4 ranks at N=4, the gate loads a sparse folder holding only that rank's read-set and compares its parts, values and scales byte for byte with the whole folder:
Host-side gates on the PR head, run on the GB10 with
just gate-ds41-place(the V4.1--placeword, the llama launch seats, the GLM generator and the preflight's unified-pool test):The preflight's refusal fails first: with the unified-memory check replaced by
if false, the same test is red.The rank read-set gate (
just gate-ds41-reads) checks the row page count. It passes, and it fails when the count goes back to two pages a row, when a plane is counted as one page, or when the MXFP8 plane arm is removed. The unit testthe_row_room_counts_the_hosts_base_pagefails without the MXFP8 arm:Hardware (if the change is for a machine)
nvidia-smiabove).sm_120abuild ofgenerate_ds41above.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.