Skip to content

Commit 680ac0e

Browse files
jan-wassenbergcopybara-github
authored andcommitted
Add blob_path to config deduction message
PiperOrigin-RevId: 782004316
1 parent 349c86f commit 680ac0e

6 files changed

Lines changed: 15 additions & 6 deletions

File tree

BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ cc_library(
132132
deps = [
133133
":basics",
134134
"//compression:types",
135+
"//io",
135136
"//io:fields",
136137
"@highway//:hwy", # base.h
137138
],

gemma/configs.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "compression/types.h" // Type
2525
#include "io/fields.h" // IFields
26+
#include "io/io.h" // Path
2627
#include "hwy/base.h"
2728

2829
namespace gcpp {
@@ -708,7 +709,7 @@ bool ModelConfig::OverwriteWithCanonical() {
708709
return found;
709710
}
710711

711-
Model DeduceModel(size_t layers, int layer_types) {
712+
Model DeduceModel(const Path& blob_path, size_t layers, int layer_types) {
712713
switch (layers) {
713714
case 2:
714715
return Model::GEMMA_TINY;
@@ -740,8 +741,8 @@ Model DeduceModel(size_t layers, int layer_types) {
740741
return Model::PALIGEMMA2_772M_224;
741742
*/
742743
default:
743-
HWY_WARN("Failed to deduce model type from layer count %zu types %x.",
744-
layers, layer_types);
744+
HWY_WARN("Failed to deduce model type from %s, layer count %zu types %x.",
745+
blob_path.path.c_str(), layers, layer_types);
745746
return Model::UNKNOWN;
746747
}
747748
}

gemma/configs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "compression/types.h" // Type
2929
#include "io/fields.h" // IFieldsVisitor
30+
#include "io/io.h" // Path
3031
#include "util/basics.h"
3132

3233
namespace gcpp {
@@ -482,7 +483,7 @@ enum DeducedLayerTypes {
482483
};
483484

484485
// layer_types is one or more of `DeducedLayerTypes`.
485-
Model DeduceModel(size_t layers, int layer_types);
486+
Model DeduceModel(const Path& blob_path, size_t layers, int layer_types);
486487

487488
} // namespace gcpp
488489

gemma/model_store.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ static ModelConfig ReadOrDeduceConfig(BlobReader& reader,
219219
// Always deduce so we can verify it against the config we read.
220220
const size_t layers = DeduceNumLayers(reader.Keys());
221221
const int layer_types = DeduceLayerTypes(reader);
222-
const Model deduced_model = DeduceModel(layers, layer_types);
222+
const Model deduced_model =
223+
DeduceModel(reader.blob_path(), layers, layer_types);
223224

224225
ModelConfig config;
225226
// Check first to prevent `CallWithSpan` from printing a warning.

io/blob_store.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ class BlobStore {
297297
}; // BlobStore
298298

299299
BlobReader::BlobReader(const Path& blob_path)
300-
: file_(OpenFileOrAbort(blob_path, "r")), file_bytes_(file_->FileSize()) {
300+
: blob_path_(blob_path),
301+
file_(OpenFileOrAbort(blob_path, "r")),
302+
file_bytes_(file_->FileSize()) {
301303
if (file_bytes_ == 0) HWY_ABORT("Zero-sized file %s", blob_path.path.c_str());
302304

303305
BlobStore bs(*file_);

io/blob_store.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class BlobReader {
5454
// Aborts on error.
5555
explicit BlobReader(const Path& blob_path);
5656

57+
const Path& blob_path() const { return blob_path_; }
58+
5759
// Non-const version required for File::Map().
5860
File& file() { return *file_; }
5961
const File& file() const { return *file_; }
@@ -101,6 +103,7 @@ class BlobReader {
101103
}
102104

103105
private:
106+
Path blob_path_;
104107
std::unique_ptr<File> file_;
105108
const uint64_t file_bytes_;
106109

0 commit comments

Comments
 (0)